--- /dev/null
+[[!meta title="Stepper motor control"]]
+
+Why
+===
+
+When I joined Prof. Yang's group, the [LabVIEW][] software controlling
+the experiment lacked control of the stepper motor which provides
+coarse `z` axis control. This made it difficult to set up the fluid
+cell and meant that leaving the system running unattended for over an
+hour could place unnecessary strain on the `z` piezo (as it would need
+to compensate for thermal drift on its own).
+
+[LabVIEW]: http://www.ni.com/labview/
+
+How
+===
+
+After a staring into the bowels of the [[MultiMode]] AFM and watching
+some of the more suspicious lines on an oscilloscope, I saw that lines
+1, 2, 15, and 16 were the stepper motor drive lines and guessed that
+they were TTL compatible. A short while later (wink), the LabVIEW
+code was up and running. The LabVIEW computer (via a PCI-6052E card
+and BNC-2090 box) writes TTL stepper motor currents to the relevent
+lines on the Nanoscope↔Multimode cable using our break-in box.
+
+ Computer <-> Breakout box <-> MultiMode
+ NanoScope <------^
+
+Part list (outdated commercial parts linked to the current generation):
+
+* LabVIEW 7.1 (in-house software)
+* [PCI-6052E](http://sine.ni.com/nips/cds/view/p/lang/en/nid/2601)
+* [BNC-2090](http://sine.ni.com/nips/cds/view/p/lang/en/nid/1177)
+* Nanoscope IIIa (altered)
+* Homemade break in box
+* [[Multimode II AFM]]
+
+Breakout box
+------------
+
+Build a DB-25 breakout box, such as the ugly hack job shown
+below. This gives us access to the stepper motor drive-lines.
+
+[[!img break_in_box.jpg size="500x"
+ alt="Break in box for Nanoscope-Multimode cable"
+ title="Break in box for Nanoscope-Multimode cable"]]
+
+Control the motor
+-----------------
+
+First, you need something to write to your new motor control lines. We
+are using the digital I/O lines from this [National Instruments][NI]
+PCI-6052E.
+
+Next, you need to send the proper signals down the lines.
+[Prof. Douglas Jones][DJ] has an excellent [stepping motor
+tutorial][tutorial], which explains [how to drive a unipolar stepping
+motor][drive]. For basic operation, you just need something like this
+pseudo-code:
+
+ step( up? ) {
+ static int index=0; // saved between function calls, only initialized once
+ int output[] = {sink 1a, sink 2a, sink 1b, sink 2b}; // the output array
+ if (up? == TRUE) {
+ index = (index + 1) mod 4;
+ } else { // down
+ index = (index - 1) mod 4;
+ }
+ write( output[index] );
+ }
+
+For my Multimode, the motor steps 'Up' when I equate:
+
+<table>
+ <tr><th>DB-25</th><th>Role</th></tr>
+ <tr><td>1</td><td>1a?</td></tr>
+ <tr><td>2</td><td>1b?</td></tr>
+ <tr><td>15</td><td>2a?</td></tr>
+ <tr><td>16</td><td>2b?</td></tr>
+</table>
+
+Problems
+========
+
+The stepper motor, like any other mechanical linkage, can have
+problems with [[backlash]].
+
+Figuring it out
+===============
+
+[[!img multimode_interior_0.jpg size="500x"
+ alt="The interior of the Multimode chassis with the main PCB removed"
+ title="The interior of the Multimode chassis with the main PCB removed"]]
+
+[[!img multimode_main_board_chips.jpg size="500x"
+ alt="The main board of the Multimode"
+ title="The main board of the Multimode"]]
+
+General stepper motor wiring
+----------------------------
+
+If you look back at the MultiMode interior and main board (above), you
+can see that there are wires coming from the stepper motor, going into
+the connector board, and (presumably) ending up at the main MultiMode
+board. Opening up your own MultiMode (until I get some better
+pictures up), you will see that the motor has 6 leads: green, brown,
+black, red, yellow, and orange. A few seconds with your ohm-meter,
+and you'll find the resistances between the leads are either 20 or 40
+ohms. I've recorded the resistances in the following table:
+
+<table>
+ <tr><th></th> <th>Brown</th><th>Green</th><th>Black</th><th>Yellow</th><th>Red</th> <th>Orange</th></tr>
+ <tr><td>Brown</td> <td></td> <td>20</td> <td>40</td> <td>Inf.</td> <td>Inf.</td><td>Inf.</td></tr>
+ <tr><td>Green</td> <td></td> <td></td> <td>20</td> <td>Inf.</td> <td>Inf.</td><td>Inf.</td></tr>
+ <tr><td>Black</td> <td></td> <td></td> <td></td> <td>Inf.</td> <td>Inf.</td><td>Inf.</td></tr>
+ <tr><td>Yellow</td><td></td> <td></td> <td></td> <td></td> <td>20</td> <td>40</td></tr>
+ <tr><td>Red</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>20</td></tr>
+</table>
+
+Browsing through Prof. Jones' tutorial, we see that our motor is
+probably [unipolar][] with a total winding resistance of 40 Ohms on
+each winding.
+
+Looking closely at the stepper motor, you can see (upside down, near
+the right hand screw) that it is labeled `5 V DC`, and `5 V` over a
+`20 Ohm` half-winding gives a current of `I = V/R = 0.25
+Amps`. Following the motor leads back up the the main board (using the
+ohm-meter guess-and-check method :p), we find that they come from the
+DS3658N (chip 1). This chip takes care of all the details of sinking
+the large motor currents given a TTL driving pattern.
+
+WARNING! I strongly suggest you don't do this on your own. The high
+voltage lines for driving the piezo are potentially dangerous,
+
+[NI]: http://www.ni.com/
+[DJ]: http://www.cs.uiowa.edu/~jones/
+[tutorial]: http://www.cs.uiowa.edu/~jones/step/
+[drive]: http://www.cs.uiowa.edu/~jones/step/types.html#unipolar
+[unipolar]: http://www.cs.uiowa.edu/~jones/step/types.html#unipolar