Instructables
Welcome to my 3rd Instructable everyone !

Today we're going to build a 'device' to control a mini-sized helicopter with a Wii Nunchuk.
The helicopter that we're using is a cheap (26$) 3-channel (yaw, throttle, pitch) helicopter that I bought a 1 month back from Dealextreme.com . I can say that it is a VERY durable heli : I have crashed more thant 100 times and it's still working ! It is not radio-controlled, but rather Infrared-controlled, so easier to reverse-engineer. I should also say that in this instructable, the original remote won't be harmed, everything can be done without opening it or even opening the helicopter itself. That means we have nothing to lose :D


In this instructable we're going to take a look at reverse-engineering the Infrared communication with a IR demodulator (very cheap), we'll also learn to use our beloved Arduino as a 1Mhz 'full-featured' logic analyzer. Finally, at the end, there's loads of fun flying the heli around with a nunchuk !

But be warned : as I'm away from home, I won't be able to provide you with a clean PCB to arrange all the components, this is more a quick-and-dirty hack than a real (and finished) project.

Please rate this Instructable ! And also, if you're actually building the thing (or have problems building it), please post a quick comment, I'm always happy to learn I've helped people out !

If you're in, let's go : step 1, the required stuff
 
Remove these adsRemove these ads by Signing Up
cct4246 months ago

i follow the step but found that the code have error.. so what should i do? im using arduino uno...

NickWayne10 months ago
Sweet tutorial! I'm new to all of this so bear with my questions. If I wanted to, would I be able to instead code in to control the heli by my computer via keypress? If so could you please kind of show me what that would look like in the code (throttle, pitch, yaw, trim, the kill switch, and if possible could you show me what a code for 'hover' on keypress would look like)? Also would I just keep the USB connected to run it all or would I have to run a different connection? Thank you for your time!
bgantaume12 months ago
Hi, Thaks a lot!
a1r (author)  bgantaume12 months ago
You're welcome dude ;)
GabrielH1 year ago
I have a Syma S107, do I need to change the Arduino code in any way? I am using Arduino Uno R3 - software 1.0.2.
a1r (author)  GabrielH1 year ago
Yep, at first my code was based on the syma s107 protocol. I don't have the time to make a syma s107 version, but the only thing you need to mod is the send fuction. You can grab the send function for the syma s107 here: http://www.avergottini.com/2011/05/arduino-helicopter-infrared-controller.html
Birdy422 years ago
Hi thx for your tutorial

I can't open run.bat when i click on it it close itself right away
I have the last version of java
Runing on windows 7 64
Try with compaibility xp service pack (1-2-3)
Try to download zip file again

But still nothing

I have no ...

Anyone? thx
gl1tch2 years ago
First many thanks on this instructable, wanted to do something similar and do not even know where to start.

At this very step after i started the capture with OLS which is always aborted with the following error.

"Capture aborted! Duplicate key: 0x30!"

And i do not know how to go from here at all :(
I am using a Arduino Deumilanove and the latest arduino IDE v1, and i get the same error rather i am on Windows or Ubuntu. Any thoughts on why this is happening?
amquad gl1tch2 years ago
Had the same problem Found I needed a new Arduino file

Downloaded at https://github.com/gillham/logic_analyzer

Works fine now. Hope this helps others :-)
gl1tch amquad2 years ago
Nice, thank you that totally solved the problem =)
Gibber82 years ago
Thanks for the inspiration!

I decided to try this with a helicopter that looks identical to yours but the Brand name is Xinxun and the model is X-02. From what I could see, the remote looks identical as well but looks seems to be where the similarity ends.

My remote has a switch next to the right stick labeled I/II. This provides high or low rate for the pitch motor. It also has a button labelled "change" that both changes the "band" of operation as indicated by the three LEDs just above the power indicator, and also turns the LED headlight on the heli on or off.

The IR pulse arrangement is completely different. Mine uses a series of 41 pulses. Each pulse is represented in the IR stream by either high (1) or low (0) (38 kHz off or on) state with a 0 being 450 microseconds long and a 1 being 900 microseconds. There are 6 bits each for throttle, yaw, trim and pitch, 4 unused bits (always 0), 2 bits to encode which "band" the remote and heli are operating on, one bit to send the status of the pitch dual rate switch, one bit to send the status of the change button, and then 9 bits that change depending on the values of the previous 32 bits, sort of like a checksum or encryption key.

This is the part I have not figured out yet. I can duplicate a sequence of pulses that I have captured using the logic analyser and the heli will decode it but I don't know how to code those last 9 bits for any variable pulse stream as generated by the nunchuck inputs. If the last 9 bits are not correctly set the heli just ignores that series of pulses and shuts down.

If anyone else has run into this type of coding and sorted it out please respond back.
a1r (author)  Gibber82 years ago
Can you post a screenshot of the captured IR pulse. I'll see if I can help you.
Gibber8 a1r2 years ago
I have attached a screen shot of the pulse from logic sniffer, captured when throttle = minimum, yaw and pitch = neutral, trim = max left, and hi/lo rate = lo. The pulse reads (000000 000000 011111 000000 000001 000011 01010) Note that I added the spaces to make transcribing easier.

I thing I almost have it figured out. The last bit is always 0 so that leaves 8 bits to decode and it looks like these are a combination of the four variables. I just need to determine if the combination is boolean and if so what (and, or, xor),

Thanks for your time.
Screen Cap.jpg
a1r (author)  Gibber82 years ago
Sorry, I forgot to mention: instructables.com compresses images, so I can't really see the pulse on your screenshot. You could try to send it directly to my email: john.a1rstudios at gmail.com . And, could you include a link to where you bought your heli ?
golaky2 years ago
Thanks a lot ,now the OLS works but nothing append, i follow all your instruction and i tested with an oscilloscope and with another analyzer the pin data of the IR demodulator and i can see an output but not over arduino and OLS.
Bye
a1r (author)  golaky2 years ago
I'm sorry it's not working. Maybe check that the baud rate in the arduino sketch and ols are the same ? Is your other analyzer computer-based ? Can you send me a screenshot of the pulse or even a photo of the analyzer's screen ?
golaky2 years ago
Thanks for the great idea.
I'll try to capture the data but i got allways fro ols programm the following error:
Device type dos not match selected type!......
I'm using arduino mega.
Can you help me?
a1r (author)  golaky2 years ago
Yup, I can help. If you have an Arduino mega, all you need is a Arduino Mega profile. Here it is. Put the file in the [OLS Folder]/plugins directory and restart ols. next, in the capture window, in the "Device type", select the "Arduino Mega Logic Analyzer, and click ok. Voila !
Mic1002 years ago
Bonjour,
I'm French to and my english in not very good !

I've made an Arduino Severino (It is pin-compatible with the Arduino Diecimila) with ATmega 168, i've tested it with processing and it work fine. this pcb has no USB port but a serial RS232 interface.
I've compiled your program under Arduino without the makefile and I uploaded it I run the sniffer but when I start the acquisition, he said device not found my question is is it because my arduino does not have a USB port?

Thank you for this Instructables :)
a1r (author)  Mic1002 years ago
Normalement, ca devrait marcher. En fait, essaye de trouver le port serie auquel est connecte ton arduino (COM1, COM2, un truc comme ca). Et quand tu ouvres la fenetre d'aquisition, selectionne ce port.
Mic100 a1r2 years ago
OK merci je vais faire des essais :)
carlsands2 years ago
well that would make controling the rc helicopter easier
francisroan2 years ago
can we use the accelerometer in the nunchuck?
a1r (author)  francisroan2 years ago
Yes ! In fact, it is already used to control the heli's throttle (up/down). If you don't have a heli, just connect your arduino to your pc and switch on the serial port to 115200 baud, I've included a debug output in the code.

 If you want to control the heli's pitch/yaw with the accelerometer and throttle with the joystick, you have to:

- change some variable names in the heli_funcs.h file :
    - change all the accy occurences with joyy in SetAbsoluteAltitude()
    - change all the joyy occurences with accy in SetPitch()
- remove the accelerometer Y-axis inversion command ( accy = map(accy, 0, 255, 255, 0); )
- call SendCommand(altitude, accx, pitch, pot);

I hope it helped you... Let me know if you have any problems, I always answer ;)
nerd74732 years ago
good use for the wii nunchuck
Hougashucka2 years ago
ever think of adding a camera? so youd see first person on your andriod
a1r (author)  Hougashucka2 years ago
Yup, but that will be part of a bigger project ;)
Can this work with the classic controller? I would really like to know, great mod. =)
a1r (author)  theawesomedude922 years ago
Um, no (not yet). But it is relatively easy to modify the code to work with one. Just search on the arduino forums. Good luck man !