Using an incremental rotary encoder?
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?
Re: Using an incremental rotary encoder?
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?
Re: Using an incremental rotary encoder?
1 Attachment(s)
Re: Using an incremental rotary encoder?
Quote:
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.
Attachment 8149
/Henrik.
Re: Using an incremental rotary encoder?
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?
Re: Using an incremental rotary encoder?