Programming AI with Leaf/Adding to Leaf: the SD84 Servo Controller
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.
As with most hardware devices, DO NOT CONNECT THE HARDWARE UNTIL SOFTWARE HAS BEEN INSTALLED!
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.
- Download the FTDI (CDM20814_WHQL_Certified 32 bit) USB drivers here:
- Unzip and install.
Configuring the SD84 USB Driver Software[edit | edit source]
- Plug in the SD84 module to a spare USB port. (A yellow LED will light up.)
- 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."
- WRITE DOWN THE PORT NUMBER!
- Edit the COM port parameters so that it is set up for 115200 baud, 8 data bits, no parity and two stop bits.
- Select "OK" as needed to close all of the windows that you opened.
- Close the Device Manager window.
Testing the SD84 with the Sample Program[edit | edit source]
- 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.
- Plug an RC servo into servo port 1 (the first to the LEFT side of the USB connector.
- 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.
- Download the SD84 Demonstration Program from
- Launch it.
- Set it to the COM port number that you wrote down earlier.
- Set the Current Active Channel to "1".
- 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]
- From the Leaf site download Alex's latest SD84 zip files and unzip them:
Installing the Rest of the Software[edit | edit source]
- 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.
- 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.
- 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.
- 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”.
- Launch LispWorks if it is not already running and open Leaf Interfaces.lisp.
- 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.
- Save the file.
- Compile and load the Leaf Interfaces.lisp file as usual.
- Install the "Microsoft Visual C++ 2010 Redistributable Package (x86)":
- 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.)
- 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]
- Paste the code below into your Leaf.lisp file just below "Print Hello"
- 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)
- Compile and load Leaf.lisp.
- if the monitor prgram, SD84Monitor.exe is not running, start it up.)
- Launch Leaf "(leaf)" in a Listener window.
- And voila! Your servo should rotate back and forth two times.