Remote control with 2.4GHz PS2 controller

In the book "Bauen, erleben, begreifen: fischertechnik®-Roboter mit Arduino" a small steerable car, the "Flitzer", is described. The book also provides some control methods. Including an infrared remote control and a so-called "nunchuk" controller.

This article about the PS2 controller was also published (in German language) in issue 4 of 2020 of the ft:pedia; a very interesting online magazine about technology in combination with the construction material fischertechnik.

Video : permission for cookies required
PS2 Controller

A wireless control console

The first generation of game consoles, such as the Sony PlayStation 2, did not yet have wireless controllers. Nowadays wireless game consoles are for sale at various robot shops and online stores [1] of which the receiver module can be plugged into the front of the (classic version 2) PlayStation. For around € 20, you get a transmitter with two joysticks and fifteen extra function buttons. If you are willing to wait a few weeks, you can also get the controller directly from China for less than half of that price.

The console transmits its signal in the 2.4GHz RF frequency band and the signals sent from the controller come digitally from the supplied receiver module according to the specifications up to 10 meters away. This of course makes it attractive to investigate whether such a gamepad could serve as a cheap, highly functional remote control for fischertechnik models!

What is special is that the interface is bidirectional. Both the interface and the gamepad are therefore both transmitter and receiver. So there is also a data flow from the Arduino back to the controller for driving two small motors in the controller that can give feedback by vibration. Very interesting for, for example, indicating the gripping or turning limits of robots, possible obstacles in the path of a controllable vehicle or, as I have now realized for the 'Flitzer' as an experiment, giving tangible feedback during braking. a vehicle.

The controller does feel a bit more toy-like than the actual Sony PlayStation controllers. But that is of course also to be expected at this price. My model did not include a manual, but a manual, probably translated from Chinese, could be found online. Fortunately, it soon became clear that more people have been tinkering with it.

The hardware

The various signals are located on the connector of the receiver module. The supply voltage may be between 3.3 and 5 volts on Vcc and Gnd. The communication is driven by the CLK (Clock) with the protocol being led by Attn (Attention). The Ack (Acknowledge) shows only a short pulse after each series of bytes sent and received and probably only used to be useful in the wired variant of these controllers in the past. On the "Vibr" (Vibrate) output, an original PlayStation supplied the (7.6 to 9V) voltage to drive the feedback motors in the (wired) controller. Obviously, this is no longer applicable because the wireless controller itself is powered by two AAA batteries.

The communication protocol is full duplex and is similar to SPI. With "Data" the controller data is read in bursts of several bytes. At the same time, the communication flows from the interface back to the game pad via CMD (Command). This data stream is probably only necessary for the status information towards the gamepad and the control of the vibration motors.

PS2 Connector
Flitzer PS2 Remote

Connecting it to the motor shield

The receiver module is connected to the digital inputs / outputs 10 to 13. A supply voltage of 5V does not cause any problems, but because a classic PlayStation2 only measured 3.4V, I stayed on the safe side and used the 3.3V output of the motor shield to power it.

For those who built the "Flitzer" from the book, the wiring up will be familiair. The only addition is that I wanted to control the red rear lights from a motor output to handle multiple light intensities. This makes it possible to have normal rear lights while driving, but make them light up brighter when braking (slowing down). The accompanying Arduino Sketch now supports this functionality. [5]

Feedback through vibration

I had to open my controller because the on/off switch was sometimes not working properly. After neatly tinning the connections around the battery compartment and the switch, everything worked flawlessly. Because I had the controller open, I was given a view of the interior. Clearly visible in the handles are the two vibration motors. The small motor on the right is on or off, the motor on the right with a slightly larger counterweight is steplessly adjustable. Both engines can of course be started for extra effect. With a test Sketch, the control and operation thereof could be properly studied. [5]

PS2 rumble motorPS2 rumble motorPS2 rumble motor

The regular push buttons can be read out pressure-sensitive, if desired. Although not very precise, they can return an analogous value depending on the applied compressive force. The controller has, according to the description, two modes. It is also possible to read only binary values. Perhaps this is a holdover from the early days of the PlayStation 2 when the games were less advanced. When using the aforementioned PS2 library, the full analog mode is activated by default, in which a value between 0 and 255 can be read from the joysticks and the twelve function buttons are pressure-sensitive if desired.

The connection between the gamepad and the receiver was established quickly and reliably. It made little difference whether the game controller was turned on first or whether I turned on the "Flitzer".

PS2 detailPS2 detail

After some time of inactivity, the gamepad turns itself off. According to the manual found, this would be after one minute. However, my controller only turned off after five minutes. Afterwards, automatically reconnecting the controller to the interface by pressing the "start" button on the gamepad did not work (with the current software library). But this was not a problem for me (yet), because in practice this time-out will not be reached quickly when operating a model under normal conditions.

Should this be necessary in the future, a solution can always be devised whereby the receiver interface (which initiates the reconnection) is restarted from the software in the event of no communication. However, the current library does not seem to offer such a software reset or reconnect. A simple hardware work-around could be an interruption of the receiver's 3.3v supply voltage. For this purpose it could be considered to supply the receiver via one of the free motor outputs of the motor shield. It seems sensible to limit the Vcc input voltage (e.g. with a zener) to 3.3v. However, also because it was not a problem for me, I have not experimented further with this.

The software

Fortunately, more people have been experimenting with such a PS2 controller [2] [3] and there is also already a library for the Arduino [4]. Although not included in the Arduino IDE's library management, it is easy to add.

In the accompanying Sketch [6] I made the above mentioned extension for brighter brake lights. I also did an experiment with the control of the vibration motors to give the console tactile feedback in the controller while slowing down (braking) the "Flitzer". This behavior can now be switched on and off with the button with the pink square. The lighting (front and rear) is switched on with the button with the red circle, and the button with the green triangle switches on the emergency lighting.

The speed and direction of the cart can be controlled with the left joystick. When slowing down (braking), the brake lights illuminate for one second. The right joystick takes care of steering with the servo.

As already mentioned, the PS2 controller can be powered by two (rechargeable) AAA batteries. I use a rechargeable 9V block battery to power my model. This solution is small and light. Because the polarity when switching on is important, I made a small "touch". The power supply can only be switched on in one way due to a small plexiglass sawn buffer. The PS2 receiver module is pressed onto the battery holder with self-adhesive Velcro.

I made a video of my findings with this wireless gamepad [7]. I can recommend an experiment with this PS2 controller to anyone looking for a reliable and affordable remote control with many expansion options. With two joysticks and no fewer than twelve function buttons for assignable functions, it offers many control options for every Arduino model. The vibration feedback in the controller itself is a nice bonus that can actually be used functionally for some models.

Polarity safe

Sources & Links

  1. Simply search the internet for "wireless PS2 controller" to find various current offers of this "2.4G Wireless Dual Shock PS2 Game Controller". The housing of the controller is available in different colors. There will probably be little difference electronically.
  2. Curious Inventor: Interfacing a PS2 (PlayStation 2) Controller
  3. Bill Porter’s page about the PS2 interface for the Arduino
  4. PS Controller library for Arduino
  5. Arduino Sketch: Test of thee vibration-motors. Ter download vanaf de ft:pedia site
  6. Arduino Sketch: Main program Flitzer. Ter download vanaf de ft:pedia site
  7. Moivie on YouTube