Author Topic: Rotary encoder counter with serial interface  (Read 2876 times)

0 Members and 1 Guest are viewing this topic.

Offline bastiaangTopic starter

  • Contributor
  • Posts: 13
  • Country: nl
Rotary encoder counter with serial interface
« on: August 15, 2019, 09:06:24 pm »
Well I am back again with a question. I am searching for a rotary encoder counter like the LS7366R (see attachments for the datasheet). I can already hear you say, why don't you choose th LS7366R, well it is not purchasable at the big three (Digikey, Farnell/Avnet, Mouser) for me. Also the counter doesn't have to be bigger than 16 bits. And the serial interface can be anything readable with a microprocessor. I hope you guys can help me ;)
 

Offline KrudyZ

  • Frequent Contributor
  • **
  • Posts: 292
  • Country: us
Re: Rotary encoder counter with serial interface
« Reply #1 on: August 15, 2019, 09:15:39 pm »
I would recommend you use an encoder with quadrature output and add a small MCU or CPLD to do the conversion if you can't do it in the existing MCU.

EDIT: re-reading your post I see that you are looking for just the decoder. This is quite straightforward to do in either an MCU or CPLD and likely cheaper as well.
« Last Edit: August 15, 2019, 09:21:37 pm by KrudyZ »
 

Offline Illusionist

  • Regular Contributor
  • *
  • Posts: 109
  • Country: gb
  • Why is the rum gone?
Re: Rotary encoder counter with serial interface
« Reply #2 on: August 15, 2019, 09:47:05 pm »
How about a dsPIC33EP32MC202? It has a quadrature interface and is cheap enough (possibly, depends if you are talking one-off or production)  to use just for that. It might do the whole job though, whatever that is.
Agilent 34410A, GW Instek 8251A, Thurlby 1905A, Siglent DS1104X-E(unlocked), SDG1032X(unlocked), Micsig DP10013 MX, LeCroy PP008 500MHz Probes, Fluke 179
 

Offline mrjoda

  • Regular Contributor
  • *
  • Posts: 80
  • Country: sk
Re: Rotary encoder counter with serial interface
« Reply #3 on: August 16, 2019, 05:54:36 am »
or STM32L011 (   STM32L011F4U6TR) , almost every STM32 has encoder interface on general purpose timer. And costs nothing.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Rotary encoder counter with serial interface
« Reply #4 on: August 16, 2019, 06:33:41 am »
Or absolutely any MCU on the market, decoding a quadrature encoder is such a common task that you can just grab some code that already does it and port it to any platform you like.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15360
  • Country: fr
Re: Rotary encoder counter with serial interface
« Reply #5 on: August 16, 2019, 01:53:34 pm »
And the serial interface can be anything readable with a microprocessor.

I second what others have said. Use a small MCU to do this.
Just a quick question though, if you're using a "microprocessor" (what is it?), can you not implement the decoding for the rotary encoder right inside of it instead?

If not - small MCU. Any very small one should fit for this sole task. Pick any that can do SPI slave. An embedded quadrature decoding peripheral would really not be necessary here IMO as long as it has timers and interrupts.

Besides, who knows, there may even be a small niche market for this, so you could sell that (and make it a little more versatile while you're at it, like offering UART as well, maybe support a few rotary encoders instead of just one, etc.)
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5408
  • Country: gb
Re: Rotary encoder counter with serial interface
« Reply #6 on: August 16, 2019, 02:44:51 pm »
I agree, use an MCU, particularly for front panel knobs.

I did this with a PIC10F322 some time ago, it provided a simple (software) UART result. This implemented a state machine using change notify interrupt bits.

See posts 14, 22 and 26 here https://www.microchip.com/forums/m933132.aspx

If you want things like SPI or I2C, you might want to consider a device with a couple more pins and hardware serial peripherals. A daisy chained SPI seems like a perfect solution if you have multiple encoders.
 

Offline Illusionist

  • Regular Contributor
  • *
  • Posts: 109
  • Country: gb
  • Why is the rum gone?
Re: Rotary encoder counter with serial interface
« Reply #7 on: August 16, 2019, 09:10:05 pm »
Aye, small PICs are great for little jobs like this.

I just bought a load of 16F18313 because I needed a flexible logic divider, and the PIC was cheaper and smaller than doing it with logic chips. (Propagation delay wasn't an issue in this case.)

The 8-pin 16F18313 is about 5p more expensive that the 10F322 but has an amazing array of peripherals in it, including a EUSART, DAC, ADC, NCO, CLC... I couldn't resist picking up a tube for those 'little' jobs.
« Last Edit: August 16, 2019, 09:11:48 pm by Illusionist »
Agilent 34410A, GW Instek 8251A, Thurlby 1905A, Siglent DS1104X-E(unlocked), SDG1032X(unlocked), Micsig DP10013 MX, LeCroy PP008 500MHz Probes, Fluke 179
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5408
  • Country: gb
Re: Rotary encoder counter with serial interface
« Reply #8 on: August 17, 2019, 07:26:10 am »
I agree that the 18313 (and 15313) are good for this too, as you say the hardware peripherals are better, and the hardware is a lot more flexible: the 10f322 project was there to see if it could be done in a six pin package.
 

Offline ggchab

  • Frequent Contributor
  • **
  • Posts: 281
  • Country: be
Re: Rotary encoder counter with serial interface
« Reply #9 on: August 17, 2019, 08:14:07 am »
I am using a small PIC12F1840 to read the rotary encoder of a hobbyist project. It's configured as an I2C slave device and a dedicated line can trigger an interrupt on the main processor when the encoder is rotated.
 

Offline Haldor

  • Newbie
  • Posts: 6
  • Country: us
Re: Rotary encoder counter with serial interface
« Reply #10 on: October 10, 2022, 06:31:13 pm »
I realize this is an old thread, but I was just researching this exact same subject and thought what I found might prove useful.

The first question you have to answer, is how fast do you need need to be able to handle quadrature input? This is determined by the resolution of the quadrature encoder (# of steps/revolution) and the maximum RPM you need to be able to handle.

For handling low speed input, by all means bit-bang it in software. This method can handle higher speed input, but you may want to dedicate a processor to just the quadrature input processing to ensure you don't lose track of position.

Newer ARM processors typically include a QDAC (Quadrature Counter) input block that you can use as long as the step rate is < 10,000 Hz.  This worked out to a max speed of ~ 1000 RPM at 512 steps per revolution (128 step coding disk in x4 mode) for the processor I am using (nRF52832).

If you have higher speed requirements (like a motorized application), then this can be too slow. The LS7366R-S is a great choice for these kinds of applications. In fact the LS7366R-S is overkill for me since it will operate up to 78kRPM at 512 steps/revolution. The downside to the LS7366R-S is it is a single sourced, special purpose IC and considering how difficult the supply chain has become, I am uncomfortable designing that into a commercial product that will be in production for > 10 years. The IC is not exactly cheap either at $7 each.

I found this app note from Renesas that explains how to implement a quadrature counter function with a SPI port using an inexpensive PLD (Programmable Logic Device). The is about 1/4 the speed of the dedicated LS7366S-R for less than $0.50 each. And the concept is easily implemented in a number of comparable parts from a bunch of IC makers.

https://www.renesas.com/br/en/document/apn/cm-277-quadrature-encoder-counter-spi-bus-interface

The app note design can operate above 20,000 RPM at 512 steps/revolution which is a perfect fit for my application. You do need to program the PLD, but the same would be true for a processor based solution. Programming PLDs is not something than most hobbyist are familiar with, but it is less complicated than writing embedded firmware is.
« Last Edit: October 10, 2022, 06:43:43 pm by Haldor »
 

Offline Infraviolet

  • Super Contributor
  • ***
  • Posts: 1152
  • Country: gb
Re: Rotary encoder counter with serial interface
« Reply #11 on: October 10, 2022, 09:53:40 pm »
Use a microcontroller to read a quadrature (or other) signal from whatever encoder is in use, then have the microcontroller provide the serial inteface using other GPIO pins? Probably cheaper than a dedicated quadrature-counting-to-serial chip, and more choices for much better availability, Literally any microcontroller which fits with whatever programming toolchain you're used to, fits any board space requirements and can kep up with the encoder signals at maximum rotation speed (interrupts help here) will do.

OOPS, this has already been said several times. But in an era of logistics hell and chip crises, it does have the advantage of just how wide a variety of microcontrollers would all be perfectly compatible for use this way.

Another thought, raspberry Pi's Pico (rp2040) chip has a programmable IO option for some GPIO pins, this might be quite quick?
« Last Edit: October 10, 2022, 09:55:58 pm by Infraviolet »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf