PDA

View Full Version : Using an incremental rotary encoder?



keithv
- 12th January 2016, 20:21
I've never used one of these devices before. It has a resolution of 12 ppr. Please give me some advice on how to use the encoder. What command statement works best for reading the pulses? I'm guessing PULSIN How does the PIC recognize whether the encoder is turning clockwise or counter clockwise?

keithv
- 12th January 2016, 20:28
I did some research and I now understand that phase A sends a pulse when turned clockwise and phase B sends a pulse when turn counter clockwise. 12ppr? Does that mean 12 pulses for each detent, or an entire rotation?

grahamg
- 12th January 2016, 20:33
ppr=pulses per rotation.

HenrikOlsson
- 12th January 2016, 21:07
did some research and I now understand that phase A sends a pulse when turned clockwise and phase B sends a pulse when turn counter clockwise
That really depends on the encoder. Most I've seen (if we're talking about the ones used to replace a pot and knob) are quadrature output and even those come in different flavours. Some have one detent per qudrature cycle, some have four detents per qudrature cycle and some doesn't have any detents.

Here's an example I already had in my attachments on the forum. This specific encoder has a full cycle per detent.

8149

/Henrik.

keithv
- 12th January 2016, 21:07
I think I've got it now. I'm not really using a command statement like PULSIN. I'm simply checking the state of the two pins connected to the encoder and I can use the XOR operator to interpret the Gray code as moving CW or CCW. Does that sound about right?

richard
- 12th January 2016, 22:23
its never that simple

http://www.picbasic.co.uk/forum/showthread.php?t=20785