Programming AI with Leaf/Adding to Leaf: the SD84 Servo Controller

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Adding and Running an SD84 Servo Controller from Leaf[edit | edit source]

As is, Leaf has the capability of controlling just two Phidget USB servos. These are typically used to tilt and pan Leaf's camera. Prior to code being added for the SD84 controller, there was no easy solution to adding more servos to a Leaf robot. And if you were to attempt to add articulated arms or legs to your Leaf robot, this would be quite a problem.

The SD84[edit | edit source]

The SD84 is an 84 channel servo controller which can drive up to 84 RC servo's. It can maintain a 20 mS refresh rate. It allows separate control of speed and position of each servo. It sports a USB interface making it fairly easy to hook up.

Devantech, the makers of this servo controller say that "...this a great animatronics controller."

Getting it working on a Windows xP Computer[edit | edit source]

For this article, installation for only the Windows xP computer will be presented.


Installing the Drivers[edit | edit source]

The SD84 module uses a FTDI FT232R USB chip to handle all USB protocols. The drivers must be downloaded and installed.

  1. Download the FTDI (CDM20814_WHQL_Certified 32 bit) USB drivers here:
  1. Unzip and install.

Configuring the SD84 USB Driver Software[edit | edit source]

  1. Plug in the SD84 module to a spare USB port. (A yellow LED will light up.)
  2. Locate the COM port it has been assigned to by right clicking on your "My Computer" desktop icon and select the "Device Manager" tab. Select the "Ports (COM & LPT)" tab. "You should see the USB serial port listed. To change the COM port number--right click on it, select properties, select advanced and select the COM port number from the available list. With Windows XP, select "Start", then right click "My computer", then select "Properties", then the "Device Manager" tab."
  4. Edit the COM port parameters so that it is set up for 115200 baud, 8 data bits, no parity and two stop bits.
  5. Select "OK" as needed to close all of the windows that you opened.
  6. Close the Device Manager window.

Testing the SD84 with the Sample Program[edit | edit source]

  1. At this point you should have connected the SD84 board to a spare USB port on your computer. (A yellow LED will light up showing that it has power.
  2. Plug an RC servo into servo port 1 (the first to the LEFT side of the USB connector.
  3. Connect 5 to 6 VDC to the first terminal block to the LEFT of the USB connector. This is how your servo will be powered. The SD84 only takes its signals from your PC. The power for each set of 4 servos must be separately connected to the SD84 board.
  4. Download the SD84 Demonstration Program from
  1. Launch it.
  2. Set it to the COM port number that you wrote down earlier.
  3. Set the Current Active Channel to "1".
  4. Move the Servo Position widget left and right. Your servo motor shaft should turn as you move the position widget.

Download and Install the Leaf Interface Code[edit | edit source]

  1. From the Leaf site download Alex's latest SD84 zip files and unzip them:

Installing the Rest of the Software[edit | edit source]

  1. Place a single copy of both the SD84.dll and SD84Monitor.exe in the System32 folder (usually c:\Windows\System32) for 32 bit versions of XP, Vista or Windows 7 and in the SysWOW64 folder for 64 bit versions.
  2. Place a Windows shortcut to SD84Monitor.exe on your desktop. You will need to have SD84Monitor.exe running in order to use your SD84 board.
  3. Place a single copy of SD84.ini in Windows folder (usually c:\Windows). The sample .ini file provided is suitable for the test program below, but must be modified to match your own set of hardware interfaces.
  4. Change the comport number in the SD84.ini file to match the port assignment in your computer. You can find this in Device Manager. If the comport is a single digit, you can specify it as shown in the sample SD84.ini file, e.g. “ComPort = COM5”. But, if the port is two digits, specify it like “ComPort = \\.\COM15”.
  5. Launch LispWorks if it is not already running and open Leaf Interfaces.lisp.
  6. Copy all the text from the LispPatch.txt to the Leaf Interfaces.lisp file. A good place to put it is right after the Phidget Servo Interface code.
  7. Save the file.
  8. Compile and load the Leaf Interfaces.lisp file as usual.
  9. Install the "Microsoft Visual C++ 2010 Redistributable Package (x86)":
  1. Test that you can run the SD84 monitor software by launching SD84test.exe which is in the .zip file you downloaded from the Leaf site. (Note: the monitor prgram, SD84Monitor.exe which should be in the System32 folder MUST be running in order to use the SD84 board.)
  1. Insert SD84Initialize in the InitializeSystems() function of the Leaf.lisp file right at the end for the function as shown below. Remember to move the closing right parenthesis from the current text as put it after the addition.

;; SD84 I/O board is installed
   (SD84Initialize "" 1))

Testing the SD84 from Leaf[edit | edit source]

  1. Paste the code below into your Leaf.lisp file just below "Print Hello"
  (format t (concatenate 'string "Hello!  My name is " robot " ~% ~% ~%"))
  (SD84SetRCPosn 1 1000)
  (sleep 2)
  (SD84SetRCPosn 1 2000)
  (sleep 2)
  (SD84SetRCPosn 1 1000)
  (sleep 2)
  (SD84SetRCPosn 1 2000)
  (sleep 2)

  1. Compile and load Leaf.lisp.
  2. if the monitor prgram, SD84Monitor.exe is not running, start it up.)
  3. Launch Leaf "(leaf)" in a Listener window.
  1. And voila! Your servo should rotate back and forth two times.