<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://hades.mech.northwestern.edu//index.php?action=history&amp;feed=atom&amp;title=PIC32MX%3A_Driving_a_Stepper_Motor</id>
	<title>PIC32MX: Driving a Stepper Motor - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://hades.mech.northwestern.edu//index.php?action=history&amp;feed=atom&amp;title=PIC32MX%3A_Driving_a_Stepper_Motor"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;action=history"/>
	<updated>2026-04-11T11:33:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.9</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=16605&amp;oldid=prev</id>
		<title>NickMarchuk at 20:21, 1 March 2010</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=16605&amp;oldid=prev"/>
		<updated>2010-03-01T20:21:21Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:21, 1 March 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;== Original Assignment ==&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;&#039;&#039;&#039;Do not erase this section!&#039;&#039;&#039;&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;Your assignment is to create code that reads a voltage from a potentiometer and controls a stepper motor to rotate at a proportional speed.  The middle range of the analog input (i.e., 1.65 V) corresponds to zero speed, the minimum is maximum backward speed, and the maximum is maximum forward speed.  You will create an interrupt service routine that is called every 500 microseconds.  Each time through the routine, you will add 1 to a counter.  When that counter (time, in units of 500 microseconds) exceeds the inverse of the desired speed (time per step), you will change the digital outputs controlling the stepper motor to the next position, depending on the direction of motion, and set the counter back to zero.&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;To do this, you must create a function that takes the analog input, turns it into a speed, then turns it into an inverse of speed that the ISR uses.  Clearly the shortest allowable inverse of speed is 1 unit (500 microseconds per step).  But can your motor really do this, or does it just vibrate if you try to rotate that fast?  Based on your experiments, you should find the maximum speed that the motor actually tracks and set that as a constant.  Then 3.3 V and 0 V map to this speed, in opposite directions.&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;You will use a geared stepper motor that we provide.&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;== Overview ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;== Overview ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>NickMarchuk</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=16335&amp;oldid=prev</id>
		<title>JarvisSchultz: /* Circuit */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=16335&amp;oldid=prev"/>
		<updated>2010-02-16T19:25:08Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Circuit&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:25, 16 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 26:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 26:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;[[Image:General_Bipolar_H-Bridge_Drive_Circuit.JPG|thumb|350px|General H-Bridge Bipolar Drive Circuit|right ]]&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;[[Image:General_Bipolar_H-Bridge_Drive_Circuit.JPG|thumb|350px|General H-Bridge Bipolar Drive Circuit|right ]]&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;A bipolar stepper motor has two separate phases.  The steps are created by changing the direction of the current flow through each of the phases in the correct sequence.  In this circuit, one-half of an h-bridge is connected to each of the four leads of the stepper motor.  These h-bridge transistors are used so that the 3.3V available from the PIC32 can be used as control logic &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;alone&lt;/del&gt;, and the primary current for the motor can be sourced from somewhere else.  These also help to isolate the motor from the PIC32.  A general image of this h-bridge setup can be seen at right.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;A bipolar stepper motor has two separate phases.  The steps are created by changing the direction of the current flow through each of the phases in the correct sequence.  In this circuit, one-half of an h-bridge is connected to each of the four leads of the stepper motor.  These h-bridge transistors are used so that the 3.3V available from the PIC32 can be used as control logic &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(for switching current direction in the motor phases)&lt;/ins&gt;, and the primary current for the motor can be sourced from somewhere else.  These also help to isolate the motor from the PIC32.  A general image of this h-bridge setup can be seen at right&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; (adapted from [http://www.nmbtc.com/motors/pm-step/engineering/selection_pm/drivecircuit.html NMB&#039;s Website])&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;&amp;lt;br clear=all&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;&amp;lt;br clear=all&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=16322&amp;oldid=prev</id>
		<title>JarvisSchultz: /* Code */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=16322&amp;oldid=prev"/>
		<updated>2010-02-16T18:53:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:53, 16 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 167:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 167:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;		count++;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;		count++;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;		// Set the current byte of the RS232_In_Buffer to be equal to data:&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;		// Set the current byte of the RS232_In_Buffer to be equal to data:&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;		// strncpy(&amp;amp;data,&amp;amp;RS232_In_Buffer[j%20],1);&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;		data = RS232_In_Buffer[j%20];&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;		data = RS232_In_Buffer[j%20];&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;		// Increment our variable for indicating which variable in the buffer we are reading&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;		// Increment our variable for indicating which variable in the buffer we are reading&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15472&amp;oldid=prev</id>
		<title>JarvisSchultz: /* Code */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15472&amp;oldid=prev"/>
		<updated>2010-02-09T02:55:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:55, 9 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;== Code ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;== Code ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;The entire pastable code for the PIC32 is in the text box below, and a link can be found&lt;del class=&quot;diffchange diffchange-inline&quot;&gt; here:&lt;/del&gt; [[Media:PIC32_Stepper_Motor_Driving_Code_JSJW.c]].  Compiling this code and loading it onto the PIC32 is the bare-minimum that is required for controlling the stepper motor.  If this is the case, motor control is handled through some serial communication terminal program (hyperterminal, [http://www.chiark.greenend.org.uk/~sgtatham/putty/| putty], or [http://realterm.sourceforge.net/| realterm]). Be sure to match the baudrate (115200), the stop bits (1), the parity bits (none), and the data flow (none).  In the main function of the program it is possible for the user to extract the correct format for the motor control data.  But, for simplicity, it is summarized here as well.  A total set of control data consists of 10, 8-bit (one byte) ascii characters.  The first character is either an &#039;s&#039;, &#039;d&#039;, or &#039;p&#039;.  An &#039;s&#039; implies that the user simply wants to set a motor speed to some value; a &#039;p&#039; tells the PIC that the user wants to control speed and position of the motor i.e. step this fast for this many degrees; and a &#039;d&#039; tells the motor to stop right where it is.  The second byte is either an ascii &#039;1&#039; or &#039;0&#039;.  This byte sets the motor direction.  The next three bytes set the motor speed in steps per second.  The first byte is the hundreds digit, then the tens digit, then the ones digit.  The last five bytes are the number of steps the user wants the motor to step before stopping; these are decoded in the same way except the most significant byte is the ten-thousands digit.  If the user sends an &#039;s&#039; as the first byte, the contents of the last 5 bytes will not affect the motor&#039;s behavior; if the user sends a &#039;d&#039;, only the first byte is important.  As an example, let&#039;s say the user wants to the motor to drive 1000 steps in the positive direction (the actual direction will depend on how the motor is wired up) at a speed of 300 steps/ second.  Then the user would send the string &#039;p130001000&#039; to the PIC.  &lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;The entire pastable code for the PIC32 is in the text box below, and a link can be found [[Media:PIC32_Stepper_Motor_Driving_Code_JSJW.c&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;| here&lt;/ins&gt;]].  Compiling this code and loading it onto the PIC32 is the bare-minimum that is required for controlling the stepper motor.  If this is the case, motor control is handled through some serial communication terminal program (hyperterminal, [http://www.chiark.greenend.org.uk/~sgtatham/putty/| putty], or [http://realterm.sourceforge.net/| realterm]). Be sure to match the baudrate (115200), the stop bits (1), the parity bits (none), and the data flow (none).  In the main function of the program it is possible for the user to extract the correct format for the motor control data.  But, for simplicity, it is summarized here as well.  A total set of control data consists of 10, 8-bit (one byte) ascii characters.  The first character is either an &#039;s&#039;, &#039;d&#039;, or &#039;p&#039;.  An &#039;s&#039; implies that the user simply wants to set a motor speed to some value; a &#039;p&#039; tells the PIC that the user wants to control speed and position of the motor i.e. step this fast for this many degrees; and a &#039;d&#039; tells the motor to stop right where it is.  The second byte is either an ascii &#039;1&#039; or &#039;0&#039;.  This byte sets the motor direction.  The next three bytes set the motor speed in steps per second.  The first byte is the hundreds digit, then the tens digit, then the ones digit.  The last five bytes are the number of steps the user wants the motor to step before stopping; these are decoded in the same way except the most significant byte is the ten-thousands digit.  If the user sends an &#039;s&#039; as the first byte, the contents of the last 5 bytes will not affect the motor&#039;s behavior; if the user sends a &#039;d&#039;, only the first byte is important.  As an example, let&#039;s say the user wants to the motor to drive 1000 steps in the positive direction (the actual direction will depend on how the motor is wired up) at a speed of 300 steps/ second.  Then the user would send the string &#039;p130001000&#039; to the PIC.  &lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;Note: There are limits to how fast the motor can spin.  If the user sets the speed too high, the motor will just vibrate.  Some motors list their maximum speeds on the data sheets.  If the desired motor does not have this listed, a little bit of experimentation should yield the maximum speed.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;Note: There are limits to how fast the motor can spin.  If the user sets the speed too high, the motor will just vibrate.  Some motors list their maximum speeds on the data sheets.  If the desired motor does not have this listed, a little bit of experimentation should yield the maximum speed.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 419:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 419:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;As mentioned at the top, this code was designed to work with processing.  A user interface has been programmed and can be found [[Stepper_Motor.zip| here]].&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;As mentioned at the top, this code was designed to work with processing.  A user interface has been programmed and can be found [[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Media:&lt;/ins&gt;Stepper_Motor.zip| here]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;].  This zip file contains the main code (Stepper Motor/Stepper_Motor.pde).  This folder should be unzipped to the default processing applications folder (something like ...My Documents/Processing).  The other folder (controlP5) contains the necessary library to execute this code.  It should be unzipped to ...My Documents/Processing/libraries.  Information on this library can be found [http://www.sojamo.de/libraries/controlP5/| here&lt;/ins&gt;].&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15471&amp;oldid=prev</id>
		<title>JarvisSchultz: /* Code */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15471&amp;oldid=prev"/>
		<updated>2010-02-09T02:45:09Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;a href=&quot;https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;amp;diff=15471&amp;amp;oldid=15469&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15469&amp;oldid=prev</id>
		<title>JarvisSchultz: /* Code */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15469&amp;oldid=prev"/>
		<updated>2010-02-09T02:38:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:38, 9 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 42:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 42:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;Note: There are limits to how fast the motor can spin.  If the user sets the speed too high, the motor will just vibrate.  Some motors list their maximum speeds on the data sheets.  If the desired motor does not have this listed, a little bit of experimentation should yield the maximum speed.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;Note: There are limits to how fast the motor can spin.  If the user sets the speed too high, the motor will just vibrate.  Some motors list their maximum speeds on the data sheets.  If the desired motor does not have this listed, a little bit of experimentation should yield the maximum speed.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;[[Media:Example.ogg]]&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15467&amp;oldid=prev</id>
		<title>JarvisSchultz: /* Code */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15467&amp;oldid=prev"/>
		<updated>2010-02-09T02:27:35Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:27, 9 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 41:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 41:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;The entire pastable code for the PIC32 is in the text box below.  Compiling this code and loading it onto the PIC32 is the bare-minimum that is required for controlling the stepper motor.  If this is the case, motor control is handled through some serial communication terminal program (hyperterminal, [http://www.chiark.greenend.org.uk/~sgtatham/putty/| putty], or [http://realterm.sourceforge.net/| realterm]). Be sure to match the baudrate (115200), the stop bits (1), the parity bits (none), and the data flow (none).  In the main function of the program it is possible for the user to extract the correct format for the motor control data.  But, for simplicity, it is summarized here as well.  A total set of control data consists of 10, 8-bit (one byte) ascii characters.  The first character is either an &#039;s&#039;, &#039;d&#039;, or &#039;p&#039;.  An &#039;s&#039; implies that the user simply wants to set a motor speed to some value; a &#039;p&#039; tells the PIC that the user wants to control speed and position of the motor i.e. step this fast for this many degrees; and a &#039;d&#039; tells the motor to stop right where it is.  The second byte is either an ascii &#039;1&#039; or &#039;0&#039;.  This byte sets the motor direction.  The next three bytes set the motor speed in steps per second.  The first byte is the hundreds digit, then the tens digit, then the ones digit.  The last five bytes are the number of steps the user wants the motor to step before stopping; these are decoded in the same way except the most significant byte is the ten-thousands digit.  If the user sends an &#039;s&#039; as the first byte, the contents of the last 5 bytes will not affect the motor&#039;s behavior; if the user sends a &#039;d&#039;, only the first byte is important.  As an example, let&#039;s say the user wants to the motor to drive 1000 steps in the positive direction (the actual direction will depend on how the motor is wired up) at a speed of 300 steps/ second.  Then the user would send the string &#039;p130001000&#039; to the PIC.  &lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;The entire pastable code for the PIC32 is in the text box below.  Compiling this code and loading it onto the PIC32 is the bare-minimum that is required for controlling the stepper motor.  If this is the case, motor control is handled through some serial communication terminal program (hyperterminal, [http://www.chiark.greenend.org.uk/~sgtatham/putty/| putty], or [http://realterm.sourceforge.net/| realterm]). Be sure to match the baudrate (115200), the stop bits (1), the parity bits (none), and the data flow (none).  In the main function of the program it is possible for the user to extract the correct format for the motor control data.  But, for simplicity, it is summarized here as well.  A total set of control data consists of 10, 8-bit (one byte) ascii characters.  The first character is either an &#039;s&#039;, &#039;d&#039;, or &#039;p&#039;.  An &#039;s&#039; implies that the user simply wants to set a motor speed to some value; a &#039;p&#039; tells the PIC that the user wants to control speed and position of the motor i.e. step this fast for this many degrees; and a &#039;d&#039; tells the motor to stop right where it is.  The second byte is either an ascii &#039;1&#039; or &#039;0&#039;.  This byte sets the motor direction.  The next three bytes set the motor speed in steps per second.  The first byte is the hundreds digit, then the tens digit, then the ones digit.  The last five bytes are the number of steps the user wants the motor to step before stopping; these are decoded in the same way except the most significant byte is the ten-thousands digit.  If the user sends an &#039;s&#039; as the first byte, the contents of the last 5 bytes will not affect the motor&#039;s behavior; if the user sends a &#039;d&#039;, only the first byte is important.  As an example, let&#039;s say the user wants to the motor to drive 1000 steps in the positive direction (the actual direction will depend on how the motor is wired up) at a speed of 300 steps/ second.  Then the user would send the string &#039;p130001000&#039; to the PIC.  &lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;Note: There are limits to how fast the motor can spin.  If the user sets the speed too high, the motor will just vibrate.  &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;A&lt;/del&gt; little bit of experimentation&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;Note: There are limits to how fast the motor can spin.  If the user sets the speed too high, the motor will just vibrate.  &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Some motors list their maximum speeds on the data sheets.  If the desired motor does not have this listed, a&lt;/ins&gt; little bit of experimentation&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; should yield the maximum speed.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15466&amp;oldid=prev</id>
		<title>JarvisSchultz: /* Code */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15466&amp;oldid=prev"/>
		<updated>2010-02-09T02:26:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:26, 9 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;== Code ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;== Code ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;The entire pastable code for the PIC32 is in the text box below.  Compiling this code and loading it onto the PIC32 is the bare-minimum that is required for controlling the stepper motor.  If this is the case, motor control is handled through some serial communication terminal program (hyperterminal, [http://www.chiark.greenend.org.uk/~sgtatham/putty/| putty], or [http://realterm.sourceforge.net/| realterm]). Be sure to match the baudrate (115200), the stop bits (1), the parity bits (none), and the data flow (none).  In the main function of the program it is possible for the user to extract the correct format for the motor control data.  But, for simplicity, it is summarized here as well.  A total set of control data consists of 10, 8-bit (one byte) ascii characters.  The first character is either an &#039;s&#039;, &#039;d&#039;, or &#039;p&#039;.  An &#039;s&#039; implies that the user simply wants to set a motor speed to some value; a &#039;p&#039; tells the PIC that the user wants to control speed and position of the motor i.e. step this fast for this many degrees; and a &#039;d&#039; tells the motor to stop right where it is.  The second byte is either an ascii &#039;1&#039; or &#039;0&#039;.  This byte sets the motor direction.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;The entire pastable code for the PIC32 is in the text box below.  Compiling this code and loading it onto the PIC32 is the bare-minimum that is required for controlling the stepper motor.  If this is the case, motor control is handled through some serial communication terminal program (hyperterminal, [http://www.chiark.greenend.org.uk/~sgtatham/putty/| putty], or [http://realterm.sourceforge.net/| realterm]). Be sure to match the baudrate (115200), the stop bits (1), the parity bits (none), and the data flow (none).  In the main function of the program it is possible for the user to extract the correct format for the motor control data.  But, for simplicity, it is summarized here as well.  A total set of control data consists of 10, 8-bit (one byte) ascii characters.  The first character is either an &#039;s&#039;, &#039;d&#039;, or &#039;p&#039;.  An &#039;s&#039; implies that the user simply wants to set a motor speed to some value; a &#039;p&#039; tells the PIC that the user wants to control speed and position of the motor i.e. step this fast for this many degrees; and a &#039;d&#039; tells the motor to stop right where it is.  The second byte is either an ascii &#039;1&#039; or &#039;0&#039;.  This byte sets the motor direction.&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;  The next three bytes set the motor speed in steps per second.  The first byte is the hundreds digit, then the tens digit, then the ones digit.  The last five bytes are the number of steps the user wants the motor to step before stopping; these are decoded in the same way except the most significant byte is the ten-thousands digit.  If the user sends an &#039;s&#039; as the first byte, the contents of the last 5 bytes will not affect the motor&#039;s behavior; if the user sends a &#039;d&#039;, only the first byte is important.  As an example, let&#039;s say the user wants to the motor to drive 1000 steps in the positive direction (the actual direction will depend on how the motor is wired up) at a speed of 300 steps/ second.  Then the user would send the string &#039;p130001000&#039; to the PIC.  &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;Note: There are limits to how fast the motor can spin.  If the user sets the speed too high, the motor will just vibrate.  A little bit of experimentation&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15465&amp;oldid=prev</id>
		<title>JarvisSchultz: /* Circuit */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15465&amp;oldid=prev"/>
		<updated>2010-02-09T02:15:33Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Circuit&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:15, 9 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 35:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 35:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;[[Image:Bipolar Stepper Motor Drive Circuit JSJW.JPG|1080px]]&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;[[Image:Bipolar Stepper Motor Drive Circuit JSJW.JPG|1080px]]&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;&amp;lt;br clear=all&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;&amp;lt;br clear=all&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;In the above circuit, pins D0-D3 of the PIC32 are used to as inputs to the h-bridge chip.  The timers in the code switch these pins high and low to step the motor.  U2TX and U2RX are connected to an RS232 cable that is correctly grounded and connected to a PC.  This cable is used for sending signals to the motor and receiving current motor step counts from the PIC.  An interesting note is that this circuit and corresponding code will work for other four-lead bipolar stepper motors as well.  If using another motor, the motor supply voltage simply has to be adjusted to match this motor.  Be careful not to exceed the limits of the h-bridge chip!&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;In the above circuit, pins D0-D3 of the PIC32 are used to as inputs to the h-bridge chip.  The timers in the code switch these pins high and low to step the motor&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;.  The motor&#039;s output leads need to be correctly connected to the h-bridge outputs.  Some motor manufacturers specify which color wires correspond to which phase, but some do not.  If unsure which wire is which, use a multimeter, and test the resistance of each of the pairs of wires.  When one pair shows a resistance that is significant, you know that these two wires are internally connected.  This means that they will either need to be connected to outputs 1 and 2 or outputs 3 and 4 of the h-bridge&lt;/ins&gt;.  U2TX and U2RX are connected to an RS232 cable that is correctly grounded and connected to a PC.  This cable is used for sending signals to the motor and receiving current motor step counts from the PIC.  An interesting note is that this circuit and corresponding code will work for other four-lead bipolar stepper motors as well.  If using another motor, the motor supply voltage simply has to be adjusted to match this motor.  Be careful not to exceed the limits of the h-bridge chip!&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;== Code ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;== Code ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15464&amp;oldid=prev</id>
		<title>JarvisSchultz: /* Code */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=PIC32MX:_Driving_a_Stepper_Motor&amp;diff=15464&amp;oldid=prev"/>
		<updated>2010-02-09T02:10:15Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:10, 9 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 39:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;div&gt;== Code ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;div&gt;== Code ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-deleted&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-context diff-side-added&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-addedline diff-side-added&quot;&gt;&lt;div&gt;The entire pastable code for the PIC32 is in the text box below.  Compiling this code and loading it onto the PIC32 is the bare-minimum that is required for controlling the stepper motor.  If this is the case, motor control is handled through some serial communication terminal program (hyperterminal, [http://www.chiark.greenend.org.uk/~sgtatham/putty/| putty], or [http://realterm.sourceforge.net/| realterm]). Be sure to match the baudrate (115200), the stop bits (1), the parity bits (none), and the data flow (none).  In the main function of the program it is possible for the user to extract the correct format for the motor control data.  But, for simplicity, it is summarized here as well.  A total set of control data consists of 10, 8-bit (one byte) ascii characters.  The first character is either an &#039;s&#039;, &#039;d&#039;, or &#039;p&#039;.  An &#039;s&#039; implies that the user simply wants to set a motor speed to some value; a &#039;p&#039; tells the PIC that the user wants to control speed and position of the motor i.e. step this fast for this many degrees; and a &#039;d&#039; tells the motor to stop right where it is.  The second byte is either an ascii &#039;1&#039; or &#039;0&#039;.  This byte sets the motor direction.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-deletedline diff-side-deleted&quot;&gt;&lt;div&gt;Where possible, make it a single piece of well-commented cut-and-pastable code, or at least make each function that way, so others can easily copy it.  Most comments should be in the code itself; outside the code (on the wiki) should only be explanatory comments that are too cumbersome to include in the code.&lt;/div&gt;&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-added&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>JarvisSchultz</name></author>
	</entry>
</feed>