Robotics news, projects and stuff
  • 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.

    Disclaimer

    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 Stunner

    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)

    Configure XBees

    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.

    Connect XBees

    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:

    Pleo-XBee connector

    Pleo-XBee connector

    • 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:

    Nunchuck Connector

    Nunchuck Connector

    • 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

    Box it

    altoidsFinally get a 9V battery and connect it to BATT connector on the Arduino board thru a switch. Done! Your final project box’s content might look like shown on the picture or better.

    Program Arduino

    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.

    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.

    Good Luck!
    Andrey

    PS. If you enjoyed this project but want more – check the routerbot.

    16 Responses to “How to control Pleo wirelessly using Wii nunchuck”

    1. […] Nothing going on? No friends? Chances are you probably have a Pleo and a Wii then. If so, how about rigging up the Pleo for Wii control? The hack isn’t that simple but when you see the video after the jump, you’re going to […]

    2. […] wrote in to show us how he hacked his Pleo to be controlled by a Wii Nunchuck. He has installed Xbee units for the communication as well as written a “skit” that […]

    3. […] too busy being hacked to worry about IP.  Modder Andrey has developed a system which allows him to remotely-control his Pleo via a Wii Nunchuck, with the head, tail and basic movements all mapped to the Nintendo […]

    4. […] Read | Permalink | Email this | Comments addthis_url = ‘http%3A%2F%2Fgadget.indoweblog.com%2Fvideo-surviving-pleo-loses-remaining-autonomy-gets-controlled-by-wii-nunchuk%2F’; addthis_title = ‘Video%3A+surviving+Pleo+loses+remaining+autonomy%2C+gets+controlled+by+Wii+Nunchuk’; addthis_pub = ”; […]

    5. Alan says:

      Hey Andrey,

      Thanks for posting this writeup, it’s very helpful. As a first step, I am trying to connect pleo directly to a PC via pleo’s serial interface and the PC’s 9-pin COM port.
      The way I understand it, the pins should be connected like this:
      Pleo pin 1 – DSUB pin 5 (GND)
      Pleo pin 3 – DSUB pin 3 (RX – TX)
      Pleo pin 4 – DSUB pin 2 (TX – RX)
      That configuration does not work, but if I swap the RX/TX pins, garbage comes out. Is there anything you can think of that would cause the garbage, or is there something I’m doing wrong?

    6. Alan,

      Try changing the baud rate. Pleo speaks @115200 8N1.

      Andrey

    7. Alan says:

      Thanks for the quick reply. Unfortunately it’s the same result, no matter what baud rate I tried (9600, 38400, and 115200, all 8N1). I forgot to mention that I am able to use the USB “serial” connection just fine, but I do eventually want to move to using an XBee or bluetooth as you describe, so I will need to use Pleo’s serial port. Do you think I should just bite the bullet and go wireless? Will it work?

      • Alan,

        From my experience if wired connection isn’t working then wireless connection has even smaller chance to work. So I’d propose to fix the wired connection first.
        Does the type of garbage change when you change the baud rate?

        I would propose to double-check the following:
        1. The Pleo connector pinout. It is somewhat confusing and you need to make sure that you’re counting the contacts from the proper side of the connector (compare it to the photo).
        2. In the pinout you sent I don’t see VCC. Did you connect it? There should be 4 wires going from Pleo, not 3.
        3. Check that your RS-232 adapter is working correctly. The output from Pleo is TTL, not RS-232, so you need a special adapter to convert Pleo’s signal. The devices I used (namely XBee and the Bluetooth adapter) already have TTL input, but your computer most probably doesn’t. So you need something like this. Please make sure you’re using adapter, otherwise you can just fry Pleo’s serial interface. Make sure the adapter is working properly by connecting it to some other device.
        4. Turn off flow control on the PC side and on the adapter.

        Let me know if nothing from the list above is working and I’ll think again.

        Andrey

    8. Alan says:

      Ah, I didn’t realize it was a TTL interface. Documentation on this sort of thing is scarce at the moment. Thank you for the excellent help, and I’ll come back and post when I get it working (assuming I didn’t already fry the interface).
      – Alan

    9. da best. Keep it going! Thank you

    10. […] wrote in to show us how he hacked his Pleo to be controlled by a Wii Nunchuck. He has installed Xbee units for the communication as well as written a “skit” that […]

    Leave a Reply

    You must be logged in to post a comment.