Jump to content
OMRON Forums

Using a CApp to Start a CPLC


bradp

Recommended Posts

When you want to start a CPLC from the IDE terminal you enter UserAlgo.RtiCplc = 1 and when you want to stop the execution you enter UserAlgo.RtiCplc = 0. The same is true for background by using the structure UserAlgo.BgCplc[n] where n is the plc number. If you want a script PLC to enable or disable a CPLC then you can directly use these structures in the script PLC as you use them in the terminal. If you want a CApp to enable or disable a CPLC then you must send these structures using the API GetResponse(), Command(), or SetPmacVar() so that it passes through the interpreter/parser. For example: Command("UserAlgo.RtiCplc=1"); In a CApp you are not allowed to change these structures via the shared memory pointer. Doing: pshm->UserAlgo.RtiCplc=1; Will not work because internally we must do more than just set the structure = 1 to make the CPLC's run and this extra work is done when the interpreter/parser works on the command UserAlgo.RtiCplc=1.
Link to comment
Share on other sites

  • 4 months later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Brad, I tried using the command "UserAlgo.BgCplc[0] = 0" from within my background CPLC to kill itself after running only once. However I get compiler errors: Error 1 'UserAlgo' undeclared (first use in this function) I'm assuming that I need to include a .h file, but which one? Here's my code: #include #include #include //#include //Not sure if this was needed saw it in an example so I tried it, didn't fix UserAlgo problem //------------------------------------------------------------- // The following is a projpp created file from the User defines //------------------------------------------------------------- #include "../../Include/pp_proj.h" #include "../../Include/fswmain.h" void user_plcc() { char *tempstr; sprintf(tempstr, "This is the sprintf in the bgplc"); Send(SEND1_PORT,tempstr); stmach_hmi1statusupdate(); sprintf(tempstr, "This is the sprintf after the state machine call"); Send(SEND1_PORT,tempstr); UserAlgo.BgCplc[0] = 0; // only run once }
Link to comment
Share on other sites

This first post has this correct. You must use the C Api Command() function. This function's description is available in the IDE help pages. You can not just write a PPmac structure name directly in C code. You always need to reference it via a pointer or a function call. In this case use either the GetResponse() or Command() function.
Link to comment
Share on other sites

I eventually figured that out yesterday. This thread is the example that steered me wrong: "How to convert a RT address to user-space address" http://forums.deltatau.com/showthread.php?tid=293&highlight=bgcplc It shows a write to a PPMAC structure in C code. I actually cut and pasted the following line in my code from this example: UserAlgo.BgCplc[0] = 0; // only run once Apparently the example was in error.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...