Im currently working on a project to add altitude hold for my tricopter with Arduino and a Ping sensor. The tricopter is controlled by a HK KK board and my transmitter is a basic 6ch HK-T6A. The idea for the code is that when my channel 6 knob on TX is turned all the way up the Arduino enters altitude hold mode. The arduino is plugged in between ch4 on RX and THRO ch on KK board. When its not in altitude hold mode the arduino just passes the throttle signal from RX to KK board.
The logics of the code in altitude hold mode:
When entering altitude hold mode, save the current ping distance and keep it as a reference. Also save the current throttle signal level.
Enter a loop which will in every cycle
1. Take ping distance and compare it to the the reference.
2. If it's lower than the reference distance - Increase throttle signal level by 5 and send to THRO on KK.
3 If it's higher than the reference distance - Decrease throttle signal level by 5 and send to THRO on KK.
Note that some checks are done in order to prevent the Arduino from decreasing or increasing the throttle level to 0 or max.
Here is the full code
I havent really tried the code live in freeflight, only holding the Tri firmly in my hand and moving it up and down. What to you think of it?
Please leave feedback.
i m also planing for the same...
starting with altitude hold, then a bit of obstracle avoiding....
pl. tell me if u have got any progress..
Hello dear, i don't know if anybody is still interested in this project, but i took your code (there are some errors) and i adapted it to the cheap HC-sr04 and it works (just on my table). It's just a couple of days i'm working on it but i added a led which turns on while in alt-hold mode and other little improvements such as residual battery voltage measurement exploiting the arduino internal reference voltage, and other things like this.
If you want to read and watch pictures about what i'm doing you will find all here http://blog.giuseppeurso.net/low-altitude-hold-auto-takeoff-autolan...
It is still your code but i will upload the new one within tonight (Amsterdam time)
Keep in touch!
i'm planning to implement auto-takeoff and auto-landing,.
And it is probably more expensive than all in one flight controller but i have also a 10dof to be used. I don't know yet if i really need a head tracker for such an aircraft, so maybe, it would be spent better by adding it in some way to this setup... suggestions? advises?
p.s. I'm going to open a google code project for this, and I will update this post soon!