Monday, March 5, 2012

Helicopter Auto Pilot - Decoding Helicopter Protocols



Back to 
Helicopter Auto Pilot - Introduction
Download source code & runtimes: Heli Control


Decoding Helicopter Protocols
For deciphering and decoding the specific protocols for each helicopter I used a tool called the USB IR Toy from Dangerous Prototypes: http://dangerousprototypes.com/docs/USB_Infrared_Toy version 1. It allows you to receive and send infrared signals. Although the emitter in version 1 was not strong enough to cover a big area.

I also used my program IR_HeliAutoPilot.exe that communicates with the IR Toy and helps decode the signals. This program was written in C# using Visual Studio 2005 and it's in the folder HeliComm. The subfolder hcomm has some of the definitions (.hcomm files) and trials I've made for different models.

This video explains the process of discovering the protocol, if you have questions you can post them in the comments section here:



Scripting the protocol
Once you know the details of the protocol the helicopter uses it can be scripted into the program and saved as an .hcomm file. That entails entering the different pulse lengths in microseconds in the IR Protocol tab and scripting the variables in the Heli Protocol and Script tabs.

(WORK IN PROGRESS, will expand later)

16 comments:

MrMobileWill said...

Hi, thanks for posting your program. I am working with it now to decode IR form a cheap helicopter called BlackGhost. It is different than yours but similar. I had a hard time getting your program to run and had to recompile but had to edit some files to get it to compile in VS 2010. Any chance there is a way I can contact you?

Thanks

TechMind said...

Hi MrMobileWill

I'm sorry I didn't reply to you sooner. I just noticed your comment today.
If you have any questions I believe the best would be to discuss them here so that others can benefit and participate as well.

Please tell me what kind of difficulties are you having? Maybe I can help you.

TechMind said...

I posted a new version for Visual C# 2010.

Dylan said...

Thanks so much for this tutorial and software. Oh i should probably note that the usb toy has to be on firmware pre v20 (ie v11, v9) I don't really know how to change your code to use the new firmware, but if anyone is reading this know that you'll need to downgrade to v11 of the firmware

Honestly I don't believe it. I was able to capture and decode the packets, and then i was even able to figure out your protocol definition box. I really didn't think i'd get that one, but delving in to the code i was able to figure it all out. I'm not sure i understood each of your commands, and i had to create my own (percentage magnitude (abs of percent), and percent sign (pos/neg)) i needed those for my definition. (there is probably a way to do it with your existing calls. Not really sure about MSB and all of the options.

The best thing about the whole process. I Figured out my checksum..... I can't believe i was able to decode that. So now i have a functioning defintion for my helicopter. Now if only i could get the headphone/soundcard to work via the iphone dongle that came with my helicopter, and then to port it to android.

TechMind said...

Dylan

Thanks for the information about the USB IR Toy v2.0. Is good to know.

I'm impressed with how much you've been able to accomplish with the scant information I provided. In fact I didn't document at all how to setup the protocol because I didn't know if anyone was interested.

If you have specific questions please don't hesitate to ask, I'll gladly respond.

For the iphone dongle I don't own one so I can't test it but it may well work right away if you plug the dongle to your computer and select the Sound Card option & Signal Generator option. If it doesn't it maybe because the dongle receives in the left channel a constant tone which maybe necessary for it to work. In that case a small change in the program would be necessary to make it work.

If you send me the protocol that you defined I can tell you how it could've been implemented using the current functionality and the script option.

Pieter Els said...

Hallo,
Thank you for this Blog. I do enjoy your work! I have got the IR Toy V1 that I bought hopping to use it to control my home entertainment system. I have been trying to write my own program to control ever thing. My biggest problem is to decode the remotes protocol, the software you wrote to decode the Heli is exactly what I was try to do. I am able to decode the remotes protocol but when I am sending it, it’s not working. I can see the IR Toy is transmitting it but nothing happens. I have a couple of questions.
Will it be possible to do this with the IR Toy?
Can you please explain to me how the End Pause (milliseconds) works?
Should I change the Carrier Frequency and Duty Cycle for the remotes?
When I send the IR Stream what should the Pre: and Post: be?
Thank You!
Pieter

TechMind said...

Hi Pieter
Yes, the IR Toy is capable of controlling your entertainment system but there is a problem, Version 1 can only do it from short distance because the IR led transmits with very low power. Version 2 is more powerful and it also has a connection to add your own amplifier.
As an alternative you could build a circuit that connects to the headphone port on the computer. The design is here:
http://technologyonmymind.blogspot.com/2012/03/helicopter-auto-pilot-infrared-emitter.html

Can you please explain to me how the End Pause (milliseconds) works?
When you select the option Read Frames any pause longer than End Pause is considered the end of the frame. For example my TV remote every time a button is pressed repeats the same information three times with a 26 milliseconds pause between them. If the value of End Pause is longer than 26 milliseconds then the three parts will be considered one frame but if it's less than 26 then only one set of data would show.

Should I change the Carrier Frequency and Duty Cycle for the remotes?
Nominally the carrier frequency should be 36000, 37000 or 38000 depending on the brand. In reality there is a lot of leeway and even 32000 could be alright (I tested with my circuit), although the closer to the right value the better the reception.

When I send the IR Stream what should the Pre: and Post: be?

When using the IR Toy Pre should always be 03 and Post FF FF, those are the codes to initiate and finish transmission.

I hope this helps.
Cheers

Anonymous said...

Hi, thanks for creating this wonderful post. could i decode the signal using a arduino uno instead of the usb ir toy tool?

TechMind said...

Hi Anonymous
Thanks for appreciating my post.

I've never worked with Arduino but conceivable it should be possible if you can transmit the pulse durations (on & off) using USB protocol as a pair of bytes per pulse.

Anonymous said...

thanks for reply. i am just getting to know about rc stuff. i would like to know whether i could use a syma 107 arduino code with a 3.5 channel modelart helicopter which i got off the internet? and could u pls give me a step by step tutorial on how to control a ir helicopter using kinect and arduino or how i could use my decoded ir signal with devices such as a laptop, controllers etc.with arduino and i would really appreciate a tutorial on decoding the ir protocol with arduino uno. tnx

TechMind said...

Sorry, I cannot help you with the arduino (or kinect) stuff because I don't own one and I know little about it.

I could create the definition for the Syma 107 from the protocol decoded somewhere in the internet, although I have no way to test it. You would need to do that, for that you would need to build the IR transmitter that connects to the speaker port on your laptop.

The design for the circuit is here:
http://technologyonmymind.blogspot.com/2012/03/helicopter-auto-pilot-infrared-emitter.html

Let me know when you have it and I'll send you a definition you can use to test with your Syma 107.

Anonymous said...

sorry for bothering u every time but i think u did not understand what i was saying. i have a modelart 3.5 channel helicopter not a syma 107. i was thinking whether i could use the syma 107 ir protocol with my helicopter

TechMind said...

I don't know.
The only way to know would be to test the protocol with a couple of frames. That way you wouldn't need to create the whole protocol and then have it not work. Just buy entering one or two frames from the protocol we could tell if it works or not.

TechMind said...

I have three other protocols that you could test as well:
- Falcon X
- SJ
- Z008

One of them may work for the modelart.

Anonymous said...

tnx. could u pls give all the three other protocols in pdf format or the link to those protocols for testing. tnx

TechMind said...

All the protocols are in the link at the top that says "Download source code & runtimes: Heli Control"

Look in the folder HeliComm/hcomm