Jump to content
OMRON Forums

How to convert a RT address to user-space address


bradp
 Share

Recommended Posts

If you are working with data from IO memory then use this method. void user_plcc() { int motorNumber; int status; unsigned offset; unsigned* pStatus; pshm->P[3]++; // debug counter motorNumber = (int) pshm->P[1]; offset = (unsigned) piom + (unsigned)pshm->Motor[motorNumber].pEncStatus - (unsigned)pshm->pRtiom; // calculate offset in user space since pEncStatus holds offset in RT space pStatus = offset; status = *pStatus; pshm->P[5] = (double) offset; // debug pshm->P[2] = (double) status; pshm->P[4]++; // debug counter pshm->UserAlgo.BgCplc[0] = 0; // only run once } If you want to do something equivalent to adding ".a" to a structure name (Motor[].ActPos.a) then in C you are working with data from user shared memory and want the offset in RT shared memory. void user_plcc() { unsigned offset; pshm->P[3]++; // debug counter offset = (unsigned) pshm->pRtshm + (unsigned)&(pshm->Motor[1].ActPos) - (unsigned)pshm; // calculate offset in RT space since pshm->Motor[1].ActPos holds offset in user space pshm->Gather.Addr[1] = offset; pshm->UserAlgo.BgCplc[0] = 0; // only run once }
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...