Rotary decoder chip

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
georduino
 
Posts: 3
Joined: Fri Oct 04, 2013 1:16 pm

Rotary decoder chip

Post by georduino »

Hi,
I have been using an Arduino Uno with the Adafruit Motor shield to control a DC servo motor. This package works great for controlling the motor, but I am having a hard time reading the encoder of the motor at high speeds. At full speed the encoder can output 100K counts per sec which according to my understanding from reading several posts on this and other forums is beyond the capabilities of arduino. I was wondering if there is a hardware solution to this problem i.e. a rotary decoder chip that is supported by adafruit or is easy enough for a beginner like me to interface with arduino

Thank you!

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Rotary decoder chip

Post by adafruit_support_mike »

Hmm.. what kind of encoder are you using?

Reading the feedback from our analog-feedback servos (http://www.adafruit.com/products/1404) does have some limits on the number of samples you can read per second.. the built-in ADC normally runs at about 10kHz, which only allows you to sample repeating signals below 5kHz accurately. You can get up to a few hundred thousand samples per second if you're willing to live with less than the full 10 bits of accuracy though.

OTOH, when you say your encoder can put out 100k signals per second, that sounds like a digital device. It isn't exactly easy for an 8MHz processor to handle an 8kHz signal and do other things as well, but it's possible.

georduino
 
Posts: 3
Joined: Fri Oct 04, 2013 1:16 pm

Re: Rotary decoder chip

Post by georduino »

Hi Mike,

Thank you for your reply. the motor that I am trying to control is this: http://www.thorlabs.com/thorcat/17600/Z812-Manual.pdf

My understanding is that the encoder is a digital device that will output about 90K counts/sec per channel at full speed. I think that the clock speed of the Arduino Uno we have is at 16 MHz.

Thank you!

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Rotary decoder chip

Post by adafruit_support_mike »

The product isn't one of ours, and the datasheet doesn't completely characterize the encoders, so take this as an educated guess:

The datasheet shows two encoder channels and mentions a Hall effect sensor, so I'm going to assume the signals are digital and run in quadrature.. signal A goes HIGH before signal B if the shaft is rotating clockwise, B arrives before A if the shaft is rotating counterclockwise. That's a standard motor sensing approach.

If those guesses are correct, you don't need to use the ADC at all. You just need to count digital pulses coming from the A and B lines, and 90kHz won't push the limits of an 8MHz or 16MHz microcontroller.

The usual solution would be to set up interrupts for two pins so they can sense when the A and B lines go HIGH or LOW. Each pin's interrupt handler would find the state of the signal it observes, then store that information to a global variable you can use in the rest of your code.

The motor's direction and speed can be derived from the quadrature signal, and from those you can calcualate displacement from an originally recorded position. The details of how much work to do in the interrupt handlers and how much to do in the main code will depend on the requirements of your application in general.

georduino
 
Posts: 3
Joined: Fri Oct 04, 2013 1:16 pm

Re: Rotary decoder chip

Post by georduino »

Thank you Mike!

I will give it a try!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”