Stepper motor control: Quadrature Enc. to step & Direction

Thread Starter

qtron

Joined Aug 1, 2018
74
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.
wow! complicated! dunno what a four-state asynchronous machine is, sorry.
but i think..hard.. that i get your drift. Not sure how cluey the Stepperature board is. Gunna test it to the max.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
are U able to help out with this, posted page 2,

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 area constitute turning on of both coils thereby providing the 1/2 step?
 

crutschow

Joined Mar 14, 2008
34,459
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..
If you want to save power and eliminate any power resistors, you could use a PWM circuit that initially applies full power to the motor and then reverts to PWM at a lower duty-cycle to minimize the holding current/power.
Here's a 555 circuit that does that.

I show just one MOSFET driving the motor, which would be part of the bridge (only one transistor per phase needs to be PWM'd at a time).
The 555 circuit can be common but each phase will require its own R2, C3, D4, and U3, U4, and U5 Schmitt-trigger gates.
(Note that for a MOSFET bridge the diode across the motor is not needed, since that function is typically provided by the MOSFET's substrate diode.)

The initial full-on time is determined by the R2C3 time-constant and can be adjusted to your motors inductance value (how long it takes the motor to reach full current, as shown by the red trace) and mechanical step response time.

The PWM frequency is determined by the value of C2 with the value shown giving a frequency of about 1.3kHz.
If that proves too noisy, you can change the value of C2 as desired.

The PWW duty-cycle is controlled by pot U2 and can be adjusted to give the desired motor hold current (shown adjusted for about a 40% duty-cycle [bottom trace], giving a hold current of 40% of the maximum).
The duty-cycle adjustment range is from near 0% to near 100%.

Edit: Corrected D4 Schematic Error
upload_2018-8-3_22-39-22.png
 

Attachments

Last edited:

Thread Starter

qtron

Joined Aug 1, 2018
74
If you want to save power and eliminate any power resistors, you could use a PWM circuit that initially applies full power to the motor and then reverts to PWM at a lower duty-cycle to minimize the holding current/power.
Here's a 555 circuit that does that.

I show just one MOSFET driving the motor, which would be part of the bridge (only one transistor per phase needs to be PWM'd at a time).
The 555 circuit can be common but each phase will require its own R2, C3, D4, and U3, U4, and U5 Schmitt-trigger gates.
(Note that for a MOSFET bridge the diode across the motor is not needed, since that function is typically provided by the MOSFET's substrate diode.)

The initial full-on time is determined by the R2C3 time-constant and can be adjusted to your motors inductance value (how long it takes the motor to reach full current, as shown by the red trace) and mechanical step response time.

The PWM frequency is determined by the value of C2 with the value shown giving a frequency of about 1.3kHz.
If that proves too noisy, you can change the value of C2 as desired.

The PWW duty-cycle is controlled by pot U2 and can be adjusted to give the desired motor hold current (shown adjusted for about a 40% duty-cycle [bottom trace], giving a hold current of 40% of the maximum).
The duty-cycle adjustment range is from near 0% to near 100%.

View attachment 157502
Again, thankyou..
re:
(Note that for a MOSFET bridge the diode across the motor is not needed, since that function is typically provided by the MOSFET's substrate diode.),
oh oops i went & bought expensive fast bead diodes qty 8x, to put across bridge fets, cos i was of the (wrong?) opinion that the substrate diodes are too slow!
 

crutschow

Joined Mar 14, 2008
34,459
i was of the (wrong?) opinion that the substrate diodes are too slow!
All diodes turn on fast (which is what's important for inductive transient suppression).
Fast diodes just turn off faster (have faster recovery time) but that has no effect on the transient suppression effectiveness.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Bah! i been misled for years on that one.. cheers:)
are U able to comment on this, please?
are U able to help out with this, posted page 2,

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 area constitute turning on of both coils thereby providing the 1/2 step?
 

crutschow

Joined Mar 14, 2008
34,459
"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 area constitute turning on of both coils thereby providing the 1/2 step?
Perhaps its how you define a "step".
But for your application I don't think that resonance at speed will be a problem.
What is your maximum speed?
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Perhaps its how you define a "step".
But for your application I don't think that resonance at speed will be a problem.
What is your maximum speed?
Unsure as whole concept at baby stage, probably 500 rpm..

The thing is, if first part of A o/p of encoder causes a step (ie, where B overlap hasn't happened yet), on coil 1, then A, B overlaps, turning on coil 2 as well, so half step FWD, then B causes next impulse to coil 2 only, the, surely that's 1/2 stepping..
Maybe I need to see true 1/2 stepping waveforms if ive misunderstood.

I also don't really get why full stepping would cause "massive resonances" anyway!
 

crutschow

Joined Mar 14, 2008
34,459
Unsure as whole concept at baby stage, probably 500 rpm.
That's a lot of steps/second.
What is generating the quadrature signal?
I also don't really get why full stepping would cause "massive resonances" anyway!
It's related to the mechanical resonant frequency of the rotor.
When the step frequency approaches that mechanical resonant frequency, the motor will start missing steps or otherwise act badly.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
Encoder, 500 again wild guess, but higher speed only used as a rapid home only. That function can b as slow as my patience!;)
Hey built ur Ccts. Wonderful.
Thanks heaps.
Up'd to 12 kHz, (cant hear that freq. Any more).
Thank God for 555's.
Love how % of step is pwm'd according to encoder, currently driven by a 'pony' motor for tests.
Cant upload dso pic from this android ph. Bah.
@ 1.8 ms step, 50% is pwm'd:)
Have to very closely match C3's, now 10 nF
to get Pwm same both 'channels'.
...
Yes had bad resonances, thanks for clarification. Must turn up a flywheel damper. No idea re mass size tho.
...
Finally got out the optical tacho, couldn't believe speed achieved for this 200 step / Rev motor just basic quadrature driven..
1641 rpm b4 it crapped out. Encoder was ~ 672 rpm. So more than adequate:):)
 

Thread Starter

qtron

Joined Aug 1, 2018
74
That's a lot of steps/second.
What is generating the quadrature signal?
It's related to the mechanical resonant frequency of the rotor.
When the step frequency approaches that mechanical resonant frequency, the motor will start missing steps or otherwise act badly.
Found by placing a 200k r from pin 2, 4093, to ground, match Pwm % quite well.
Matching the caps made little diff.
Problem is threshold diffs as 2nd 4093 a different brand. My stock of 4093's now zero LOL.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
That's a lot of steps/second.
What is generating the quadrature signal?
It's related to the mechanical resonant frequency of the rotor.
When the step frequency approaches that mechanical resonant frequency, the motor will start missing steps or otherwise act badly.
You could replace R2 with a 100kΩ pot to allow adjustment of the initial full-on time.
Yes, but will get identical brand of 4093 too.
Meant to ask, CMOS gate driving power Fet?? I thought the purpose of a nice interfacing fet driver chip was to provide the grunt ..
Conned again? Ciss is ~ 1.8 nf on IRFZ44
 

crutschow

Joined Mar 14, 2008
34,459
CMOS gate driving power Fet?? I thought the purpose of a nice interfacing fet driver chip was to provide the grunt ..
That's generally true.
But a single CMOS driver is usually okay at slow speeds, however more will likely be needed for 12kHz.
What does the signal look like on the MOSFET gate?

A poor man's driver for that is to parallel the six inverters in a CD4049 to replace U5 (they are sufficiently matched in one-chip that paralleling them should not a problem).
(Or perhaps 3 and 3 paralleled for each of the two phases would be sufficient for this application, so you would only need one chip.)
That should rapidly charge/discharge a fairly high MOSFET gate charge to operate efficiently at 12kHz.
 

Thread Starter

qtron

Joined Aug 1, 2018
74
That's generally true.
But a single CMOS driver is usually okay at slow speeds, however more will likely be needed for 12kHz.
What does the signal look like on the MOSFET gate?
A poor man's driver for that is to parallel the six inverters in a CD4049 to replace U5 (they are sufficiently matched in one-chip that paralleling them should not a problem).
(Or perhaps 3 and 3 paralleled for each of the two phases would be sufficient for this application, so you would only need one chip.)
That should rapidly charge/discharge a fairly high MOSFET gate charge to operate efficiently at 12kHz.
ok,
great, will do. U keeping me busy;)
hey uh, any further comments re 1/2 step?(posted at 4:30 yesterday, local time).
I mean, is Mr "The R_B" wrong or i wrong or?
i am chasing this down cos I want the motor to 1/2 step, not full step.. atm not sure what mode its in..
I thought Mr. vish2207 had presented fairly well how he is driving his motor (or was).
 

crutschow

Joined Mar 14, 2008
34,459
hey uh, any further comments re 1/2 step?(posted at 4:30 yesterday, local time).
I mean, is Mr "The R_B" wrong or i wrong or?
I'm really not that familiar with the specifics of stepper motor operation to know who is correct.
Can you not measure that with your setup?
 
Top