Controlling my quadcopter with a PS2 controller

I can now control my quadcopter with a PS2 controller - really cool!  The magic control box is powered either from the Arduino Nano inside and communicates with the quadcopter via radio, or a lipo battery, which is rechargeable over USB.  LEDs on the top feedback about the drone status and look really awesome.

UPDATE: I have now incorporated the control electronics, and a long distance radio module directly into the PS2 controller!

Left:  Previous Quadcopter radio controller.  Right: PS2 controller and PS2 radio transmitter box.

Previously...
Previously I was using a radio controller I had built to control my quadcopter.  The core of the hardware was an Arduino Nano and an nrf24l01 module, along with some 2d thumb joysticks and some mini buttons.  In terms of radio transmission, I sent a 5 byte packet to the quadcopter with a frequency of 250 Hz (the quadcopter loop frequency) and received an ACK data packet in return every so often which is a byte containing flags on the quadcopter status.  It was a bit hacked together (and it looked it), the pitch/roll thumbstick kept coming off and crucially the thumbsticks were rather digital.  By that I mean that although they give an analog voltage that the Arduino Nano reads, in practice the actual stick movement to get a range between the centre and the extremes was very narrow.

I decided I was re-inventing the wheel somewhat here.  After all, haven't major game console manufacturers poured money into developing decent controllers? Other people must have interfaced one with an Arduino before - well, of course they have! And there are libraries available.  In particular I came across the PS2 Arduino library by Bill Porter.

New and improved
I decided to make a box of electronics that I could plug a PS2 controller into and would send commands by the nrf24l01.  I bought a PS2 socket and a small project box, with the PS2 Arduino library it was really simply to interface the PS2 controller and adapt my previous code.  In fact the most difficult thing was cramming everything into the same box.  I also added a single cell LiPo battery with a USB charging module.  Inside the box there's a 5v boost converter to run the Arduino Nano when it's not being plugged into and programmed over USB.

I also added 4 LEDs to the top that report on the PS2 connector status and also light up in various patterns according to the quadcopter status byte that is received - I'm pretty pleased with how it looks when it's talking to the quadcopter!

I decided to leave the radio module on the outside, as long-term I'd like to switch it out with a higher powered radio module with an antennae.  Currently this module runs off the 3.3V pin on the Arduino Nano which can only supply up to 50 mA, however the higher powered radio modules may draw greater than 100 mA at a maximum power.  Therefore I'll add a LD1117 3.3V 800 mA to supply the necessary current.

Useful references

UPDATE: I have now incorporated the control electronics, and a long distance radio module directly into the PS2 controller!





Arduino/PS2 interfacing:

Cool PS2 hacks:
http://www.proofofprinciple.nl/projects/long-range-doubleshock-controller-part-2-of-2/
http://fabioangeletti.altervista.org/blog/playstation-controller-hack-with-arduino-mini-n24l01/?doing_wp_cron=1502831212.9339148998260498046875




Comments

Popular posts from this blog

Arduino and Raspberry Pi serial communciation

Getting started with the Pro Micro Arduino Board