¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Stepper motor drive PULSE? #MISC #STEP


 

What does a Stepper Motor drive pulse look like?

This is very basic, starting from scratch.

I am writing (attempting to write)? PWM code to drive a stepper motor.
What should the pulse look like?
How long?
How much delay between pulses? Is the delay the same as Duty cycle?

Yes I have managed to get myself thoroughly confused.

I have seen someone using a 20ms pulse with a 50ms delay for UGS settings.

What is the practical range?
Do you vary the pulse length or the OFF time?

Ralph

Ralph

--
Clausing 8520, Craftsman 12x36 Lathe, 4x12 mini lathe, 14" Delta drill press, 40 watt laser, Consew brushless DC motors and a non working 3D printer


 

¿ªÔÆÌåÓý

Hi Ralph,

Throw out the concept that stepping pulses are PWM.? They aren't.

?

Now look at the driver you are interfacing to and read the specifications.? There are several.

1.????? Minimum step pulse width.? Usually no less than 1 or 2 Microseconds.

2.????? Direction change setup time.? This one is important.? If you change the direction pin it must remain at that new level for a number of Microseconds before you issue a step pulse.

3.????? Some stepper drivers will also state minimum step pulse low time but generally not and the minimum time is usually the same time as the step pulse.

?

Think of it this way.? If you have full stepping or 200 steps per rev it's likely you still won't run the stepper motor faster than about 700 RPM before the torque falls off so badly that it has no power. ??If it can even get there through the resonant point.? That's where micro-stepping comes in.? It helps to prevent resonance where the torque falls off very steeply. You see fancy things done with GECKO drivers.? They shift the phase slightly during the resonant points and switch over to full step above that (from 10 micro steps/step) to increase the torque at higher speeds.

?

Anyway, at 720 RPM you are turning 12 revolutions per second.? At 200 steps per rev that's 2400 Hz or about 417uS period.? The step pulse only needs to be high for about 2 uS of that.

?

Now change to 10 micro-steps/step and you have 24,000 Hz and a 41.7 uS period.? Still only need 2 uSec. Step pulse.?

?

It's easy enough to get a hardware counter module to create 24kHz.? But implementing an acceleration curve is more difficult.? And a stepper motor will lock up with a full speed step rate.? By the same token you can't just remove the step rate.? So your stepper code has to do two things.

?

1.????? Accelerate up to speed while maintaining a smooth acceleration

2.????? Maintain speed with even step pulses

3.????? Decelerate to zero arriving at the stopped point with exactly the correct number of steps so the distance travelled is correct.

?

The small systems that track a spindle work differently.? They look at the spindle encoder frequency, perhaps multiplying and dividing by a scale factor and that's the step rate.? They then scale that number to create an acceleration up to the scaled spindle speeds and then switch off the acceleration and just use the spindle pulses to create step pulses.? Again, only about 2uS.

?

Often they will run a separate speed check loop to detect that the spindle is slowing down faster than expected because the motor has been switched off.? They then switch back into a deceleration loop and bring the motor back down to 0 without locking up.? Distance isn't important because the half nut is still used to engage the carriage.? Or with a VFD make sure the spindle can't accelerate faster than the stepper motor and then just directly couple the spindle encoder pulses to the stepper pulse input.

?

These systems work well as long as the speed of the spindle encoder pulses remains low enough so that the processor can keep up.? A Sherline or a mill turning 6000 RPM is out of the question if the encoder is more than 200 PPR.? I believe the parallel port LinuxCNC implementation suffers from this restriction.?? OTOH, with a MESA card the FPGA hardware uses quadrature encoder counters to track spindle speed with encoder line counts of 2500 or 10,000 PPR at 10,000 RPM.? That's 100MHz.

?

John

?

?

?

?

?

From: [email protected] [mailto:[email protected]] On Behalf Of Ralph Hulslander
Sent: July-11-20 11:21 AM
To: [email protected]
Subject: [digitalhobbyist] Stepper motor drive PULSE? #MISC #STEP

?

What does a Stepper Motor drive pulse look like?

This is very basic, starting from scratch.

I am writing (attempting to write)? PWM code to drive a stepper motor.
What should the pulse look like?
How long?
How much delay between pulses? Is the delay the same as Duty cycle?

Yes I have managed to get myself thoroughly confused.

I have seen someone using a 20ms pulse with a 50ms delay for UGS settings.

What is the practical range?
Do you vary the pulse length or the OFF time?

Ralph

Ralph

--
Clausing 8520, Craftsman 12x36 Lathe, 4x12 mini lathe, 14" Delta drill press, 40 watt laser, Consew brushless DC motors and a non working 3D printer


 

John, I am not 100% sure, but I think that Ralph is attempting to drive the motor directly without using a separate hardware stepper driver.

Ralph, could you please clarify whether you are using a stepper motor driver??John provided a lot of thorough and useful information for driving a stepper motor via driver, but I am not sure that is what you are trying to do. It is possible to write your own code to drive the motor directly, but I would not recommend it for anything more than experimenting. and may provide you with some basic information.?

--
Regards,

Charlie
New Jersey, USA

There IS no cloud!? It's just someone else's computer.


 

¿ªÔÆÌåÓý

To drive the stepper directly you still need to drive some sort of transistors with the ability to change the direction of the current in each of the two windings.?

?

I used a pair of stepper motor driver chips to run a stepper motor directly and set the current and direction in each winding.? These two LMD18245 driver chips from Digikey now cost more than an entire far east Micro-stepping driver.

?

?

The source code link is on the above page.? Look in the Int.c for the 8 micro-step/step tables and method of DIR setup and STEP width. ?This would drive a motor up to 20kHz which was still faster than I've been able to drive any motor.? At least where I couldn't stall the shaft with my fingers.

?

I've since ported the entire project to the PIC32.? Where before all of the trajectory motion (and taper tracking) and stepping was done in that interrupt routine and took about 35 Microseconds out of the 50 uS (20KHz) interrupt period the PIC32 does it all in under 3 uS.? But that also meant I had to dramatically change how I did the timing for DIR setup and for step pulse width.

?

The PIC32 project conversion is currently on hold while I do some more work on the CNC conversion of my MILL.? Among other things.? The attached photo shows the Microchip Automotive Networking Board as the build platform with CLICK modules.? From there I go to an adaptor that does level translation from 3V to 5V and buffers all the signals so I don't blow the CPU module on the ANB.? And from the adaptor it has a 40 pin DIP to DIP cable that replaces the processor on the ELS.

?

I've tested it driving a motor with both the separate step/dir out to an external driver and also the internal LMD18245 drivers and directly to the motor.? The PIC32 I expect to use has CAN bus and PWM Motor control, USB and most importantly hardware quadrature encoder support.?? Therefore I should be able to handle spindle encoders and Sherline and other small lathes to 6000 RPM.?

?

Theoretically also spindles on Mills turning up to 6000 RPM.? But that's in the future.?

?

John Dammeyer

?

"ELS! Nothing else works as well for your Lathe"

Automation Artisans Inc.

www dot autoartisans dot com

?

?

?

From: [email protected] [mailto:[email protected]] On Behalf Of CLevinski
Sent: July-12-20 9:31 AM
To: [email protected]
Subject: Re: [digitalhobbyist] Stepper motor drive PULSE? #MISC #STEP

?

John, I am not 100% sure, but I think that Ralph is attempting to drive the motor directly without using a separate hardware stepper driver.

Ralph, could you please clarify whether you are using a stepper motor driver??John provided a lot of thorough and useful information for driving a stepper motor via driver, but I am not sure that is what you are trying to do. It is possible to write your own code to drive the motor directly, but I would not recommend it for anything more than experimenting. and may provide you with some basic information.?

--
Regards,

Charlie
New Jersey, USA

There IS no cloud!? It's just someone else's computer.


 

Thanks for the replies, I have been in the garden and not in my shop or at my computer.
I just posted pictures on Facebook if you want to take a look!

Regarding "Stepper Motor Pulse" Wow talk about more than one can handle, Thank you John
you have always been such a great help.

Charlie, actually I "think" I was thinking about the pulse for a stepper driver module.
I just wanted to start at the beginning. John very few of the stepper driver programs I have found address acceleration, I do have the Arduino AccellStepper code and forum.

I still have not decided exactly what motorized Leadscrew method I am going to use.

I am going to do something, it is a work in progress I almost have my stepper setup to drive my leadscrew.

I want controlled automated Z & X drive on my lathe(s).

John's ELS has held my interest for the past 3 - 4 years, but I hate buttons.
The RELS seems interesting but ...

Currently I have been looking at and following Jon's (Birney Eye) leadscrew9 project.

I like using the Nextion display but most of all I like being able to talk with the developer.

I think Jon is a member of the digitalhobbyist group.

So I am leaning towards leadscrew9, actually I am not sure what Jon actually calls the project.

Of course having a nice straight course of action to accomplish my goal of automated Z & X
is not something I do for any of my projects, I have to complicate them somehow.

Now I just received two of the modules.

I love the flexibility these modules offer.??

"12V to 80V and output current up to 10A."

So now I am looking at how to integrate these into an automated Z & X routine.

Thanks for the replies, I love to see things being talked about and of course the help I receive.

Ralph





--
Clausing 8520, Craftsman 12x36 Lathe, 4x12 mini lathe, 14" Delta drill press, 40 watt laser, Consew brushless DC motors and a non working 3D printer