Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Storing lifetime distance traveled per axis?
I would like to store total distance traveled for the axes in my machine. These numbers should be resettable through deliberate action but otherwise persist across power cycles and resets.

Does anyone have any ideas for doing this accurately but without putting undue strain on the system resources?
Why not just write a plc which integrates the actual velocity ? (the absolute value, I suppose...)
Yes, like Dave said, use a background PLC to integrate the absolute velocity value, write it to a global variable, and use the Fsave feature to write the value to memory periodically so that it persists across power cycles. See page 1090 for the fsave entry in the PPMAC SRM.
How often could I poll the velocity without affecting performance?
If you poll the velocity in a background script PLC, PMAC will guarantee that the polling will not affect servo/phase/RTI performance. It literally only polls "in the background" (i.e. when the CPU has completed all performance-critical tasks and has time to do other things). This will not be quite as accurate as polling at a set frequency, but for the purposes of tracking lifetime distance traveled (we're talking big numbers probably), it should be OK. Make sense?
Ok so here is some pseudocode to accomplish what I think you all are telling me:

oldTime = currentTime
currentTime = GetTime()
timeDelta = currentTime - oldTime
velocity = GetAxisVelocity()
distance = velocity * timeDelta
totalDistance += distance

I would then run that loop in a PLC as fast as possible and it should have no effect on performance? Let me know if I am missing something.
If you are going to use a PLC, you might want to look at Motor[x].FltrVel or Motor[x].FltrVel2 to get something that's averaged over a longer time. Note that scaling is needed, I think a factor of 16 or 16*Sys.ServoPeriod.

Forum Jump:

Users browsing this thread: 1 Guest(s)