Introduction: Driving a Stepper Motor Without a Microcontroller.

In this Instructable, I will drive a 28-BYJ-48 step motor, with a UNL2003 darlington array board, sometimes named x113647, without a micro controller.

It will have start/stop, forward/backward, and speed control.

The motor is a uni-polar step motor with 2048 steps per revolution in full step mode. The datasheet for the motor is found at http://robocraft.ru/files/datasheet/28BYJ-48.pdf

The two devices can be bought together from several vendors. I got mine from kjell.com

Bing it or google it to find a vendor near you.

I will first go through some steps and parts needed to get it running, and then add some steps and parts for some more control.

You should be warned that the parts that I use, are those that I happen to have in my treasure chest, and not necessarily the parts best suited for the purpose.

Also, you should be warned, that this is my first Instructable, and that I'm quite new to electronics.

Please add comments if you think I have done something that I shouldn't, or if you have suggestions for improvements, or suggestions for better suited parts.

Step 1: Part List

The parts used for this project are

  • Breadboard
  • Stepper motor 28byj-48
  • Darlington transistor array ULN2003 board (x113647)
  • 74HC595 shift register
  • 74HC393 binary ripple counter
  • DS1809-100 Dallastat digital potentiometer
  • 74HC241 octal buffer
  • 3 × tactile buttons
  • 3 × 10kΩ resistors
  • 2 × 0.1µF ceramic capacitors
  • 1 × 0.01 µF ceramic capacitor
  • Connection wires
  • 5V power supply

Step 2: The Main Parts

The 74HC595 shift register

The motor is moved by repeatedly giving the four input pins of the UNL2003 board this sequence:

1100-0110-0011-1001

This will drive the motor in what is called full step mode. The pattern 1100 is repeatedly shifted right. This suggests a shift register. The way a shift register work is, at every clock cycle, the bits in the register shift one place to the right, replacing the leftmost bit with the value of the input pin at the time. Hence, it should fed with two clock cycles of 1 and then two clock cycles of 0 to generate the pattern for diving the motor.

To generate the clock signals, an oscillator is needed, that generates a steady series of pulses preferably a clean square wave. This will form the base of the shifting patten of signals to the motor.

To generate the "two cycles of one and then two cycles of 0", flip-flops are used.

I have a 74HC595 shift register. This is a very popular chip, that is described in numerous Instructables and Youtube videos.

The data sheet can be found at http://www.ti.com/lit/ds/symlink/sn74hc595.pdf

A nice Instructable is 74HC595-Shift-Register-Demistified by bweaver6,

The 74HC595 shift register works so that at every clock cycle, the data in its 8 bit register is shifted right, and shifting in the value of the input pin at the leftmost position. Hence, it should fed with two clock cycles of 1 and then two clock cycles of 0.

The data is shifted at the rising edge of the clock pulse. Henc the flip-flop should toggle at the falling edge of the clock, so the 74HC595 will have stable data input at the rising clock edge.

The 74HC595 in can be wired like this:

Pin  8 (GND)   -> GND
Pin 16 (VCC)   -> 5V
Pin 14 (SER)   -> Data in
Pin 12 (RCLK)  -> Clock input
Pin 11 (SRCLK) -> Clock input
Pin 13 (OE)    -> GND
Pin 10 (SRCRL) -> 5V
Pins 15, and 1-3 will output the pattern to drive the motor.

Connecting RCLK and SRCLK ensures that the chip data register is always in sync with the output register. Putting Pin 13 to ground makes the content of the output register immediately visible to the output pins (Q0 - Q7).

The 555 timer

To generate the clock pulse, the 555 timer chip can be used. This is also a very popular chip, and is even more described and discussed than the shift register. Wikipedia has a nice article at https://en.wikipedia.org/wiki/555_timer_IC.

The data sheet is here: http://www.ti.com/lit/ds/symlink/ne555.pdf

This chip can, among other things, generate square wave clock pulse. External resistors and capacitors are used to control the frequency and duty cycle (on-fraction).

When set up to repeatedly generate pulses, the 555 chip is said to be in astable mode. This is done by wiring it like in the picture above. (picture by jjbeard [Public domain], via Wikimedia Commons):

Pin 1 -> GND
Pin 2 -> R1 (10kΩ) -> Pin 7
Pin 2 -> Pin 6
Pin 3 is the output
Pin 4 (reset) -> 5V
Pin 5 -> 0.01µF -> GND
Pin 6 -> 0.1µF -> GND
Pin 7 -> R2 (10kΩ) -> 5V
Pin 8 -> 5V

The output of Pin 3 will be connected to the input clock pins (Pin 11 and Pin 12) of the 74HC595 shift register.

The frequency of the output signal (and hence the speed of the step motor) is determined by the values of the resistor R1 and R2, and the value of the capacitor C.

The cycle time T will be
ln(2) C (R1 + 2 R2) or approximately 0.7 C (R1 + 2 R2).
The frequency is 1/T.

The duty cycle, the fraction of the cycle time that the signal is high, is
(R1 + R2) / (R1 + 2R2).
The duty cycle is not very important for this project.

I use 10kΩ, for both R1 and R2, and C = 0.1µF.

This gives a frequency of about 480Hz, and is near the maximum frequency I found that the step motor can handle without stalling.

To generate the 1100 shifted, repeated pattern from the 74HC595, pin 14 (SER) should be kept high for two clock cycles, and then low for two clock cycles repeatedly. That is, the pin should oscillate with half the frequency of the clock.

The 74HC393 dual binary ripple counter

The 74HC393 count in binary, and that also means that it can be used to divide pulse frequencies by powers of two,

Its data sheet is here: http://www.ti.com/lit/ds/symlink/sn74hc393.pdf

The 74HC393 is dual, it has one 4 bit counter on each side.

At the falling edge of the clock pulse, the first output pin toggles on and off. Hence, output pin one will oscillate with half the frequency of the input clock. At the falling edge of output pin one, output pin two toggles on and off. And so on for all the four output pins. Whenever pin n turns off, pin n+1 toggles.

Pin n+1 changes half as often as pin n. This is binary counting. The counter can count to 15 (all four bits 1) before it starts on zero again. If the last output pin of counter 1 is connected as a clock to counter 2, it may be counting to 255 (8 bits).

To create a pulse with half the frequency of the input clock, only output pin 1 is needed. That is, only counting from zero to one.

So, if the counting is done by the clock pulse from the 555, the pin on the 74HC393 counter that represents bit 2, will oscillate with half the frequency of the clock. Hence this can be connected to the SER pin of the 74HC595 shift register, to make this generate the wanted pattern.

The wiring of the 74HC393 binary counter should be:

  Pin  1 (1CLK) ->  74HC595 Pin 11, 12 and 555 Pin 3
  Pin  2 (1CLR) ->  GND
  Pin  4 (1QB)  ->  74HC595 Pin 14
  Pin  7 (GND)  ->  GND
  Pin 14 (VCC)  ->  5V
  Pin 13 (2CLK) ->  GND (not used)
  Pin 12 (2CLR) ->  5V  (not used)

Step 3: Make It Run

We now can make the motor run, If Pins 0-3 of the 74HC595 are connected to the Pins 1-4 of the ULN2003 board respectively.

For now, replace the 0.1µF capacitor at Pin 6 of the 555 timer with a 10µF. This will make the clock cycle hundred times longer, and one will be able to see what is going on.

The LEDs on the ULN2003 boards can be used for this. Unplug the motor from the ULN2003 board. Connect Pins 1 to 4 of the board to the output QA-QD (pins 7, 9, 10 and 11) of the 74HC595. Connect the - and + of the ULN2003 board to the ground and 5V. If the power is turned on, you should see the wanted pattern on the LEDs.

If you want to see what's going on in the 74HC393 binary counter, connect to pins 3-6 of that one in stead.

If the pattern seems right, power down, replace the capacitor with the 0.1µF again, connect input pins 1 - 4 of the ULN2003 board to the output pins QA - QD of the 74HC595, and plug in the motor again.

With the power on, the motor should now run.

Step 4: Speed Control

The speed of the step motor is governed by the frequency of the output of the 555 timer. This again, is governed by the values of the resistors R1 and R2 and the capacitor C1 connected to it. By connecting a 100kΩ potentiometer in series with R2, the frequency may be between the 480Hz and 63Hz. The steps pr. second of the motor, will be the half of the 555 timer frequency.

I used a DS1809-100 digital potentiometer, which is made for push button usage. Push buttons connecting pin 2 (UC) and Pin 7 (DC) to 5V makes the resistance increase/decrease between the RH (Pin 1) or RL (Pin 4) terminals, and the wiper Pin 6 (RW). Holding a button for more than a second, makes the button auto-repeat.

The datasheet can be found here: https://datasheets.maximintegrated.com/en/ds/DS180...

The wiring is like this:

Pin 1 (RH) unused
Pin 2 (UC) -> tactile button 1
Pin 3 (STR) -> GND
Pin 4 (RL) -> 555 Pin 2
Pin 5 -> GND
Pin 6 (RW) -> 10kΩ -> 555 pin 7
Pin 7 (DC) -> tactile button 2
Pin 8 -> 5V

The wiring for tactile button 1:

Pin 1/2 -> DS1809 Pin 2
Pin 3/4 -> 5V

The wiring for tactile button 2:

Pin 1/2 -> DS1809 Pin 7
Pin 3/4 -> 5V 

Now, the speed can be regulated.

Step 5: Start / Stop

To start and stop the stepper motor, Pin 4 (the Reset pin) of the 555 timer can be utilized. If this is pulled low, there will be no output pulses from Pin 3.

A tactile button will be used to toggle start and stop. Pressing the button once, should start the motor, snd pressing it again, should stop it. To get this behavior, a flip-flop is needed. But the 74HC393 that is already there, can also be used. The 74HC393 has two parts, and only one half is used as a frequency divider for the clock pulse.

Since the binary counter is actually just a set of toggling flip-flops in series,the first flip-flop of the other part can be used. By connecting a tactile button such that Pin 13 (2CLK) is low when the button is pressed, and high if it is not, Pin 12 will toggle on each low. Connecting Pin 12 to Pin 4 of the 555, will start and stop its output, and hence the motor.

Tactile buttons are a bit tricky, because they are mechanical. They may 'bounce', that is they may send multiple signals on each push. Connecting a 0.1 µF capacitor over the button, helps avoiding this.

So a tactile button (button 3 is added, and the connection to Pin 4 of the 555 is changed.

The wiring of the button:

Pin 1/2 -> 10kΩ -> 5V
Pin 1/2 -> 0.1µF -> Pin 3/4
Pin 3/4 -> 74HC393 Pin 13 (2CLK)

The following changes are made to the 555:

Pin 4 (Reset) -> 74HC393 Pin 11 (2QA)

Button 3 should now work as a start/stop toggle.

Note that a motor stopped this way, will still consume power.

Step 6: Direction Control

To control the direction of the motor, another push button is needed, and then another flip-flop. However, I will cheat, by using the next flip-flop of the 74HC393, after the on/off flip-flop, and the on/off button.

When the direction pin (Pin 2QA) goes low, the next pin (Pin 2QB) is toggled. Hence repeatedly pushing the push button will result in
OFF - ON FORWARDS - OFF - ON BACKWARDS - OFF - ON FORWARDS etc.

To make the motor run backwards, the pattern fed to the ULN2003 should be reversed. That might be done with a bi-directional shift register, but I don't have one. The 74HC595 is not bi-directional.

However, I found I could use my 74HC241 octal buffer. This buffer has two 4 bit parts, with separate OE (output enable) pins. The first OE pin controls the four first output pins, and the second the last four output pins. When the OE is on the output pins have the same value as the corresponding input pins, and when it is off, the output pins will be in high impedance state, as if they were not connected. Further, one of the OE pin is active low, and the other is active high, so when connecting them together, only half of the buffer will be active at the time.

So, for the same input, one half of the buffer can drive the motor forwards, and the other half backward. Which half is being active, depends of the value of the OE pins.

The data sheet for the 74HC241 is found at http://www.ti.com/lit/ds/symlink/sn54hc241.pdf.

The wiring could be like this:

Pin 1  (1OE) -> 74HC293 Pin 10 (2QB)
Pin 2  (1A1) -> 74HC595 Pin 15
Pin 3  (1Y4) -> ULN2003 Pin 1
Pin 4  (1A2) -> 74HC595 Pin 1
Pin 5  (1Y3) -> ULN2003 Pin 2
Pin 6  (1A3) -> 74HC595 Pin 2
Pin 7  (1Y2) -> ULN2003 Pin 3
Pin 8  (1A4) -> 74HC595 Pin 3
Pin 9  (1Y1) -> ULN2003 Pin 4
Pin 10 (GND) -> Ground
Pin 11 (2A1) -> Pin 2 (1A1) 
Pin 12 (1Y4) -> Pin 9 (2Y1)
Pin 13 (2A2) -> Pin 4 (1A2)
Pin 14 (1Y3) -> Pin 7 (2Y2)
Pin 15 (2A3) -> Pin 6 (1A3)
Pin 16 (1Y2) -> Pin 5 (2Y3)
Pin 17 (2A3) -> Pin 8 (1A4)
Pin 18 (1Y2) -> Pin 3 (2Y4)
Pin 19 (2OE) -> Pin 1 (1OE)
Pin 20 (VCC) -> 5V

Now, the wiring should be completed just by powering up with 5V.
Make sure that the power supply can deliver enough current to drive both the motor and the circuits.

Step 7: Conclusions

The step motor may be controlled without microcontroller.

The ICs used here, were some that I had from before. Most of them are not optimal for this, and several alternatives could be used.

  • To generate the pulses, the 555 timer chip is a good chice, but several alternatives exist, e.g the one described in this Instructable.
  • For the speed control, any potentiometer could be used, not only a digital one. If you have a 10kΩ potentiometer, rather than a 100kΩ, the 10kΩ resistors could be replaced by 1KΩ, and the 0.1 µF capacitor with a 1µF capacitor (divide all resistors and multiply the capacitor with the same number to keep the timing).
  • Using a bidirectional shift register, e.g. the 74HC194 would make direction control easier.
  • For button control, the 74HC393 could be replaced by a flip-flop, e.g. 74HC73. The 555 may also be wired to act as a toggle.
First Time Author

Participated in the
First Time Author