Rotary Encoder

Thread Starter

Dritech

Joined Sep 21, 2011
901
Hi all,

I am going to use a rotary encoder (20 pulses per revolution) which will be connected to a leadscrew. I will then use a microcontroller to monitor the pulses and hence knowing the linear position.
Since the leadscrew is 1m long with a 1cm pitch, that means the encoder will produce 20000 for the full length.
What is the best method for storing and monitoring these pulses in the MCU please?
 

strantor

Joined Oct 3, 2010
6,782
Hi all,

I am going to use a rotary encoder (20 pulses per revolution) which will be connected to a leadscrew. I will then use a microcontroller to monitor the pulses and hence knowing the linear position.
Since the leadscrew is 1m long with a 1cm pitch, that means the encoder will produce 20000 for the full length.
What is the best method for storing and monitoring these pulses in the MCU please?
Without further input, it won't know the linear position. It will only know how many pulses have occurred since it was turned on. In order to know actual position on power up, you will need an absolute linear positioning device like a glass scale. You can make the encoder work if you provide another input, such as a proximity switch or limit switch for "home" position; this resets the count to zero. As long as power is maintained, it will keep track of it's position. This should be a quadrature encoder, so that you can add and subtract from the position value, otherwise travel in either direction will add to the value.

There are cost-effective ready-made solutions for this application; are you interested in exploring them, or are you dead-set on rolling your own?
 

alfacliff

Joined Dec 13, 2013
2,458
yoju could also make a "home" switch. on one end of the lead screw travel, placde an accurate limit switch, and move the position there. then you will have a reference or zero position.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
If the travel is relatively slow then you could use a CCP module with T1 capture.
Double the resolution by rising/falling edge capture.
If you want to record direction then you will have to keep track of the dir pulse of the quadrature signals?
Max.
 

GetDeviceInfo

Joined Jun 7, 2009
2,192
Hi all,

I am going to use a rotary encoder (20 pulses per revolution) which will be connected to a leadscrew. I will then use a microcontroller to monitor the pulses and hence knowing the linear position.
Since the leadscrew is 1m long with a 1cm pitch, that means the encoder will produce 20000 for the full length.
What is the best method for storing and monitoring these pulses in the MCU please?
16 bit counter, and compare, check your mcu specs.
 
It's typical to have a high limit, low limit and ORG sensor. So, low may me found and then the direction reversed and the speed reduced until ORG is found. That is the real zero.
 

GopherT

Joined Nov 23, 2012
8,009
Hi,

Thanks for the replies. I bought the rotary encoders in the link below:

http://www.ebay.co.uk/itm/390595474...eName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

Apparently these encoders produce pulses using a mechanical switch instead of optical sensors. Can this cause debounce problems?
Debounce is not a problem if you know the gray-code output sequence. Confirm the code position in software and wait for a change in state from the encoder and confirm the new position based on the next gray-scale state expected. You can determine which direction the encoder is turned as well.
 

BillB3857

Joined Feb 28, 2009
2,570
2 bit gray code made me go look it up since I had never heard of it. Turns out to be the same a what I've always known as quadrature output. Gray code, as I learned it, requires that no two bits change state at the same time. Quadrature output meets that requirement.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
2 bit gray code made me go look it up since I had never heard of it. Turns out to be the same a what I've always known as quadrature output. Gray code, as I learned it, requires that no two bits change state at the same time. Quadrature output meets that requirement.
Your right to a degree, I had to refresh my memory as I had never used 2 bit gray before, but the only difference appears to be the gray code although one pulse shifted from the other, does not remain at 90° as does quadrature.
Max.
 

BillB3857

Joined Feb 28, 2009
2,570
So, if I understand correctly, Max, a true quadrature will have a precise 90 degree displacement where the 2 bit gray code may or may not be exactly 90 degrees.
For the OP's application, it may be close enough, especially since high speed probably won't come in to play.

Now to digress a little.
When I was dealing with phase analog servo systems, the 90 degree phase relationship driving resolvers was so important that they didn't depend upon digital displacement prior to converting to sine waves, but analog techniques that provide full adjustment of relative amplitude and phase control.

Rotary encoders, on the other hand, were expected to provide near perfect 90 degree displacement between outputs. We had one machine made by Hughes that had adjustable photo detectors built into the encoders. We put the encoder on a fixture to spin it and monitored outputs with a scope using ADD channel function. By rotating the photocell holder, we could get very close to perfect displacement . Really gotta love 50+ year old tech.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
Yes, quadrature = 90° separation.
I recall doing the alignment in some of the first linear scales made by Farrand that used incandescent lamps and they had to be realigned to 90° using a scope via the Lissajous figure method to get the exact displacement.
Modern usage of the relatively low resolution Resolver uses the Arc-Tangent absolute calculation in order to get a finer resolution.
Max.
 

BillB3857

Joined Feb 28, 2009
2,570
The systems I worked with used sin/cos excitation. When setting sin/cos/amplitudes/phase, the Lissajous figure would get us in the ball park. Then we would move the machine slowly while observing the feedback and observing bounce. When the amplitudes matched and the phase was exactly 90 degrees, the bouncing would stop and we would only see the shifting phase when triggering on a fixed reference such as the sin signal.
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
The Literature that Farrand supplied also went into detail on how the 1k pulses/inch were obtained or created using the Moiré effect, which otherwise would be unobtainable using optical transmission through a grating, which is used to this day.
Max.
 

BillB3857

Joined Feb 28, 2009
2,570
Talking about Farrand, we used the brushless rotary inductosyn on several of our machines. In one instance we could not get the sin/cos drive signals to set up to eliminate the bounce in the output signal. A call to Farrand tech support was made for help. The tech asked how we were using the scale and when we said we were exciting the stator with sin and cos, he said, "you mean it will actually work that way?" That took me by surprise since all of our machines that had inductosyns,either linear or rotary used the sin/cos excitation with sinusoidal phase shifting feedback.

For a trip down memory lane, look at this pdf......
 

Attachments

MaxHeadRoom

Joined Jul 18, 2013
28,619
The machines I mentioned also had the similar linear Farand scales in conjunction with a LVDT to measure machine 'growth' as they increased in temperature, this value was added to the measuring scale.
A bit OTT for a Loco car wheel borer. :rolleyes:
Max.
 

BillB3857

Joined Feb 28, 2009
2,570
Max, I think we could go on and on about or similar industrial experiences, but that is going very far off topic. I'll monitor for any more on topic chatter.
 
Top