Jump to content
OMRON Forums

Example C Program for ACC-72E CANopen


hongchinlin_992x
 Share

Recommended Posts

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

I just sent this to Stanly today. //-------------------------------------------------------------------------------- #include #include // Global Rt/Gp Shared memory pointers //------------------------------------------------------------- // The following is a projpp created file from the User defines //------------------------------------------------------------- #include "../../Include/pp_proj.h" int main(void) { double fbDate; double dOutData; int nok; char response[255], cmd[255]; InitLibrary(); // load PPmac API pshm = GetSharedMemPtr(); // Get pointer to shaered memory if(!(nok = GetPmacVar((char*)"Acc72E[0].Date", &fbDate))) // get date back as a double pshm->P[1] = fbDate; // debug write to P1 for easy viewing else { sprintf(response,"GetPmacVar Err# = %d\n", - nok); pshm->P[1] = (double) nok; // debug write to P1 for easy viewing } dOutData = 2.0; if(!(nok = SetPmacVar((char*)"Acc72E[0].Output8[0]", dOutData))) // get date back as a double { sprintf(response,"SetPmacVar Ok = %d\n", - nok); pshm->P[3] = (double) nok; // debug write to P3 for easy viewing } else { sprintf(response,"SetPmacVar Err# = %d\n", - nok); pshm->P[3] = (double) nok; // debug write to P3 for easy viewing } if(!(nok = GetResponse((char*)"Acc72E[0].Date", response, 255, 7))) // get data back as string pshm->P[2] = atof(response); // debug write to P2 for easy viewing else { sprintf(response,"GetResponse Err# = %d\n", - nok); pshm->P[2] = (double) nok; // debug write to P2 for easy viewing } sprintf(cmd, "Acc72E[0].Output8[1]=%d\n", 3); if(!(nok = Command((char*) cmd))) // set data as string { sprintf(response,"Command OK = %d\n", - nok); pshm->P[5] = (double) nok; // debug write to P5 for easy viewing } else { sprintf(response,"Command Err# = %d\n", - nok); pshm->P[5] = (double) nok; // debug write to P5 for easy viewing } CloseLibrary(); return 0; }
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...