Skip to main content
Submitted by mwilk on Fri, 02/10/2017 - 12:40

Using a rotary encoder for position input:

After a defined distance, I need to reset the axis back to zero. Example: DEX = 0

This will be repetitive: when TDX == setpoint, then DEX=0, repeat.

Is there a way to automate this rather than put it into a loop and continually monitor the encoder count?

My concern is that if just monitor the TDX until the setpoint and then send the DEX command, I will steadily miss a count or two that will accumulate. Is there a function that can do this automatically?

Comments 3

KushalP on 02/13/2017 - 16:14

Hi mwilk,

Which Galil controller are you using, and how fast is the rotary encoder moving? DMC commands can execute in microseconds, so depending on the speed of your loop, you would read the position (set point) and set the position to zero within microseconds. It would be fast enough such that you would not miss counts. But this also depends on the controller you are running and how you have written the loop.

Another way to do this is to use the controller's output compare feature.

Regards,

Kushal P

mwilk on 02/14/2017 - 08:03

Thanks,

DMC-4183

Encoder will probably be getting counts at about 33 usec at highest resolution and highest speed. It's possible we might get them as quickly as 10 usec, but at that resolution we would have at least 10 counts before we'd notice anything out of tolerance. Even if the error accumulated, we would have manually reset the system and re-zeroed the counts often enough to clear the errors before we'd notice.

If the DMC-4183 can do this in the usec range, I think we will be OK. No other threads will be running.

The loop would be similar to:
// dorun is the flag that is tested to tell when to exit the loop
// trgcount is the trigger/setpoint and will occur approx every 750 msec. Value will be about 500,000
// the section (... do some things) will take 5-10msec
//
// Basically, loop for about 750 msec looking for a setpoint, reset the count, do about 5-10msec of work, and go back to waiting

#RUNLOOP
JP #RUNEXIT, dorun=0
IF (_TDH >= trgcount) // happens about every 750 msec
DEH=0 // reset encoder back to zero
... do some things. // takes about 5-10 msec
ENDIF

JP #RUNLOOP,(dorun<>0) // I can remove the test if that adds too much time
#RUNEXIT

---

Please also verify, for the encoder input I need to use the TDx and DEx commands?

Thanks for the help.

KushalP on 02/15/2017 - 08:40

mwilk,

If you are using a quadrature encoder that is connected to the axis' main encoder input, you would use the TP and DP commands to report and define the positions respectively. If your encoder is connected to an axis' Aux encoder input then you would use the TD and DE commands to report and define the position respectively.

- Kushal P