Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading analog value at set positions during a move
I am trying to generate a CompTable with an analog distance sensor I have mounted to my gantry.

My goal is to command a continuous move along one axis, then get readings from my analog distance sensor at set distances along that move (say every 20mm). Ideally I would like to put these readings directly into the CompTable array (after some transformations to convert raw sensor readings to motor counts).

I currently have a PLC that simply loops, looks at current position, and records the sensor value when current position is equal to desired position.

Is there a simpler or more automated way to accomplish this?
With analog inputs, I don't think there is a fundamentally better way. Because we cannot sample analog inputs asynchronously (as we can the encoder counters), this task looks like it has to be down with a software algorithm as you are doing.
I am trying to trigger off of encoder position, not off of the analog input.

I've been reading through the User's Manual trying to figure out how to solve this, and I think a Capture/Compare Interrupt Service Routine might be what I need (p796)

Do you have any experience with those?
It is possible to use the Capture/Compare ISR to start your routine extremely quickly on reaching a particular position (sub-servo cycle timing), but I'm not sure it will do you any good because you can't sample the ADC at that instant, so you lose the time advantage you gain by using the ISR.
Thanks Curt

Forum Jump:

Users browsing this thread: 1 Guest(s)