Rotary Encoder

Discussion in 'General Electronics Chat' started by Dritech, Mar 10, 2014.

  1. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    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?
     
  2. strantor

    AAC Fanatic!

    Oct 3, 2010
    4,302
    1,988
    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?
     
  3. alfacliff

    Well-Known Member

    Dec 13, 2013
    2,449
    428
    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.
     
  4. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,503
    2,366
    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.
     
  5. Bernard

    AAC Fanatic!

    Aug 7, 2008
    4,170
    395
    Do you mean a 1 mm pitch? 1 cm is pretty agressive.
     
  6. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,503
    2,366
    High lead ball screws can go up to 2.5cm pitch.
    .5 to .625cm would be considered around normal.
    Max.
     
    Bernard likes this.
  7. GetDeviceInfo

    Senior Member

    Jun 7, 2009
    1,571
    230
    16 bit counter, and compare, check your mcu specs.
     
  8. KeepItSimpleStupid

    Well-Known Member

    Mar 4, 2014
    1,135
    200
    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.
     
  9. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
  10. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,503
    2,366
    Outputs a 2 bit gray code evidently, I don't see this as the best choice.
    A quadrature encoder may have been a better one.
    Max.
     
  11. GopherT

    AAC Fanatic!

    Nov 23, 2012
    5,984
    3,719
    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.
     
  12. BillB3857

    Senior Member

    Feb 28, 2009
    2,400
    348
    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.
     
  13. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,503
    2,366
    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.
     
  14. BillB3857

    Senior Member

    Feb 28, 2009
    2,400
    348
    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.
     
  15. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,503
    2,366
    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.
     
  16. BillB3857

    Senior Member

    Feb 28, 2009
    2,400
    348
    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.
     
  17. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,503
    2,366
    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.
     
  18. BillB3857

    Senior Member

    Feb 28, 2009
    2,400
    348
    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......
     
  19. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,503
    2,366
    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.
     
  20. BillB3857

    Senior Member

    Feb 28, 2009
    2,400
    348
    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.
     
Loading...