RaphaelM Posted September 14, 2012 Share Posted September 14, 2012 Hello, I would like to change the value of an output in a CPLC. In a PLC, I write in GateIO[0].DataReg[3], but I can't do that in a CPLC. I can do that with pointers but it's a PLC script which upload the outputs with the pointers values. So the speed of my process is impacted by speed of the PLC. I search the best solution to synchronise a moove on an edge signal. Thanks for your help. RM Link to comment Share on other sites More sharing options...
Omron Forums Support Posted September 14, 2012 Share Posted September 14, 2012 Raphael, In order to write to gate structures in C, you must first define the gate pointer. Pages 483 and following of the Power PMAC User Manual describe this in detail. To get that manual, click "FileDepot" near the top right of the forum page and then go to Power PMAC-->Manuals. Basically for your card, a GateIO card, define a pointer like this: volatile GateIoStruct *MyFirstGateIoIC; Then, assign the pointer to your card's memory address. Since you wrote in your post that you're using GateIo[0], you can use the 0th index in the GetGateIoMemPtr() function as follows: MyFirstGateIoIC = GetGateIoMemPtr(0); Then you can access DataReg[3] like this: MyFirstGateIoIC->DataReg[3]=value; where value is the value you want to write to DataReg[3]. Is that clear? Link to comment Share on other sites More sharing options...
MatthewDean Posted September 17, 2012 Share Posted September 17, 2012 What about the ECAT structures? I can't find anything in the manuals about how to access them from a cplc. Is it possible? Thanks, Matthew Dean Link to comment Share on other sites More sharing options...
Omron Forums Support Posted September 19, 2012 Share Posted September 19, 2012 What about the ECAT structures? I can't find anything in the manuals about how to access them from a cplc. Is it possible? Thanks, Matthew Dean Hi Matthew, If you want to use it in C, this is how you will access. Use pshm->ECAT[slave].IO[number].Data to access from C background program. Typically you will setup the device using system setup. The utility allows you to create user names for the PDO. Using export variable (Right Click on the master) option you can generate the .pmh and .h file , which can be added to your project. Thanks Atul Link to comment Share on other sites More sharing options...
RaphaelM Posted September 20, 2012 Author Share Posted September 20, 2012 Raphael, In order to write to gate structures in C, you must first define the gate pointer. Pages 483 and following of the Power PMAC User Manual describe this in detail. To get that manual, click "FileDepot" near the top right of the forum page and then go to Power PMAC-->Manuals. Basically for your card, a GateIO card, define a pointer like this: volatile GateIoStruct *MyFirstGateIoIC; Then, assign the pointer to your card's memory address. Since you wrote in your post that you're using GateIo[0], you can use the 0th index in the GetGateIoMemPtr() function as follows: MyFirstGateIoIC = GetGateIoMemPtr(0); Then you can access DataReg[3] like this: MyFirstGateIoIC->DataReg[3]=value; where value is the value you want to write to DataReg[3]. Is that clear? Charles, I have follow the user manuel like you wrote. I don't understand why, but I have a syntax error on the declaration of the pointer in red. See my code: ____________________ #include #include #include #define _EnumMode_ #define _PPScriptMode_ #include "../../Include/pp_proj.h" void realtimeinterrupt_plcc() { volatile GateIoStruct *MyFirstGateIoIC; MyFirstGateIoIC=GetGateIOMemPtr(0); MyFirstGateIoIC->DataReg[3]=1; } ____________________ Thanks for your help. [/align] RM Link to comment Share on other sites More sharing options...
MClement Posted September 20, 2012 Share Posted September 20, 2012 didnt think you could define both of these? #define _EnumMode_ #define _PPScriptMode_ Link to comment Share on other sites More sharing options...
JeffLowe Posted September 21, 2012 Share Posted September 21, 2012 didnt think you could define both of these? #define _EnumMode_ #define _PPScriptMode_ Yes. Once _PPScriptMode_ is defined it will not use the _EnumMode_ #ifndef _PP_PROJ_H_ #define _PP_PROJ_H_ //****** ..... #ifdef _PPScriptMode_ ..... #else #ifdef _EnumMode_ ..... // end of #ifdef _EnumMode_ #else // ***** Standard default mode ***** ... #endif #endif #endif //_PP_PROJ_H_ Link to comment Share on other sites More sharing options...
curtwilson Posted September 21, 2012 Share Posted September 21, 2012 Raphael: "I don't understand why, but I have a syntax error on the declaration of the pointer... volatile GateIoStruct *MyFirstGateIoIC; " Try it with a capital "O" in "GateIOStruct". It looks like there was a transcription error somewhere. Link to comment Share on other sites More sharing options...
Recommended Posts