How to control Pleo wirelessly using Wii nunchuck
This article describes the hack allowing you to control Pleo toy dinosaur with Wii Nunchuck. The video below shows the final result:
As you can see the proposed hack allows you to control head, tail and make basic movements. Further in this article you will see how to adjust Pleo’s response to joystick commands.
As you might expect I’m not responsible for any damage you’re about to make to your toy, electronic components or any other property. I’m just sharing my experience and by following the instructions below you take full responsibility for whatever you’re doing. I also assume that you have appropriate level of experience in electronics, programming and having fun, otherwise please talk to an expert and ask for advice. Good luck and it is all your fault!
Get the parts
For this project we will need the following parts:
- 2x XBee RF modems. There is a variety of these, so you can choose the one that fits your needs best. I used the cheapest ones available from sparkfun electronics: for Pleo’s side and for the nunchuck side. If you don’t care about power consumption and need better range you can pick up something different with up to 5mi range. Just make sure the two modems you’re about to buy are compatible with each other.
- 1x 3.3V Arduino Pro board that will decode nunchuck signals and turn them into Pleo commands
- 1x XBee breakout board is not necessary but will greatly simplify your life
- 1x Altoids box or similar project case
- 1x Molex connector housing to connect XBee to Pleo. I would actually recommend getting 2-3 of those Some people solder wires to Pleo directly.
- At least 4x 1.25mm connectors For the Pleo connector. I’d recommend actually getting 20-30 of those.
- 1x switch to turn the Arduino on/off. Anything of suitable size from RadioShack is good
- 1x 9V battery
- 1x 9V battery connector (get it from RAdioShack or make from old 9V battery)
- 1x RP-SMA antenna for the XBee (if you chose to get RPSMA version)
- 2x low power LEDs for mode indicators
- 2x XBee headers
- Some straight F hreaders and angle M headers will make your life easier
- Wires, solder, soldering iron, heat shrink and other standard project stuff
- 1x XBee Explorer USB is required, 2x are recommended for programming and debugging your XBees.
Pleo was originally designed to be completely autonomous. So when you turn it on it will start moving instantly which doesn’t fit our plans perfectly. It would be more handy if Pleo is static until we order it to move, couldn’t it be? In order to stun it I created a really dumb skit that does nothing. You can download it from here, extract it to an SD card and put that card into Pleo’s SD slot. This will make it stand still.
Access Pleo’s service port
Pleo’s service port providing serial interface access to Pleo’s internals is located under a small plastic stub at Pleo’s bottom. I explained how to get rid of it here (See step 1).
Assemble Pleo’s connector
explained here (See step 2)
First let’s configure XBees. The tricky part here is that Pleo’s serial port uses 115200 bps baud rate while Arduino can’t do more then 19200 (Actually 9600 is much safer). Insert each XBee connecter into its XBee USB adapter, connect the USB adapters to to your computer and run two instances of program called X-CTU. Use this user manual to configure the XBees. If you find it confusing (I did!) just do the following:
- On the “PC Settings” page select 9600 8N1 No Flow control for both XBees
- Select appropriate serial ports to connect the two X-CTU programs to DIFFERENT XBees. Test Hit/Query button and make sure both programs can communicate with the XBees
- Go to Modem configuration page in both programs and hit “Read” button
- Check “Always update firmware” checkboxes
- Make the follwoing modifications to the XBee with RP-SMA connector (we will be calling it coordinator):
- In function Set drop down select ZNET 2.5 COORDINATOR AT
- Change “ID – Pan ID” to something random
- Change “NI – Node identifier” to something meaningfully random (like “Coordinator123″)
- Change “SE – Source Endpoint” to something meaningfully random (like “A1″)
- Change “DE – DestinationEndpoint” to the same value as SE
- Change “DH – Destination Address High” to router’s “SH – Serial Number High” value
- Change “DL – Destination Address Low” to router’s “SL – Serial Number Low” value
- Make the follwoing modifications to the XBee with built-in antenna (we will be calling it router):
- In function Set drop down select ZNET 2.5 ROUTER/END DEVICE AT
- Change “ID – Pan ID” to the same value as coordinator’s ID
- Change “NI – Node identifier” to something meaningfully random (like “Node1234″)
- Change “SE – Source Endpoint” to coordinator’s SE
- Change “DE – DestinationEndpoint” to coordinator’s DE (which should be the same as SE, right?)
- Change “BD – Baud Rate” to “7-115200″
- Hit “Write” buttons in each X-CTU’s instance
- In the router’s X-CTU change the Baud rate in PC Settings to 115200, hit Test/Query to verify that X-CTU is capable fo communicating with the XBee using the new baud rate
- Test everything. Go to terminal page in each X-CTU and type something in the terminal window. Whatever you type in one window should appear in another and vice verse.
Now cut XBee breakout board in two halves so each half has its own sets of holes. Solder XBee headers to each half. You will use the remaining holes to connect XBees to Pleo and to Arduino. Here is the mapping for Pleo:
- Pin 1 on Pleo’s 7-pin connector goes to pin 10 on XBee
- Pin 3 on Pleo’s side goes to pin 3 on XBee side
- Pin 2 on Pleo’s side goes to pin 2 on XBee side
- Pin 1 on Pleo’s side goes to pin 1 on XBee side
The resulting connector is shown on the picture.
Please pay attention to the fact that Pleo is very RF-noisy. That means you want to keep the wires in the connector you just built short and well shielded. Wrap the wires with an aluminum foil (get some from a candy, not shown on the picture) without shortcutting the contacts.
XBee on Arduino’s side is connected to 6-pin serial connector available on the left side of Arduino. Here is the mapping:
- Pin GND on Arduino’s 6-pin connector goes to pin 10 on XBee side
- Pin 3.3V on Arduino’s side goes to pin 1 on XBee side
- Pin RX-I on Arduino’s side goes to pin 2 on XBee side
- Pin TX-I on Arduino’s side goes to pin 3 on XBee side
If you’re looking at XBee from top (where antenna is mounted) pin #1 is the one in the top-left corner.
Make Nunchuck connector
Wii nunchuck is using a proprietary connector I still unable to find part number for. So you can’t get it in the store and here are a few options you have to attach nunchuck to Arduino:
- Cut the nunchuck wire, expose the wires and solder them to Arduino directly. This way you won’t be able to use your nunchuck with Wii again. A bit better solution is not soldering to Arduino, but to some connector. This way you can use the opposite genter connectors for connecting the nunchuck either to Arduino or to the rest of the wire with the connector.
- Use a “Wiichuck”. This method badly works for this project’s enclosure, but you can design a better case instead of Altoids box.
- Use an old ISA board, floppy drive connector or similar type of old-fasioned boards to make your own connector (like I did in thisproject). Just cut out a piece of PCB that has 3 connectors on one side and 2-3 connectors on the other, check if it matches the contacts in nunchuck’s connector and solder wires to it. Optionally you can fix the wires with a glue gun.
- Surpisingly FireWire (IEEE1394) connector fits the contacts. For instance you can insert regular firewire cable into wiimote. Some work is required to make itperfect fit too.
- Possibly the best solution is buying an extension cable for wiimote and getting the connector from it. You can get one for about $6 with free shipping.
Now turn the nunchuck connector so the side with 3 connectors faces up (see the picture) and connect the wires to Arduino as the following:
- Contact 1 on Nunchuck’s side goes to pin 3 on Arduino
- Contact 3 on Nunchuck’s side goes to pin 4 on Arduino
- Contact 4 on Nunchuck’s side goes to pin 5 on Arduino
- Contact 5 on Nunchuck’s side goes to pin 2 on Arduino
- Yes, contact #2 on Nunchuck’s side hangs free
Connect the LEDs
The last (andoptional) connections you need to make are from Arduino to LED’s. I used two leds: red and green to indicate the current state of the system. Green LED is lit when arduino is power on. Red LED islit when the system is waiting for connection with Pleo to be established. When the system is ready only the green LED should be on and red LED should be blinking every 2 seconds indicationg that data from nunchuck is being read. So get your two 3V LEDs, find their polarity and connect as described below:
- Connect negative leads from both LEDs to GND pin on Arduino
- Connect green LED positive lead to pin 13
- Red LED’s positive lead goes to pin 12
Now it’s time to program Arduino. Get the Arduino software. Temporarily disconnect the Arduino XBee connector from the Xbee and connect it to the serial port using any method you know.
If you don’t have serial/com port one of these USB-to-RS232 adapters will give you the port.
The serial interface you get with RS232 port isn’t the one Arduino uses, so you need a TTL-RS232 converter like this one.
You can use these connectors to connect Arduino to the RS232 adapter: http://www.sparkfun.com/commerce/product_info.php?products_id=8430
Once you hooked up Arduino to your computer use the ARduino software to load this program to your board. Refer to Arduino documentation for additional information if you have trouble programming the board.
If you’re curious you might want to take a look at the code. Couple defines in the beginning of the code actually define what Pleo should do when you press different buttons on the nunchuck. You can change that to whatever you want.
Once you have successfully loaded the program to the board (two lit LEDs will indicate that) you are ready to test.
Now turn the altoids box on. Both LEDs should lit instantly. If they don’t turn off the device you have just made asap, check all connections, battery voltage, contacts, wires and other electronics.
If just the green LED is lit reflash your arduino once more. Keep relfashing and checking connections until both LEDs are lit.
Once you have both LEDs on it’s time to connect the XBee to Pleo, insert the SD card and turn Pleo on. It will take 10-20 seconds for red LED to go off. When only green LED is lit Pleo’s mind and body is under your total control, master.
If Pleo is controllable only for a few seconds/minutes and then freezes pay attention to your Pleo-XBee connector. The wires should be short and well shielded. Otherwise Pleo get’s too much noise on its serial interface and after awhile it will eventually decide to stop accepting commands.
Looks like that’s it. If you have any questions please do not hesitate to ask them here.
PS. If you enjoyed this project but want more – check the routerbot.
16 Responses to “How to control Pleo wirelessly using Wii nunchuck”
Leave a Reply
You must be logged in to post a comment.