Andrew Burks

Archive for July, 2010

Stepper Motor Driver – NAND Gates

by on Jul.11, 2010, under RobOrchestra, Robotics Club, Vibratron

The Problem

I still need to find a cost effective way of turning a bipolar stepper motor on and off using just one pin.  I want to have the ability to use a powered brake, and I want to be able to use half-stepping control of the motor for smoother rotation.

Half-stepping gives the motor higher resolution, which is good for my application because one full step cycle is enough to move a single ball through.  The 4-stage process from before turns into an 8-stage process when you change to half-stepping.

t=0  A=1  B=0  C=0  D=0

t=1  A=1  B=1  C=0  D=0

t=2  A=0  B=1  C=0  D=0

t=3  A=0  B=1  C=1  D=0

t=4  A=0  B=0  C=1  D=0

t=5  A=0  B=0  C=1  D=1

t=6  A=0  B=0  C=0  D=1

t=7  A=1  B=0  C=0  D=1


The Solution

I noticed that in half stepping (and full stepping) if you view the logic for each of the four wires as a wave, they are always 90 degrees out of phase and have a specific shape.  I wanted to create four unique signal lines, one for each of the four wave patterns, and transmit this signal to each of the 30 stepper controllers.  At each controller, I should be able to choose either some default value (like a powered or unpowered brake) or let the motor run off the signal.

Because my focus was centered on the powered brake, my initial idea was to take my on-off line at each motor and perform a logical AND with three of the four waves and a logical OR with the other wave.  The OR would drive its input high while the AND would drive its inputs low.  This solved my problem, but unfortunately I couldn’t find a chip with an AND and an OR circuit on it.

You can build any logic gate with a combination of NAND or NOR gates.  It takes two NAND gates to build an AND gate, and three NAND gates to build an OR gate (and vice-versa when building from NOR gates).  They sell IC’s with 4 NAND gates in them, so I really wanted to find a way to do my OR operation with only 2 NAND gates.

Eventually I realized that if I negated the signal wave coming from the Arduino (by using 1 NAND as an inverter) and then performed a NAND operation with the wave signal and the on-off signal I got the exact output I wanted!  of course, if I had just used an AND on each of the four inputs, I would have an unpowered brake and less of a headache.

I made this circuit on a protoboard, and tested it with both full and half stepping.  It worked like a charm.  The next step is to see if half-stepping combined with a smaller diameter wheel will be able to push balls along without jamming.  Here is the protoboard layout:


This setup allows for full and half stepping.  It costs less than the shift register design, about $2 per unit (only $0.75 from the two NAND ICs).  Each of the four inputs is completely isolated from the others, so the wiring is simpler (which makes the PCB layout easier).


There are now 4 common signal wires instead of just one.  These 4 wires will need to be jumped from board to board, potentially requiring some sort of transistor to keep the voltage from dropping as it moves across the boards.

More Photos

Leave a Comment :, , , , , , , more...

Stepper Motor Driver – Shift Register

by on Jul.06, 2010, under RobOrchestra, Robotics Club, Vibratron

The Problem

I need to be able to turn 30 identical stepper motors on and off individually.  I can only afford to have one unique wire going to each stepper unit because I only have ~40 digital outputs to work with.  I can afford to have a few common outputs that are jumped from board to board.  basically I need to turn four inputs that go in a pattern into one input.

The four lines on the motor driver (H-Bridge) basically take turns going high when I want the motor to turn.  When I want it to stand still, only one of the lines should be high.  This is called “wave driving” a stepper motor.  Here is what happens when a bipolar stepper motor is wave driven.

t=0:  A=1  B=0  C=0  D=0

t=1:  A=0  B=1  C=0  D=0

t=2:  A=0  B=0  C=1  D=0

t=3:  A=0  B=0  C=0  D=1


The Solution

A Serial in Parallel out (SIPO) Shift Register does basically exactly what I’m looking for.  If I have one common clock (a line that goes high every 1/4 step) and connect the 4th output to the data input, then the four parallel outputs will shift through my 4 states like a champ.  The only catch is that I need to seed the circuit with the initial “1″ so that the “1″ can move along the shift register.

Luckily, because a shift register is just 4 flip-flops lined up in a row, I could build my own shift register out of flip flops, and access the set/reset abilities of the individual flip-flops.  So in the final setup, I had a single clock coming from the Arduino (pulsing at 100ms intervals) which controlled the speed of the motor, and a “stop” pin coming from the Arduino to control whether or not the motor was turning.

The “stop” pin was tied to the reset pin on the first flip-flop and the set pins on the other 3.  This means that when the “stop” pin was driven low, it would force the shift register into the “1-0-0-0″ state, and when it was released the “1″ would shift sequentially at the speed of the clock to drive the motor.  Here is a view of the protoboard layout (the center IC is the motor driver, and the other two each contain two flip-flops):


This is a huge improvement over controlling all 120 lines individually.  An Arduino mega can easily output a single clock and 30 control lines.  The cost of each circuit is about $4 in parts (three Integrated Circuits, or ICs), more if you PCB it.  It works, and it lets you do a powered brake as well.


The two IC’s with flip-flops are about $2.50 0f the total parts cost.  For this price ($2.50×30=$75) it would technically be cheaper to buy some other board that can take serial from the Arduino and control the 120 outputs.  Also, the wiring is a bit complex and uninsulated because each flip-flop’s output feeds into the next one’s input.

More Photos

Leave a Comment :, , , , , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!