Author Topic: Incremental encoder direction signal decoding  (Read 1360 times)

0 Members and 1 Guest are viewing this topic.

Offline AlexReschTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: za
Incremental encoder direction signal decoding
« on: September 04, 2018, 10:06:53 pm »
Too keep it short : what is the easiest way to get a direction signal from an incremental encoder ? I need to control the direction ( and position ) of a small stepper motor and the drive wants pulse and direction. Pulse I can do, direction not.
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1134
  • Country: us
Re: Incremental encoder direction signal decoding
« Reply #1 on: September 04, 2018, 11:25:21 pm »
For a rotary encoder...
 
The following users thanked this post: AlexResch

Offline cncjerry

  • Supporter
  • ****
  • Posts: 1310
Re: Incremental encoder direction signal decoding
« Reply #2 on: September 06, 2018, 01:59:52 am »
if you hook two steppers back to back (without power) you can turn one with the other based on the EMF generated by the one you turn.  Not much torque at all but it is interesting.

Look up quadrature encoding.  This is how you decode encoders with a microprocessor.  The two pulses are offset so that dependng on how the encoder turns, one or the other pulse will lead or lag the other and based on that, you get the direction and step.

So turning one way you'll get a pulse train of ABABABAB as to which leads the other; The other way, BABABABABA.  Remember, that the transition from A to B and from B to A is which leads.  So you really have A, and while A, then B;  The other way, B and while B, then A.  I think they call it quadrature because you can have four states: not A & not b; A; B; A & B.  Most microprocessor libraries have quadrature encoder libraries or code.

Jerry
 

Offline intabits

  • Frequent Contributor
  • **
  • Posts: 334
  • Country: au
Re: Incremental encoder direction signal decoding
« Reply #3 on: September 07, 2018, 02:23:45 pm »
Looking at some old assembler code I did for a servo controller, it's simple in software if you have a microcontroller involved.
On the falling edge of one encoder channel (I used that as in interrupt), look at the other channel. If that's high, it's rotating one way, if low, it's rotating the other way...
(which is what the circuit above does in hardware)
« Last Edit: September 08, 2018, 12:11:31 am by intabits »
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 15360
  • Country: fr
Re: Incremental encoder direction signal decoding
« Reply #4 on: September 07, 2018, 02:38:05 pm »
I have used the principles given here successfully in a few projects: https://tutorial.cytron.io/2012/01/17/quadrature-encoder/
 
The following users thanked this post: AlexResch

Online PA0PBZ

  • Super Contributor
  • ***
  • Posts: 5205
  • Country: nl
Re: Incremental encoder direction signal decoding
« Reply #5 on: September 07, 2018, 02:49:52 pm »
If pulse for the drive would trigger high- or low going you could hook the encoder directly to it, it's not going to be simpler than that.  ;)
Keyboard error: Press F1 to continue.
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1134
  • Country: us
Re: Incremental encoder direction signal decoding
« Reply #6 on: September 07, 2018, 03:25:16 pm »
For a rotary encoder...

If all you want is DIR, you can eliminate the inverters since CLK is buffered internal to the 4013.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf