Introduction: Wireless Playstation 2 Xbee Control With Xbee

About: When I was young I took all of my toys apart just to see inside. Eventually I learned how to put them back together.


Note: I started this instructable a long time ago, like nine years, and then put off finishing it until now (oops!) Well, I'm catching up on my to do list and this was something I really wanted to complete. Luckily not all that much has changed and I hope that it may still be relevant and helpful to someone, although there are certainly more modern ways to do the same thing with the newer generation controls. I am happy to say that all the parts I used to originally make this still work, including the remote and RC car and the Arduino Code. Also, some of the links go to old products that have been replaced with newer versions, and some of the links may not work at all by now, but the principles remain the same.

Tom - Oct, 2022


A few years ago I came across a really neat project in an Adafruit blog for a PS2 remote that can be used to control robots, or RC cars, or anything that you can connect a microcontroller and Xbee receiver to. The author, akemp, did include a schematic and code, but being new to Arduinos and Xbees, I needed more info before getting started. I delved into research and eventually found everything I needed to make my own Xbee PS2 remote. This Instructable explains how to turn a Playstation 2 control into a wireless remote, and includes sources for all of the components, assembly drawings, and some sample code.

Of course a remote can't be a remote without something to remote..erize, so I'll also be giving the skinny on how I hacked into a toy RC car so that it could be driven with the PS2 control.

Supplies

Bill of Materials


Playstation 2 Control - If your resourceful and savvy you'll be able to find these for a couple of bucks at pawn shops and garage sales. It's also possible that you have one in storage or know someone who would give you theirs.


1x XBee 1mW Trace Antenna, Series 1 (802.15.4) - 2.4GHz wireless transceivers with a range of roughly 100ft (stronger versions with greater range are available.)

https://www.sparkfun.com/products/11215

1x XBee Pro 1mW Trace Antenna, Series 1 (802.15.4) - Like the Xbee above but with a larger range.

https://www.sparkfun.com/products/11216

Arduino ProMini 328 3.3V/8MHz - A compact Arduino platform, essentially a bare-bones Uno. This needs a FTDI converter for programing (listed in the tools section).

https://www.sparkfun.com/products/11114


Sparkfun Fio V3 - I love these little boards! They have a LiPo charger, they can be plugged right into a USB port to be programmed, and they also have sockets for an XBee, all of my favorite things in one. The Fio isn't actually part of the remote control but is used as a receiver and control board for the RC car.

https://www.sparkfun.com/products/11520


2x Opto-isolator Breakout - The Fio runs at 3.3 volts, but the RC car runs at 9V. If we were to just plug them into each other without some kind of buffer very bad things could happen (the Fio would likely fry.) These opto-isolator breakout boards are used to keep the two electrical systems separate.

https://www.sparkfun.com/products/9118


Lithium Polymer Battery 3.7V 400mAh - Small, light, rechargeable, and packed with delicious electrolytes. Matches with the lipo charger board.

https://www.sparkfun.com/products/10718


USB LiPoly Charger, Single Cell - Charges our LiPo battery via USB mini. This is an "in-circuit" charger, meaning the battery can be charged while all of our electronics are still connected and turned on, making it ideal for permanently installing in projects.

https://www.sparkfun.com/products/10161


2mm 10pin XBee Socket SMD - The pins on the Xbee are closer together than the more common .1" pins (like on a breadboard.) A special header socket is needed, but we only need one since only one side of the XBee is connected.

https://www.sparkfun.com/products/10030


6 pin Female Header - For programming the Pro-Mini. I chose a female header to minimize the amount of exposed metal.

https://www.sparkfun.com/products/11894

Mini On/Off Toggle Switch - http://www.radioshack.com/product/index.jsp?productId=12708883


Small 3mm LED - Attaches to the LiPo charger to indicated when it is charging. I used red because that is what I had on hand, but I do think that yellow and orange are better charge colors.

https://www.sparkfun.com/products/533


Tools & Software

  1. FTDI Basic Breakout 3.3V - FT232RL USB to serial converter, needed to program the Pro Mini. https://www.sparkfun.com/products/9873
  2. XBee USB Adapter - Used to connect the XBee to a computer for configuration and testing. http://www.parallax.com/product/32400
  3. Soldering Iron and soldering supplies
  4. Flush cutters
  5. Rotary Tool with Cutting Disks (Dremel)
  6. Small Screwdriver
  7. Arduino IDE
  8. Mini-USB Cable
  9. Micro-USB Cable

Step 1: How the Transmitter and Receiver Work

Before started actually building the remote, I needed to learn how the thing worked. After a lot of googling and study I got a feel for the remotes operation and figured out what parts I needed.

The PS2 control is essentially a microcontroller with a bunch of switches and sensors attached. Our Pro Mini is programmed to talk to the PS2 to find the value of those buttons and sensors. The Mini then sends that information out as serial data into an XBee, a transmitter that shoots the data out into the air. Later on we'll use another Xbee to pick that transmission out of the aether and put it into yet another microcontroller that is hooked up to the RC car (details can be found in the RC car section.)

For details on the PS2 interfacing check out this info over at curiousinventor http://store.curiousinventor.com/guides/PS2

The Pro Mini board is the equivalent of an Arduino Uno, minus a few functions. Here we use the Mini to interface with the PS2 control, retrieve the states of the buttons, and send that data to the XBee for transmission. The Mini also provides a regulated 3.3V to the XBee.

The receiver that will be attached to the the RC car's motors is comprised of an XBee connected to an Arduino Fio. The Fio is another Arduino compatible board with built in LiPo battery charger and XBee sockets. The Fio receives the button state values and translates it into motor control signal outputs.

Those control signals need to be connected to the RC car's motor driver circuit, but the Fio runs on a 3.7 Volt battery where as the RC car uses a 9 Volt. To get around that minor problem several optoisolators are used to transfer the control signal from the Fio to the RC car circuitry optically, while still keeping the 3.7 Volt and 9 Volt system separated.

Step 2: Construction Begins! Open the Remote

  1. Place the Playstation control face down on a table.
  2. Remove the screws (save these!)
  3. Remove the white,plastic frame that holds the circuit board and the motors by gentling lifting it upward.
  4. Move the face of the control out of the way so you don't accidentally bump the buttons out of place. It's a pain getting them back in.

Step 3: Remove the Motors and Their Supports

We'll need some space to add electronics to the control so the motors gotta go!

  1. Using a pair of flush cutters, clip the two wires leading to each motor. Cut these wires as close to the circuit board as possible, we don't want them hanging loose.
  2. Remove the motors and, with the same set of cutters, snip away the plastic supports that held them. The plastic in my control was surprisingly soft and it was very easy to cut it down.

Step 4: Prep the Control's Cord

To interface with the control's circuitry we need access to the wires inside the cord. The tricky part about this for me was identifying the wires that were inside the cord as I couldn't find a solid standard for them. Curious Inventor's PS2 interface page has a diagram for identifying the wires but my control didn't match exactly. I resorted to using a multimeter to test each pin of the plug to see which wires were attached to which pin.

  1. Cut a path through the white, plastic frame so that the wires can reach the empty, handle part of the control.
  2. CAREFULLY slice through the cord's outer insulation with an exacto blade and peel it away.
  3. Snip away the extra insulation and the white fibers that are twisted within the wires.

Step 5: Trim the LiPo Charger to Fit

In its natural habitat the Sparkfun lipo charger board would not normally take shelter inside something as cramped as the PS2 control. However, in times of crisis this little, red board can shed access body weight and nestle itself quite snugly within the control's crannies.

  1. With a rotary tool and a cutting disk, grind through the board removing anything that isn't part of the circuit. The pictures show were these cuts should be made.
  2. Straight from the factory this lipo board is configured to charge at 500mAh, that's too high for battery small enough to fit inside the control. However, the board's charge rate can be changed to 100 mAh by cutting a pre-existing jumper on the board and soldering a jumper between the center pad and the "100mA" pad to lower the charge rate.

Step 6: Cut Plastic to Make Room for the Charger

With the charger trimmed down to it's bare essentials it can fit just barely inside the control, but to do so a little modification to the plastic frame is needed. With care and finesse the charger will press fit perfectly into the plastic and won't need any glue or screws to stay in place.

  1. Disconnect the circuit board from the frame by gently pulling the flexible ribbon cable free of its connector.
  2. Set the charger on top of the white frame and mark where the cuts need to be with a sharpie.
  3. Flush cut the frame until the body of the charger fits inside, or rather fits as best it can without a hold for the USB plug.
  4. With a sharp x-acto knife*, mark the black shell along the outside of the USB connector. Use the knife to shave away the black plastic until you have a rectangular hole that the USB can fit through.
  5. To test the fit, put the two halves of the shell back together with the charger inside. The outer casing needs to fit together snugly, just as they did before they were modified.

Step 7: Add the Charge Indicator LED

The charger includes an option to add your own LED charge indicator. This LED will light up while the board is connected to a computer (or other power source) via USB cable and the battery is being charged. The light will turn off when the battery is fully charged.

  1. Solder a few short wires to the end of the LED and cover the connections with heat shrink tubing.
  2. Solder the free ends of the wires into the appropriate thru-holes as marked in white on the board.

Step 8: Gently Remove the Flexible Circuit Board

Step 9: Cut the White Plastic for the On/Off Switch

Use an exacto knife to cut notches into the screw posts so that the micro on/off switch fits snugly inside the control. When the case is put back on the switch will not need any glue to stay in place.

Step 10: Electrical Wiring Details

The included diagram shows how to wire up all of the components. One thing that I did that was a bit unusual was to solder wires directly to an Xbee header instead of using a circuit board, this was done to save room inside of the control.

Step 11: Program the Pro-Mini & Configure XBees

To program the Arduino Pro-Mini microcontroller you will need a 3.3V FTDI Basic Board ( I got mine from SparkFun) and a copy of the Arduino IDE software that programs the board, which can be found on the Arduino website.

  1. Download the Arduino code from my Github
  2. Install the PS2X_lib Arduino Library by pasting it into the Arduino libraries folder on your computer.
  3. Open the file PS2_Control_v11.ino with the Arduino IDE.
  4. Under the Tools > Board menu select "Pro Mini 3.3V".
  5. Connect the FTDI Basic to your computer.
  6. Plug the FTDI Basic onto the male headers of the Pro-Mini
  7. Select the corresponding serial port under the Tools > Serial Port
  8. Click the Check Box icon to upload the code

To configure the two Xbees you will need an Xbee USB adapter and a copy of Digi's XCTU software. There are three settings that we need to set: the baud rate, the channel, and the PAN ID (personal area network.) These setting ensure that our two radios can talk to each without interference from other Xbees, and set the speed at which they will communicate.

Plug one of the two Xbees into your computer via a USB cable and the Xbee USB adapter and open up the XTCU software. After configuring the first Xbee, hook up the second and repeat the process.

  1. Click on the "Add Module" button in the upper left of the interface. This will scan for Xbees connected to your computer but, depending on what your Xbee settings currently are, you may need to hunt around by selecting different baud rates. Once found, your Xbee will be represented on the left of the interface.
  2. Clicking on your Xbees icon will read and display the modules settings.
  3. Change the "CH Channel" to a value from 0x0B to 0x1A.
  4. Change the "ID PAN ID" to a value between 0 and 65,535.
  5. Set the "BD Interface Data Rate" to 57,600 (this is the baud rate used by my example code.)
  6. Write the new settings to the Xbee by clicking on the pencil icon.

There are more setting that add a few more layers of authentication and access control but, too be honest, I haven't really played with those yet. You can learn more about XCTU and XBee configuration from this sparkfun tutorial.

Step 12: Putting the Control Back Together

Reassembly the control with the lipo charger underneath its circuit board and stuff the Pro Micro and the Xbee into the empty handle on the right. Add some tape, or thin plastic, or whatever you have on hand in between the Micro and the Xbee to isolate them from one another, you do not want their exposed solder joints to touch each other.

Step 13: Initial Testing and Code Explanation

  1. Connect the second Xbee to the USB adapter and plug it into your computer.
  2. Open the Arduino IDE and select the port that the adapter is connected to.
  3. Open the Serial Monitor and change the baud rate to 57600
  4. You should see a bunch of random symbols on the screen (why these symbols seem random is explained below.)
  5. Press a button or move a joystick on the control and the symbols should change in response. This is a quick way of seeing that the buttons and stick positions are being transmitted and received. Later on we will decode that data.

The codes function is to read the states of the PS2 control's buttons and send them out over the Xbee. The code continuously loops, checks each buttons state, and then constructs this data and sends it as six bytes. Four of these bytes hold the value of the thumb sticks (2 potentiometers per stick, one byte for each pot.) One byte is used for the D-pad and the last holds the remaining button states.

The states of the buttons and the D-pad are mushed together into their respective bytes by using the bitWrite function, which writes the state of a button (0 or 1, high or low) to one bit of a specific byte. In the receiver code, we do the opposite and read the specific bits of the bytes received (the bitRead function.)

The Fio receives this data, decodes it, and sends out control signals based on that data. The code used in this example does not use control's buttons, only the thumbsticks to control the speed of the motors. The Fio sends out pulses that turn the motors on and off quickly. The speed of these pulses is based on the position of the thumbsticks. Pushing the left stick forward causes the left motor to move forward and the further the stick is pushed, the faster the motor will turn. The right stick controls the right motor in the same way.


*Extra Note: Serial.print vs Serial.write

When I got this far in the project I decided to do some testing to see if another Xbee could pick up the data coming from the control. I plugged a second Xbee into the USB and, using the Arduino IDE's serial monitor, read the data as it was received. I expected a series of numbers but instead the monitor was only displaying gibberish, a combination of symbols, numbers, and letters that I could not interpret. However, the gibberish did change when I pressed buttons on the control so I knew that something was being transmitted. I tried changing the baud rate of the monitor but that didn't turn the strange data into anything I understood.

After digging around the code that I had copied and reading the Arduino reference section I discovered why I wasn't able to read what the Xbee was spitting out. The Serial.print function is a often used command that prints out serial data over the Arduino's TX line. It is usually used to send data from the Arduino over USB so that it can be read using the IDE's Serial Monitor. The thing is that this is encoded serial data, as in ASCII encoded. The code used in the PS2 control instead uses the Serial.write function which does something significantly different!

When you use Serial.print to send numbers you don't send a byte that is equal to that number in binary, you send that numbers character code which is then decoded by the serial monitor. For example, if you Serial.print "3" the byte coming out won't be 00000011 (the binary equivalent of three), instead it will be 00110011 (51 in binary.) If you were to look at the ASCII chart linked above you would see that the code for three is 51.

Serial.write, on the other hand, does not encode the data

Step 14: Program Arduino Fio Receiver

To receive the signals from the PS2 control Xbee I used a Sparkfun Fio, which is essentially an Arduino Uno with a built in lipo battery charger and Xbee socket.

  1. Connect the second Xbee to the Arduino Fio and connect it to your computer via USB.
  2. Open the file PS2_Reciever_RCcar_v11.ino with the Arduino IDE.
  3. Select the port with the Fio. Set the board to the Fio as well
  4. Upload the code to the Fio

Next we will take a RC car apart and figure out how to attach the Fio to the car.


Step 15: Modifying Toy RC Cars

I enjoy taking things apart to see how they work so whenever I find any kind of electronics that is headed to the dump I'll tear it open first to have a peak inside. Most of the RC cars that I've run across were the less than $30 dollar variety, and they all had a similar set up. The typical setup is an antenna and receiver circuitry for picking up control signals from the remote control, a microcontroller chip to decode the control signal, and a motor driver circuit to turn the motors.

Here I've removed the the microcontroller and replace it with an Arduino Fio Xbee receiver. This microcontroller will receive signals from the remote and then command the circuitry already in the RC car to control the motors.


It should be noted that not all RC cars are not the same, far from it. I got lucky and the car I had used circuitry that I recognized. I certainly cannot guarantee that it will also be this easy or that a car you open up will be very similar to mine. It is very likely that you will have to track the traces on your circuit board and possibly need to reverse engineer it by drawing a schematic. You may then also need to look up the individual components and look up circuits to figure out what is going on. If it comes down to this remember to be patient and don't be afraid to experiment, preferably with some cheap RC toy that you won't miss if you do break something.


Step 16: Trace the Motor Driver Circuitry

I'm still learning how things work but fortunately I recognized what was going on inside my RC. Like most inexpensive RC toys, my car uses an H-bridge to control it's motor. H-bridges consist of four transistors (or MOSFETs) and, given that they are handling the drive motor current, are usually the largest transistor looking part on the circuit board. Additionally, they pretty much always have some heat sinks attached as driving all that current makes them get seriously hot.

To find which traces of the circuit board are controlling the H-bridge I first examined the PCB and found the traces that connected the H-bridge transistors and the main microcontroller (chances are that the trace will go to a resistor first.)

In this case there are four wires coming from the H-bridge going to the microcontroller on the board. Each of the car's two motors is controlled by two of these wires. One of the wires for forward, the second for reverse. When 9v (the car's working voltage) is applied to one of these wires it turns on its respective motor in either direction.

Step 17: Remove the Car's Brain

I don't know exactly what chip is controlling this RC car, and I don't care. Identifying ICs in commercial products can be difficult sometimes and even if we were to try to find out exactly what the main chip is, chances are it would be a microcontroller with custom code that we don't have access to. It's just easier to rip that sucker out so I can add my own chip with my own code.

The easiest way I've found to remove ICs (if you don't want to save them) is to use wire cutters to clip all of the chip's leads from the top of the circuit board. Then I'll use a spring loaded solder sucker and soldering iron to suck up the loose leads from the bottom of the board. Quick n' crude but it gets the job done.

Step 18: Tap Into the RC's H-bridge

Now that we've removed the IC that was driving the H-bridge we can add some jumper wires to the board. These jumpers need to connect to the traces that go the the bridge. Later we will connecting these wires to our circuitry with a breadboard.

Step 19: Connect the Receiver to the RC

Having tapped into the car's H-bridge we need to connect that to the Arduino Fio. The problem that needs to be solved here is that the H-bridge is expecting a 9 volt signal but the Fio runs at 3.3 volts so we need a way to connect these two circuits despite the voltage differences. There are several ways of doing this but I decided to keep the two circuits completely separate by using optoisolators.

Optoisolators (also called optocouplers) are small 'chips' that contain an LED with photo sensitive transistor. Since the light from the LED turns on the transistor with out actually being electrically connected to it optoisolators can be used to have separate circuits to talk to each other. In this case I use them to connect the 3.3v outputs of the Fio to the 9v inputs of the RC car. The included diagram shows how all of the components are connected to the RC car.

*Extra Note - Optoisolators typically invert the input given to them. That is to say that when the internal LED is turned on it turns off the phototransistor. This can be corrected with code or with hardware. Here I am using a Sparkfun Optoisolator break out board that has built in transistors that remove the inversion.

Here's a video of the whole setup in action:

https://www.youtube.com/watch?v=hDYDej1sk1M

Step 20: Possible Uses and Upgrade Ideas

The goal of this project was to create a way to control my electronic projects using a remote with the functions of a Playstation control. Since the control's signal is received by an Xbee it will be easy to plug it into whatever else I make. As functional and useful as the remote has been for me since building it, there are some things I would like to add to it.

First, battery life is a concern. I've never actually had the remote's battery go dead on me while using it but I've never used it for any long period of time. Next, the remote doesn't have a way to control more than one thing. It would be nice to have some way to address more than one receiver. I would also like to get a bit more range from the device as well.

Of course, its been years since I started this project so by now game console controls have advanced quite a bit. They have their own built in batteries and wireless communication and I imagine there would need to be less hardware modding needed to get one of those to talk to an Arduino.

I learned a lot working on this project, enough to feel confident in building a control completely from scratch. When this one no longer does what I need I'll think about building my own.