<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andrew Burks &#187; Flip-Flop</title>
	<atom:link href="http://blog.andrewburks.com/tag/flip-flop/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.andrewburks.com</link>
	<description>Personal Experiences with Technical Projects</description>
	<lastBuildDate>Fri, 25 Feb 2011 19:38:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Stepper Motor Driver &#8211; Shift Register</title>
		<link>http://blog.andrewburks.com/2010/07/stepper-motor-driver-shift-register/</link>
		<comments>http://blog.andrewburks.com/2010/07/stepper-motor-driver-shift-register/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 03:37:30 +0000</pubDate>
		<dc:creator>aburks</dc:creator>
				<category><![CDATA[RobOrchestra]]></category>
		<category><![CDATA[Robotics Club]]></category>
		<category><![CDATA[Vibratron]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Circuit]]></category>
		<category><![CDATA[Flip-Flop]]></category>
		<category><![CDATA[H-Bridge]]></category>
		<category><![CDATA[Integrated Circuit]]></category>
		<category><![CDATA[Motor Driver]]></category>
		<category><![CDATA[PCB]]></category>
		<category><![CDATA[Shift Register]]></category>
		<category><![CDATA[Stepper Motor]]></category>

		<guid isPermaLink="false">http://blog.andrewburks.com/?p=73</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<h2>The Problem</h2>
<p>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.</p>
<p>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 &#8220;wave driving&#8221; a stepper motor.  Here is what happens when a bipolar stepper motor is wave driven.</p>
<p>t=0:  A=1  B=0  C=0  D=0</p>
<p>t=1:  A=0  B=1  C=0  D=0</p>
<p>t=2:  A=0  B=0  C=1  D=0</p>
<p>t=3:  A=0  B=0  C=0  D=1</p>
<p>t=4=0</p>
<h2>The Solution</h2>
<p>A Serial in Parallel out (SIPO) <a href="http://en.wikipedia.org/wiki/Shift_register#Serial-in.2C_parallel-out_.28SIPO.29">Shift Register</a> does basically exactly what I&#8217;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 &#8220;1&#8243; so that the &#8220;1&#8243; can move along the shift register.</p>
<p>Luckily, because a shift register is just 4 <a href="http://en.wikipedia.org/wiki/Flip-flop_(electronics)#RS_.28Reset-Set.29_flip-flop">flip-flops</a> 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 &#8220;stop&#8221; pin coming from the Arduino to control whether or not the motor was turning.</p>
<p>The &#8220;stop&#8221; 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 &#8220;stop&#8221; pin was driven low, it would force the shift register into the &#8220;1-0-0-0&#8243; state, and when it was released the &#8220;1&#8243; 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):</p>
<p><a href="http://blog.andrewburks.com/wp-content/uploads/2010/07/Stepper-Shift-Circuit-Top.jpg"><img class="alignnone size-medium wp-image-81" title="Stepper Shift Circuit - Top" src="http://blog.andrewburks.com/wp-content/uploads/2010/07/Stepper-Shift-Circuit-Top-300x225.jpg" alt="" width="300" height="225" /></a></p>
<h2>Pros</h2>
<p>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 <a href="http://media.digikey.com/photos/Fairchild%20Semi%20Photos/261-20-DIP.jpg">Integrated Circuits</a>, or ICs), more if you PCB it.  It works, and it lets you do a powered brake as well.</p>
<h2>Cons</h2>
<p>The two IC&#8217;s with flip-flops are about $2.50 0f the total parts cost.  For this price ($2.50&#215;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&#8217;s output feeds into the next one&#8217;s input.</p>
<h2>More Photos</h2>
<p><a href="http://blog.andrewburks.com/wp-content/uploads/2010/07/Stepper-Shift-Circuit-Detail.jpg"><img class="alignnone size-medium wp-image-82" title="Stepper Shift Circuit - Detail" src="http://blog.andrewburks.com/wp-content/uploads/2010/07/Stepper-Shift-Circuit-Detail-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p><a href="http://blog.andrewburks.com/wp-content/uploads/2010/07/Stepper-Shift-Circuit-Arduino.jpg"><img class="alignnone size-medium wp-image-83" title="Stepper Shift Circuit - Arduino" src="http://blog.andrewburks.com/wp-content/uploads/2010/07/Stepper-Shift-Circuit-Arduino-300x225.jpg" alt="" width="300" height="225" /></a></p>
<p><a href="http://blog.andrewburks.com/wp-content/uploads/2010/07/Stepper-Shift-Circuit-Iso.jpg"><img class="alignnone size-medium wp-image-84" title="Stepper Shift Circuit - Iso" src="http://blog.andrewburks.com/wp-content/uploads/2010/07/Stepper-Shift-Circuit-Iso-300x225.jpg" alt="" width="300" height="225" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewburks.com/2010/07/stepper-motor-driver-shift-register/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

