Stepper motor control: Quadrature Enc. to step & Direction

Thread Starter

qtron

Joined Aug 1, 2018
74
Am new to forum, couldnt find the right subject thread for my subject!
I wish to convert a quadrature encoder output to step & direction..
So 5 volt powered optical encoder with quadrature out (& an index pulse), to be converted to step & direction using simple cmos logic IC's.
i tripped over a schematic - well I thought it was, but turned out to be part of a PSoC, whatever that is.
here is the link, https://www.hackster.io/juanespj/quadrature-decoding-with-logic-gates-no-udbs-tcpwms-used-0c3859
Being undeterred I breadboarded the cct with 4000 series logic.
I couldnt find a Set/reset FF that didnt have a D input, so i built one using a quad, 2 input Nand gate, with a 4011B
( pls see http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/SRFFclock.html )
It's not normal step & direction! It also loses pulse in deciding direction..
Here is the reply upon asking the intended purpose of the setup:
"This circuit is made to read a quadrature encoder to detect rotational direction. And number of counts, it is not a cmos implementation, it is built with digital blocks on PSoC device"

i also looked at: https://www.allaboutcircuits.com/worksheets/flip-flop-circuits, was unclear to me from the logic offered as to which is correct.
Surely there must be a simple schematic that can do this, that MUST not lose a single step. - i cant be Robinson Crusoe here!
It must decide direction before 1 complete quadrature cycle too.
The output 'speed' , or RPM of the encoder is not going to be so hi as to cause propagation delays to need consideration ;-)
[I also considered http://www.learnabout-electronics.org/Digital/dig53.php ]
There is a commercial IC device avail, but buying it is becoming elusive, & it aint cheap (compared to CMOS).
Thanks HEAPS!
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
Do you intend to use the signals and circuit to drive the stepper directly or input into a step/dir drive?
The difference is that driving directly you need use both Enc. quadrature signals the way they are, or at least amplified, if using a drive or other such method then the dir. signal requires to stay either 0 or 1 depending on direction.
A little more explanation of what you want to do would not hurt.
What is the resolution of the encoder?
Max.
 

danadak

Joined Mar 10, 2018
4,057
The PSOC has a multitude of components on its chip, a component being
an onchip resource. If you are generating stepper signals with PWMs the
PSOC can handle that as well as Quadec and other stuff like COM, LCD,
random logic, counters, timers, analog....

You can start with a $4 board on the low end, PSOC 4, highend board $ 10,
PSOC 5LP.

Regards, Dana.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Do you intend to use the signals and circuit to drive the stepper directly or input into a step/dir drive?
The difference is that driving directly you need use both Enc. quadrature signals the way they are, or at least amplified, if using a drive or other such method then the dir. signal requires to stay either 0 or 1 depending on direction.
A little more explanation of what you want to do would not hurt.
What is the resolution of the encoder?
Max.
Thanks for fast response - yes will use a newly built (FET) stepper drive - just built one, full steps only, at this stage.
needs step & dir input.
...
VERY interesting that U should mention direct drive, amplified- I used an old chip, crappy darlington L298 stepper driver board, bought from Jaycar.com.au. [i had to provide some logic to invert signals for the four inputs on this board].
Unfortunately, after a LOT of time invested, the motor lost torque, even at quite slow speeds, despite trying to meet ALL the usual requirements for stepper driving. The interesting bit is that where the quadrature outputs overlap, ie when both signals are hi, that provides half stepping :)
see: https://www.jaycar.com.au/arduino-compatible-stepper-motor-controller-module/p/XC4492
..
I have set the encoder at a very low res, 128 ppr, according to CUI
see https://www.digikey.com/product-detail/en/cui-inc/AMT102-V/102-1307-ND/827015
its actually capacitive. [Their datasheet ppr table, & their view on interpreting ppr conflicts.. its actually only a low cost 500 line encoder!!]
the basic objective is to have a stepper follow precisely the encoders rotation, or at least at a suitable ratio.
if the encoder is set to 256 ppr, & the stepper is 200 steps per rev, then that ratio would be somewhere near the required amount, me thinks. But to be determined at a later date. - some sort of digital "gearbox" may be required, together with the right pulley ratios to get it all to work as required.
its a "follow me'' idea.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
The PSOC has a multitude of components on its chip, a component being
an onchip resource. If you are generating stepper signals with PWMs the
PSOC can handle that as well as Quadec and other stuff like COM, LCD,
random logic, counters, timers, analog....

You can start with a $4 board on the low end, PSOC 4, highend board $ 10,
PSOC 5LP.

Regards, Dana.
thanks,
but want to use basic logic at this point. Cant program code, amoung other issues!
 

MaxHeadRoom

Joined Jul 18, 2013
28,619
Interestingly a stepper motor can be used to drive an identical one direct, as in the original servo system!
One problem as you may know, using the rated volt/amp rating of the motor, it does not take many rpm's before you run out of torque.
An old method was to use a higher voltage supply with a series resistor for automatic compensation, now usually a higher P.S. voltage and PWM control is used in order to overcome this.
Max.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Interestingly a stepper motor can be used to drive an identical one direct, as in the original servo system!
One problem as you may know, using the rated volt/amp rating of the motor, it does not take many rpm's before you run out of torque.
An old method was to use a higher voltage supply with a series resistor for automatic compensation, now usually a higher P.S. voltage and PWM control is used in order to overcome this.
Max.
yes, my first test. & yes, i tried that trick too :)
anyway, any ideas?
 

ebp

Joined Feb 8, 2018
2,332
from the Hyperphysics link:
"Likewise, a clock pulse must have the reset NAND gate high to receive a high RESET pulse. Therefore all transitions are synchronized to the clock."

This is complete nonsense. As long as the clock is high, the state can be changed immediately by the R and S inputs.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
from the Hyperphysics link:
"Likewise, a clock pulse must have the reset NAND gate high to receive a high RESET pulse. Therefore all transitions are synchronized to the clock."

This is complete nonsense. As long as the clock is high, the state can be changed immediately by the R and S inputs.
Oh! thanks Mr ebp! funny how one can rely on those that "know more" only to be led astray.
I actually didnt absorb the text at all, just built the cct.
 

jbeng

Joined Sep 10, 2006
84
What you're looking for here is a phase detector. Here's a diagram of one we used years ago which doesn't have the NAND gate. See if this one works any better than the one you're using now. (no promises, though)

Phase_Det.jpg
 

Thread Starter

qtron

Joined Aug 1, 2018
74
What you're looking for here is a phase detector. Here's a diagram of one we used years ago which doesn't have the NAND gate. See if this one works any better than the one you're using now. (no promises, though)

View attachment 157379
Thankyou jbeng, U seem to have beaten others to the punch!
Wonderful! I assume the o/p doesn't change state until theres a change of phasing at the input..
The thing that puzzles me with these logic setups is, dreaming up the solutions! I cant.
- Is it out of a book of ingenious solutions, is it taught as part of a list of basic logic 'mechanisms' or..?
 
Search for "rotary" here: https://www.elmelectronics.com/products/dsheets/ This isn't in the US.

Yep, shipping can be a bear. Cost's close to $20.00 USD which I think is close to AUD. to ship anything small outside the US from the US, The Chinese subsidizes postage, so China to US can cost zero. e.g, ebay or Aliexpress Now there's tariffs to deal with.

But a DHL tracked package: $50.00 USD for a LED LAMP and external DImmer and $50.00 to ship from China is steep.

I have a friend in OZ and yes, shipping is a pain.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Search for "rotary" here: https://www.elmelectronics.com/products/dsheets/ This isn't in the US.

Yep, shipping can be a bear. Cost's close to $20.00 USD which I think is close to AUD. to ship anything small outside the US from the US, The Chinese subsidizes postage, so China to US can cost zero. e.g, ebay or Aliexpress Now there's tariffs to deal with.

But a DHL tracked package: $50.00 USD for a LED LAMP and external DImmer and $50.00 to ship from China is steep.

I have a friend in OZ and yes, shipping is a pain.
Oz post = thieves too. Big shot at top fleece us.
$20.00 usd = 20/0.71 aud
Maybe I can send $$ to u, u buy 7184, post to me, ordinary snail mail. But cant pay $ 25 usd postage for 1 chip. Despite wonderfully simple solutions supplied by Crutschow, I really like the digital 'gearbox' built into the 7184.. but need to prove the animal first.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Sorry to say answer by schematic supplied by Crutschow is too cheap!
It gives the direction before first step in one direction, but the other direction step occurs before Direction status.
so 1 step in wrong direction, changing to the other encoder phase output for the step signal simply reverses the problem...
will now try Mr. JBeng 2 FF 4013 solution:)
 
Wow! The last time I checked, it was around $20.00 USD to mail something. Now it's $35.25 USD to mail stuff. I was going to mail some obsolete OP amps I had to someone in the UK and he balked that, at the time postage was <$20.00 USD. This is a significant increase.

eek!!!
 
Top