Rotary encoders - pulses and detents per revolution - Page 1
Forum section: electronics / beginners

author: Peabody
author_rank: Super Contributor
timestamp: November 26, 2017, 04:03:27 am
content: Last year I worked on a project which used a Bourns rotary encoder from the PEC11R series. It had 18 detents per revolution and 18 pulses per revolution. So at each detent both switches are open, and between any two detents both switches go through a full close/open cycle. But I noticed that the data sheet:http://www.bourns.com/docs/Product-Datasheets/PEC11R.pdfsays that this encoder also comes with 12 and 24 pulses per revolution, and either of those can have 12 or 24 detents. So you could have 12 pulses with 24 detents, or 24 pulses with 12 detents.I would like to understand why one would use an encoder where the pulses and detents don't match. I can see that having fewer pulses than detents would still allow the full number of effective pulses since you could just process each half-pulse as an increment or decrement, with perhaps some additional complexity in the software. But I'm having trouble understanding why you would use one of those in preference to a 12/12 or 24/24. And I'm particularly puzzled by the idea of having more full pulses than detents - two full pulses per detent.I assume Bourns wouldn't offer these non-matching options if there were no use for them, but could someone explain what use cases there would be for them?

author: Cliff Matthews
author_rank: Unknown
timestamp: November 29, 2017, 12:07:55 am
content: Surprised no one answeredbut I'd submit having more pulses than detents could aid software detection of velocity. For Arduino newbies, it might be useful to have a real answer (not mine..) so others avoid buying the wrong encoders on eBay for example.

author: Nusa
author_rank: Super Contributor
timestamp: November 29, 2017, 12:17:46 am
content: Unless you've found distributors that actually stock the variations you see no use for, it's probably an academic question.From the manufacturing datasheet point of view, it doesn't cost them anything to offer all combinations of existing parts, just in case someone does have a reason to order them that way.

author: rstofer
author_rank: Super Contributor
timestamp: November 29, 2017, 01:06:51 am
content: It also depends on your definition of a 'pulse'. If I look only at the 'A' signal, there is one pulse per detent and that pulse consists of a rising and a falling edge. Maybe I only actually look at the rising edge or maybe I only look at the level. One pulse per detent using the level definition.I could count rising and falling edges and get 2 counts per detent. But I can't tell direction! So, they add a second channel, 'B', and now I can count 4 edges to get 4 counts per detent and I can determine the direction with a simple state machine. But I don't have to keep all 4 counts, I just need the quadrature relationship of the edges to determine direction.I guess the manufacturer does something to the switch contacts inside the encoder to provide less, equal or more pulses per detent. For my purposes, I want all 4 edges between each detent.

author: bson
author_rank: Unknown
timestamp: November 29, 2017, 04:58:05 am
content: Not all logic or microcontrollers can clock/interrupt on both edges. Although discrete logic would be for legacy support, it could still be a significant market.

author: rstofer
author_rank: Super Contributor
timestamp: November 29, 2017, 05:55:24 am
content: Quote from: bson on November 29, 2017, 04:58:05 amI suppose, somewhere, there might be a uC that can't keep up but most of the ones I use have 'interrupt on change' for the GPIO pins. Polling could be a problem on any uC depending on how the super loop is coded.Just to put a number out there, assume 2 revolutions per second, 18 detents per revolution and 4 edge transitions per detent - 144 interrupts per second. That's not a lot. Of course, that is for human interaction. At 1000 RPM on a detentless encoder (driven by a motor), we'd be looking at 1200 interrupts per second. Still not a lot for most uCs.The trick is to get in and out of the interrupt routine as fast as possible.

author: Peabody
author_rank: Super Contributor
timestamp: November 29, 2017, 06:09:17 am
content: Thanks for the responses. I've basically concluded that for new designs all you would ever use is an encoder with the same number of pulses as detents - a pulse being one complete close/open cycle of both switches.If you have 12 pulses and 24 detents, then every other detent will leave both switches closed, which will have them drawing current through the pullup resistors for what may be long periods of time. Moreover, after handling, say, the falling edge to get one increment/decrement, you would then have to switch over to looking for the rising edge to get the next one. I don't see any benefit to offset these disadvantages.For matched pulses/detents, you only have to look for one type of edge. Moreover, at each detent both switches are always open, and not drawing current. I don't see any disadvantage to going this way.The other option - 24 pulses and 12 detents - is what Nusa said, which is basically an imaginary product until someone actually orders one.The only thing I've found that complicates deaing with these encoders is switch bouncing, and even that issue goes away if you poll the state of the switches periodically instead of triggering interrupts on rising or falling edges. In fact, the polling logic is really simple, and foolproof, even without any hardware or software debouncing.

author: Peabody
author_rank: Super Contributor
timestamp: November 29, 2017, 06:18:41 am
content: I should add that my polling experience with these is in assembler for the TI MSP430 processors. Basically, everything the processor does occurs at periodic interrupts (512 per second), so polling the switches is just another thing to do on each interrupt. The processor sleeps between interrupts. I don't know how well polling would work in a C-like Arduino sketch.