Jump to the content

On this page:

A little Arduino-project, control a simple small toy RC helicopter using the Wii Nunchuck remote.

Page navigation:

Tools


Introducing: the WiicooZ

I have a Silverlit PicooZ RC helicopter toy ↑. I have a Wii, which has a motion-sensitive controller. I have an Arduino-board ↑, a AVR ATMega168-based micro-controller development board. And I had an idea: why not use them together, and control the helicopter with the Wii controller?

I've implemented the idea, and call it WiicooZ :)

Implementation - hardware

WiicooZThe controller 

It turned out, connecting the nunchuck-part of the Wii controller to the arduino-board is really easy with the Nunchuck adapter ↑. Just plug it in! Using the accompanying library getting the data from the nunchuck is simply a breeze.

The transmitter 

I stripped the IR-led from an old TV-remote, and hooked it up to the arduino with a 220Ω resistor. This worked, but the range was limited to a few meters. Not very practical for a helicopter. I've tried using shorter pulses with more power, up to 200mA, but the range was too limited. Perhaps the IR-led had simply the wrong wavelength, or it just wasn't powerful enough. And, it was just one led, not three as the original remote.

Luckily, the IR-leds on the original remote were mounted on a module, including resistors, which was easily detached from the RC. With a oscilloscope I measured the module was driven using ~5V power. Since the arduino runs on 5V, this was also easy.

But the IR-leds draw way too much current for the ATMega168 chip, which has a maximum of 20mA per pin. And I guess even a normal transistor wouldn't cut it, I used a IRF540 mosfet ↑ which is more than adequate for the job. Hooking things up is easy: arduino pin 9 on the gate, the kathode of the IR-LED module on the drain, ground on source, and anode of the LED's on the +5V line.

Implementation - software

The nunchuck

The nunchuck_func.h is a simple library for getting the values of the nunchuck. It's simple. Really. Just look at the code. :)

The protocol

The remote uses a special protocol to send throttle, rudder and trim-data to the helicopter. To detect data corruption, the data is secured with a checksum. Since there's no official information, one has to reverse-engineer it... Lucky for me Andrew McCubbin ↑ already did this for the PicooZ helicopters. All I had to do was to convert it to C - I'm no fan of assembly, and the atmega168 has room enough for compiled C-code.

The transmission

The signal is send using an infrared (duh) carrier, modulated using simple on/off AM on a 38kHz carrier. The ATMega is fast enough to do the modulation complete in software, but it's much nicer to use the built-in frequency-correct PWM feature for this. I used the 16-bit TIMER1 in fast PWM-mode. This isn't standard Arduino-language, but since the Arduino SDK is based on the AVR LIBC library, this is also easy. After the timer is set it's only just a matter of "connecting" and "disconnecting" the output-pin (pin 9) to the PWM-output, to send the carrier wave.

Increasing resolution

The resolution of the signals is quite low: 4 bits for throttle, and only 3 bits for the full range rudder from left to right, while the resolution of the nunchuck is much higher. By applying dithering ↑, the perceived resolution of the signal can be increased. The code uses simple error diffusion ↑ for this, and it is quite effective. The controls feel much more detailed, especially the throttle. The downside is that the helicopter seems to stutter a bit sometimes. If this bothers you, you can disable error diffusion in the code.

Combining things

Then combine all the bits. The setup initializes the output-pins, the nunchuck, and the PWM for the carrier wave. After initialization, the joystick of the nunchuck is calibrated, and the calibration data stored.

The loop reads out the nunchuck, applies the error diffusion, converts the ranges to the ranges suitable for the helicopter, and transmits the data.

Download and Usage

Download the WiicooZ v1.2 sketch for Arduino ↑.

Hook up the arduino with the mosfet, IR-led module and the nunchuck. Then connect a power supply, switch on the helicopter, and grab the nunchuck!

Controls:

  • Z-button: dead man's switch: keep pressed to fly. Release it, and the helicopter stops immediately, thus drops out of the sky :)
  • Nunchuck up/down: throttle.
  • Nunchuck joystick left/right: rudder.
  • C-button + joystick left/right: trim left/right.

What's new?

  • v1.2 20120405 Arduino v1.0 compatibility.
  • v1.1 20090718 added dithering using error diffusion.
  • v1.0 20090715 original release.

Loose ends

This software is written for the 2-channel PicooZ helicopters. The 3-channel version has a "boost"-feature. I believe this is enabled by sending throttle-value 1111b (15).

This code is written for Arduino v1.0. I used a Arduino Diecimila board, some changes (especially to the PWM-setup/pin) for the ATMega32-based boards might be required.

Look at the photo above (or the full size version ↑) and you'll see the IR-leds shining!

Possible improvements

The IR-leds draw quite a lot current. With today's switching power supplies this can cause spikes in the voltage. I don't know how harmful this is, but adding a few hundreds µF worth of capacitors does solve this. Dampening the spike at the source, the switching of the IR-leds, by adding a small capacitor to the gate of the mosfet can also help.

Site Information