Stepper motor control: Quadrature Enc. to step & Direction

Thread Starter

qtron

Joined Aug 1, 2018
74
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!!!
Tell US post u'll email it instead. Need that matter translator machine. Bah. More theft.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Tried Mr. JBeng 2 FF 4013 solution just now.
if the right pins for Dir & step are used then positive going edges of step occur at same time as state chage for dir.
So, a delay was used for step signal, the direction state will change B4 the next step!
just gotta make dely sort enuf for max encoder rpm..:):)
THANKYOU Mr JBeng.,and to all who r willing to spend time helping others
 

Attachments

Thread Starter

qtron

Joined Aug 1, 2018
74
oops - meant to say,lower trace is Dir. upper, ch1, is step.
Pin9/3 is Ch1, D / clk,
Pin 1 is Ch2, Q, 4013 ff pair.
One can see timing of edges.
Putting Ch 2 on the other Q , pin 13 causes step/dir inconsistencies.
( Or moving Ch1 to pin 5/11 same problem).
 

crutschow

Joined Mar 14, 2008
34,464
After looking at my circuit I realized that the output clock signal should be selected from the FF D input signal, not the FF clock input, ( as below) to avoid the clock and the direction signal changing at the same time.

upload_2018-8-2_9-15-46.png
 
Last edited:

ebp

Joined Feb 8, 2018
2,332
Try looking for specialty parts in the UK. Royal Mail small packet rates were still quite reasonable the last time I had anything sent by mail.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
ok, thanks crutschow.
the problem wasnt changing at same time, but rather, clock (step) occurred B4 the direction signal.
Stepper motor drive must receive the change of state of the Dir signal B4 the next step occurs.
my app cant afford to lose steps or add steps to the wrong direction.
But maybe speaking too soon will try yours again, & again, thankyou 4 your time:)
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Oh well, thanks anyway.
A general Q I asked previously:
Are these types of simpler logic Ccts, avail in a cookbook, taught as part of logic cctry in tech schools ?
I cant dream up logic, hopeless at that.
Apart from good people on forums, how does one find solutions..
EG new problem: logic delay line of ~2 usec for the step pulse?
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Sams used to put out a line of fairly decent manuals such as the TTL Cookbook, Opamps etc.
One cheap source of books is Abe Books Clearing house.
Max.
Ah yes name rings a bell, think I was told that in 1978, RAAF. Radio school!
Thanks MHR. Love that handle
 

crutschow

Joined Mar 14, 2008
34,464
Apart from good people on forums, how does one find solutions.
I look at the sequence of signals required and then, knowing what the various logic elements do, gin up a circuit to perform the desired function.

Often I have to modify the circuit several times to get the proper output based upon the simulations I do using LTspice.
Simulation is a great timesaver in ending up with a correct design and I wouldn't attempt the design without it.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
I used to use multisim, old crap. Puzzled tho.. if it Sims correctly, as it should, why the modifications?
I built a 3 octave hi pass op-amp audio filter, printed the Sim graph, the real world graph almost identical. couldn't design without it, (& basic formulae).
But filters are built to benchmarked configurations. Logic seems 'random'!
 

crutschow

Joined Mar 14, 2008
34,464
Another take on a FF circuit.
This uses three FFs (two packages) and a NAND gate (package) to suppress the clock pulses when the quadrature signal changes direction.
Is that sufficient for your requirements?

upload_2018-8-2_19-16-2.png
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Problem is, if the encoder moves at all, 1 change of state, either A or B output, then the stepper motor must follow, so suppression would cause an aberation.
Sorry! Certainly appreciate your input.
 

crutschow

Joined Mar 14, 2008
34,464
After some further thought I believe what you want requires a state machine or a microprocessor.
This is because there are four different states that the quadrature signal can be when it is reversed, and each requires specific logic to generate the proper direction signal and clock pulse on the very next step.

I may be wrong, but that's how I see it. :(

If you could modify the stepper driver to directly drive the motor from the quadrature signal, that might be easier.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Funny u should say that, the driver I am using, I discovered late last night, kit I just built, converts incoming step & direction to quadrature!! Couldn't believe what I saw on the DSO.
So, have some meditation to do
 

Thread Starter

qtron

Joined Aug 1, 2018
74
yes you are right crutschow, re what u said earlier, an MCU probably required to decode. "Stepperature" use one, MSP430, so must be warranted.
["Stepperature" no longer manufactured, but now open source on Github, a cute little board the allows a cheap stepper to be used as an Manual Pulse Generator, in CNC control - instead of encoders]

After some tests, driving the motor with the new FET bridge kit, & quadrature output from the encoder, via 74HC74 to provide the necessary 4 outputs to the bridge, (A, A mirrored B, B mirrored), it did seem to work ok..ish

Certainly a lot better than earlier attempts with the L298 darlignton bridge where motor rotation would abruptly stop at only a few rpm.

i had Said ''Couldn't believe what I saw on the DSO'', because, when I had originally used
the ST Microelectronics chip, L298 , the experiment failed with same signals in (from 74HC74).
(i had expected a lower mark to space ratio or something,, anything!! to explain the drastically improved difference with the new FET bridge kit.
-> Kit is very basic, not even source current sensing, no coil resetting, nothing fancy at all.

So - now motor follows encoder exactly! & no conversion needed to step & direction :):)

Now i need to solve other issues like current fold back at very low rpm, or when stationary, with instantaneous revert to full power mode with sudden encoder rotation.. the challenge continues.
Again, appreciate your input.
I am going to have to get my head around using LTspice for sure.
 

ebp

Joined Feb 8, 2018
2,332
The circuit requires a four-state asynchronous machine. You can find lots of state diagrams on the web, though I haven't looked at any of them in detail. Lots of stuff on the web is wrong (Gasp! :eek:) - as we saw earlier.

Every change of level of either input must generate a clock for the state machine, however because that clock looks at the levels of the quad' inputs, it is typically necessary to delay the clock slightly to meet the setup time requirement for the state machine flip flops. If the the quad' signals are not clean with adequate slew rate, they must be cleaned up.

[EDIT - Sorry, I conflated a machine that produces separate UP and DOWN clocks with one which produces one clock and a direction signal - but the basic notion of what must happen in terms gen'ing the clock & dir are the same.
Where many attempts go wrong is in dealing properly with a reversal that changes the level of only one of the inputs. If the encoder is rotating CW, changes the level of (say) the A output, an UP output clock must be generated (assuming CW is UP) after setting (or not changing) the DIRECTION signal. If the direction of rotation is then changed so that A goes back to its earlier level, the state of the DIRECTION output must change and a DOWN output clock be generated - which is all covered in the state diagram. This can all happen in a small fraction of a degree of rotation, even for an ultra-low resolution encoder. I know of a case where decoding was done in firmware and was in use for years before anyone realized the code was wrong. Fortunately it was on a machine where rotation was continuous in one direction when the encoder output was necessary.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
referring to https://forum.allaboutcircuits.com/threads/stepper-motor-speed.93961/
i am now puzzled:
"The R_B" posted, Feb2, 2014, that "Vish2207" schematic & nicely presented waveforms supplied, top of the page, constitute a full step drive..
"You have built a full-step motor driver which causes a massive amount of resonance, so at some speeds the motor will stall."
how so? - Isn't the A & B signal overlapped constitute turning on of both coils thereby providing the 1/2 step?
 
Top