# Stepper motor speed control [closed]

People I am having a problem regarding the control of the stepper motor speed, I understand that in order to change the speed of the stepper motor I will need to generate pulses at different frequencies using a micro-controller. My problem is that I can't find an algorithm of how to program a micro-controller so that I will be able to generate pulses with different frequencies. Can Someone plz find time to explain how can I interact with the MCU so that I will be able to accelerate/decelerate the stepper motor. To make my question more clearly, I need someone who can give me an Idea on how to tell the MCU to change the frequency of the output it generate,because the motor speed also depends on the frequency of the pulses, I will then try to code that myself, plz people just an Idea. Thank You

• It might help if you edit the question title, and add 'Stepper Motor' to help people find your question more easily. Aug 31, 2016 at 2:35

One of the most popular and definitive, free, explanations of how to drive stepper motors is 'Control of Stepping Motors, A Tutorial, by Douglas W. Jones' often shortened to 'Jones on Steppers'.

However, if you are new to this, I would recommend you do not drive the stepper motor 'directly' (using two H-Bridges and the MCU), but instead use the MCU to control a stepper motor driver. There are lots of ready made modules. The advantages of a stepper motor driver, over a simple H-bridge are a little complex to describe in a few paragraphs. However the main advantages are they are much simpler to control from a MCU program, and you can get better torque and finer speed or position control.

The right stepper motor driver depends on the specification of the stepper motor you need to drive.

Common examples of stepper drivers suitable for 1A-3A motors can easily be found on www shopping sites by searching for 'stepper motor driver'. You will likely be able to find examples up to 10's of Amps on shopping sites.

These types of modules typically need one clock signal (i.e. a square wave) and a direction signal, and the stepper motor drive modules will derive all of the signals necessary to drive the stepper. The majority of modules are designed for bi-polar steppers motors. The clock signal is generated by a MCU timer.

For example the 16 bit timer on an Arduino's ATmega328 is usable because the maximum count of the timer can be set and changed, and this would change the duration of each pulse, and hence the stepper motor speed. As it is 16bit, it s easy to get a very wide range of oulse frequency, which lets you run very slow up to very fast with very little extra complication.

If you really want to see how to generate the signals to drive a stepper, using simple H-Bridges to control the current, then you can read the source code in the Open Source Arduino Stepper library, which is installed when you install the Arduino IDE.