Jump to content
OMRON Forums

Sample C PLC


bradp
 Share

Recommended Posts

This is a sample C PLC which shows how use a few of the basic PPmac API functions. The API is already initialized in a CPLC so its functions can be used directly. For a more complete example look into the two sample projects installed with the PPmac IDE. #include #include #include #define CHAR_BUF_SIZE 0x10000 void user_plcc() { double dMtr1Kp, dSysDdata1, dPartNum, dGateIOData, PPmacData; char response[CHAR_BUF_SIZE]; volatile GateArray1* Gate1; volatile GateIOStruct* GateIO; int result; //------- Shared Memory Pointer Examples ------------------------------------------ dMtr1Kp = pshm->Motor[1].Servo.Kp; // read Motor[1].Servo.Kp dSysDdata1 = *((double *) (((double *) pushm) + 1)); // read Sys.Ddata[1] Gate1 = GetGate1MemPtr(4); // use CAPI to get pointer to the Gate1[4] structure if(Gate1) { dPartNum = Gate1->AdcStrobe >> 8; // lower 8-bits are not used in Gate1 } GateIO = GetGateIOMemPtr(0); // use CAPI to get pointer to the GateIO[0] structure if(GateIO) { dGateIOData = GateIO->DataReg[0] >> 8; // lower 8-bits are not used in GateIO } //------- PPmac API Examples ------------------------------------------------------ result = Command((char*) "#1"); // Send string to command processor with no response desired result = GetResponse((char*) "Motor[1].Servo.Kp", response, CHAR_BUF_SIZE, 0); // Send string to command processor and get an ASCII response result = GetPmacVar("Motor[1].Servo.Kp", &PPmacData); // Send string to command processor and get a numeric response }
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Guest
This topic is now closed to further replies.
 Share


×
×
  • Create New...