jackvoxel8.com Posted August 19, 2018 Share Posted August 19, 2018 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? Link to comment Share on other sites More sharing options...
curtwilson Posted August 22, 2018 Share Posted August 22, 2018 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. Link to comment Share on other sites More sharing options...
jackvoxel8.com Posted August 22, 2018 Author Share Posted August 22, 2018 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? Link to comment Share on other sites More sharing options...
curtwilson Posted August 22, 2018 Share Posted August 22, 2018 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. Link to comment Share on other sites More sharing options...
jackvoxel8.com Posted August 30, 2018 Author Share Posted August 30, 2018 Thanks Curt Link to comment Share on other sites More sharing options...
Recommended Posts