Monday, March 5, 2012

Helicopter Auto Pilot - Introduction

Download source code & runtimes: Heli Control

You may have seen my video on how to control a Helicopter using the computer:



Since many people have shown interest in this little project of mine I wanted to share more in depth information in this blog for those who want to replicate and/or expand on this.

Let's start with a schematic of the solution:

Notice I have two control loops, a manual loop h-w-d-L-i-h:
  • (h)elicopter
  • Human with (w)iimote
  • (d)esktop computer
  • (L)aptop computer
  • (i)nfrared emitter
  • (h)elicopter
 and an automated loop h-c-d-L-i-h:
  • (h)elicopter
  • Web (c)am
  • (d)esktop computer
  • (L)aptop computer
  • (i)nfrared emitter
  • (h)elicopter
Notice I use two computers because my laptop is not terribly powerful and also it's easier to place the web cam and infrared emitter in different places. You can just as well use one computer.

I'll be adding new sections and expanding existing ones according to your questions and comments.



19 comments:

Anonymous said...

Hi,
I have same helicopter but controlled by RF, not by IR. How do you think will your solution work for RF assuming that instead of IR tranmitter will be used RF one?
I ask because it is not simple for me just to try. It will take a lot of work and I try to decide worth this way to be tried or not.
I'll be very appreciated for your information
Thanks!

TechMind said...

There are three problems you would need to solve to make it work:
- Building an RF interface with the PC
- Adapting the program to use that interface
- Decoding the protocol. It may be the same or it may be different from the one I'm using.

Apart from that the program should work fine to control the helicopter.

Where did you buy your helicopter?
Do you have a link?

Anonymous said...

I've posted a comment. It has dissapeared?

Anonymous said...

Yes, it has dissapeared.
Ok, I'll write it again.
Sorry for delay in answer.
I've bought my helicopter on DealExtreme http://dx.com

My helicopter has an RF module which is connected to aduio output. Seems, like you one. And moreover, it is controlled by the same program i-helicipter. So, I suggest that the protocol between the program and a control module (RF or IR) is the same. That is the set of sounds which the program sends to a module is identical.
So, I suggest to genrate such sounds by my own program and thus to control helicopter using staff RF module.

TechMind said...

Interesting, I didn't know they have an RF module too.

In that case it may work, although a little modification to the code may be necessary(probably not). See, the iHelicopter program sends two different signals: on one channel it sends the actual information and in the other channel a constant tone at a fixed frequency. I'm not sure what's the purpose of this constant tone. It may be a carrier frequency for the module or an attempt to provide power. In any case it doesn't contain any information.

My program instead sends the same signal in both channels although inverted: when one is high the other is low. The purpose of that is to double the voltage of the output.

You can try and modify my program so that it sends the constant tone in one channel but I suspect you can use the program as it is and it should work. I believe the RF/IR module just ignores that channel.

Try using the 'Falcon Sound Card Signal Generator.hcomm' definition file included and make sure to check/uncheck the "Invert Signal" option in the "Sound Card" tab to see which one works.

TechMind said...

BTW, test it first without actually connecting the module. When you press the send button (to the right of the Ir Stream) you should hear a short loud chirp.

When you check the option "Keep Sending", you will hear constant chirping. Uncheck to stop.

- Connect the RF module.
- In the Variables tab set Power to 25%
- Turn the helicopter off then on.
- Press send once. The blades should spin for 5 seconds or so.
- If it doesn't work, try inverting the signal in the Sound Card tab, also increase volume.
- If the helicopter responds then check the option "Keep sending" and play with the controls.

If that works you're on your way. Please let me know how it goes. Actually it's very hard to control the helicopter using only the program, try using the wiimote for smooth control.

Anonymous said...

1. I investigated sounds generated by i-helicopter and found exactly what you said: 20KHz carrier modulated by 2KHz harmonical signal whith phase shift in left channel and some signal packets in the right channel.
2. I connected recorder between RF module and sound card and recorded sounds which generet were ed by i-helicopter program during simple session. Then I played them back to RF module expecting helicopter will behave the similar way. Nope! Very strange!
3. Your IR_HeliAutoPilot.exe program refused to start. Without any explanations.
I don't have Visual Studio and am unable to build application from your source code. So I'm unable to execute that steps which you advised for now.
Because I'm busy in another project right now I'm unable to give much time for helicopter task. So please be patient. Helicopter task is very interesting for me and I'll workfor it certainly.

TechMind said...

For your recording to work, maybe you just need to turn the sound volume all the way up.
Here is a simpler test: I just uploaded two files:
One Frame Falcon X.WAV &
One Frame Falcon X Inverted.WAV
If you play them back on your phone or computer they send a single packet of information that should make your helicopter spin for 5 seconds. One of them should work.
Turn the volume all the way up.
Let me know.

I use Visual C# Express, it's completely free. Here is a link:
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express

TechMind said...

I uploaded a new version of the file Heli Control\HeliComm\Runtime\IR_HeliAutoPilot.exe try it now.
The main screen should open. When you press on the Send button you should hear a chirp or get a nasty error message.
Please let me know which.

Anonymous said...

Both files have no any effect.
As far as I see they both are some thing like RS-232 data sequence. Correct?
Seems, they work for IR and does not for RF. Seems, i-helicopter program for IR and RF are different. At least in part of identification of helicopter. In i-helicopter manual is mentioned that at very first time i-helicopter sends to helicopter its ID and which helicopter keeps then. I suppose it is dedicated for ability to distinct several RF controlled helicopters in range of different RF controls. So, in every control data packet such ID must exist. Obviosly it is not necessary in IR case.
If you want I'll send you my recorded files. May be you'll have some idea.

Anonymous said...

The new version of the program failed with error message "Initialization error" before opening main window.
OS Win XP.

TechMind said...

I just uploaded an installer for the program. See if that works for you.

You can email me the file to amieres@hotmail.com. I'll try it with my helicopter.

TechMind said...

I checked the file you sent me and I can confirm the protocol is exactly the same as the Falcon X helicopter.

I believe the RF transmitter is not transmitting anything for some reason. It could be the quality of the reproduction or the recording. Try playing the files from your phone instead of the computer.

I also uploaded the file One Frame iHelicopter.wav try that one too.

TechMind said...

I tried your file with my helicopter and it worked perfectly. It spins for a couple of seconds then stops and then the lights turn on and off.

Anonymous said...

Exactly!
I tried that file on two computers with no effect.
Did you try it with a computer or with a phone?
I've made the picture of my RF-module. It has on its top 3 leds which vener lit. I suspect they are IR diodes and therefore the same modul is used for RF and IR helicopters. Not the program only. I'll send you that picure. Please, compare.

TechMind said...

I used a laptop.

BTW, if you look at the IR diodes through a camera you can see if they lit or not.

Anonymous said...

BTW, yes, it's a good idea - to see to the leds trhrough camera. I'll check.

I've sent RF module picture.

I used my laptop Dell Vostro 3350. The RF module lits blue light like it does this when it works with iPod and nothing more happens.
Something is wrong here.
There is one more thing I'll try - playing back that sound files directly from iPod (here we have some problem yet). Then new ideas will be wanted :)

mahmedsuhail said...

Hey... i want to control syma107 helicopter using kinect sensor n arduino mega. i am working on it for a month but still facing problems. Can you provide me the processing code for controlling it through kinect? Will be extremely thankful to you.

TechMind said...

Hi mahmedsuhail
I don't own a kinect or an Arduino so I cannot help you there. All my source code is available for download but I don't know if that would help you since your implementation is so different.

What specific area are you having difficulty with?

Several people have built arduino controller for that helicopter and posted in YouTube.

Good luck!