PDA

View Full Version : Discussion IMU 1DOF - artificial horizon


gmamo
Nov 06, 2008, 07:01 AM
Hi....

I would just like to share this clip showing a gyro and 2 axis accelerometer and their combined outputs on this video clip.

My intention is to create a single axis stabilization utility that can be given a PPM input and the servo output is then governed by the IMU but controlled by the user stick inputs.

Hope to be able to present another clip with the working development soon.

Thanks for watching.

http://www.youtube.com/watch?v=6oJr4Yhq3z8

dleroi
Nov 06, 2008, 10:44 AM
You have MY attention!

Tomapowa
Nov 06, 2008, 11:53 AM
Could you please tell us more regarding the hardware you are using?

I was once looking at these 2 DOP breakout boards by Sparkfun...
http://www.sparkfun.com/commerce/product_info.php?products_id=698
http://www.sparkfun.com/commerce/product_info.php?products_id=839


A bit pricey for my tinkering, but still cool... I've got a UAV project in the works and might have to soon splurge... :)

gmamo
Nov 06, 2008, 03:28 PM
Hi.. The above demo was done with the following bits and bobs..

Hardware:
Hot Melt Glue gun :)
An old CSM360 piezo gyro element
An Analog Devices 2 axis accelerometer

Software
Arduino as a platform for sampling, and the code for the display part was done in Processing.

I have already done a fully working unit with microchip PIC 16F series, however I am not happy with the resulting lack of processing power when trying to cram 32 bit floating point math into an 8 bit machine.

AndyKunz
Nov 06, 2008, 07:19 PM
Don't do it with FP. Use fixed point instead. It will give you much better performance than float because it's integer math. You might not have the ability to do a full 360 perfectly, but for what you were showing there it should suffice.

The 16-bit and 32-bit PICs use the same footprint - you might want to try one of them instead.

Andy

gmamo
Nov 06, 2008, 08:22 PM
Andy..

Don't know if you have done this as well, but for scaling stuff, and dT's you have to use float's...IMHO...and...
Especially when you come to the real world where different users have to adjust Gains and ATV's for their application... ditto above

AXI Motor Models
Nov 06, 2008, 08:31 PM
That is great! I would like to build a similar circuit but my programming skills are not good.
Are you eventually going to sell these? (or the code on a chip)

JustinONE
Nov 06, 2008, 08:57 PM
will this be a new head tracker for FPV? I would love to get a 3 axis system for the added head rolling affect. maybe a 4 th axis for a zoom in zoom out feature would be really cool!!!


is there any drift when stationary for long periods?

gmamo
Nov 07, 2008, 06:46 AM
Haha.. this is a good one...

3 axis for head tracker is a good target to look into.
For the 4th axis.. I propose a tension sensor to put in between your teeth and the grind ;)


There is absolutely NO drift even after 10 days !! Stationary or moving !!

AndyKunz
Nov 07, 2008, 09:15 AM
Andy..

Don't know if you have done this as well, but for scaling stuff, and dT's you have to use float's...IMHO...and...
Especially when you come to the real world where different users have to adjust Gains and ATV's for their application... ditto above

Yes, I have, that's why I recommended it. Math was my minor (emphasis on discrete math), behind a double major in computer science.

Just because the user thinks he's manipulating an analog control doesn't mean it has to be floating point. In many places floats may be convenient to the programmer, but that doesn't make them the best choice for the work being done.

OTOH, silicon is cheap...

Andy

gmamo
Nov 07, 2008, 09:34 AM
Ok.. I get the drift...

I'll try to mangle the code and C what happens.

Many Thanks.

JustinONE
Nov 07, 2008, 10:30 AM
Haha.. this is a good one...

3 axis for head tracker is a good target to look into.
For the 4th axis.. I propose a tension sensor to put in between your teeth and the grind ;)


There is absolutely NO drift even after 10 days !! Stationary or moving !!
well the 4th axis would be great for zoom in, I could be wearing goggles and just move my head forward or backwards to activate the zoom servo.

ps2727
Nov 07, 2008, 11:13 AM
Very nice work here!

Paul

JimnAz
Nov 07, 2008, 01:48 PM
Nice work George.

Now have you anything to show other than the IMU working on a screen?I mean can you show it actually controlling an axis or servo?

Did you use Jordi's code for his IMU?

Your project parallels one I am doing for three axis stabilizing of a camera only I am using the Basicx 24P.

Hang in there. :)

Jim

gmamo
Nov 07, 2008, 02:38 PM
Hi Jim,

Yes.. I have some other snippets.
I think I'll just wait a bit more till I have the values tuned well enough to show.
I'm on PIC16 and ATMega for now to try my best to keep costs low.

JimnAz
Nov 07, 2008, 08:00 PM
Hi George

I understand about keeping the costs in check. I am using the BX24 because I happen to have a few from earlier days. I would go to the Arduino and probably will soon since there is so much code examples and info on this Micro available.

Have you checked out www.DIYDRONES.com yet? Much info there on the 'duino system.

Jim

shanghai_fool
Nov 07, 2008, 08:20 PM
You might also want to check out the Propeller chip from Parallax (http://www.parallax.com/tabid/407/Default.aspx). The code is alraedy available on their object exchange and forums. Its about the cheapest development system around. Their spin code is about as simple as it gets to do complicated things. The IMU/Kalman object does exactly what you want. There is also a vb.net program to display on PC.

Donald

gmamo
Nov 21, 2008, 05:30 PM
some more clips ...

http://www.youtube.com/watch?v=fsnNTH0yRvE
http://www.youtube.com/watch?v=jsMvbNG8dX0

AXI Motor Models
Nov 21, 2008, 08:55 PM
That is great! I would buy one.

AndyKunz
Nov 22, 2008, 11:44 AM
Still using floats or did you try fixed point?

Looks good. Doesn't it feel great when it actually controls the servo!?!?!

Andy

gmamo
Nov 22, 2008, 05:45 PM
Hi Andy,

Tried with fixed point using 16bit integer. Not too happy.
Values get filled up pretty quick.
Long Int works better, but that's 32 bit.. therefore back to floats.
The resolution when using 32bit math is much better.

Chophop
Nov 22, 2008, 06:00 PM
Great project. I wish I had one when I first flew ultralights and wanted an artificial horizon. I was fool enough to take off by the side window when the windshield fogged up in the morning, and figured I might need it in case the window didn't defog. I also got caught up there by ground fog a few times and it would have been a help. Then again, you can only legally fly by visual reference under FAR 103. But having one for an emergency would outweigh breaking a rule. But one more, a person should not fly any aircraft in weather it is not CERTIFIED for.

About the circuit, it amazes me that you managed to interpolate from a rate gyro and get the results of a roll gyro. It seems the gyro could loose track of it's exact interpolation after a number of interpolations. I started to do it, but in the 80's all I could come up with then was a heavy old mechanical rate gyro clunker. I suppose in a manned aircraft, the pilot could occasionally reset the gyro while in stable flight. After all, you do need to reset the mechanical horizon gyro after some time.

CH

gmamo
Nov 22, 2008, 06:21 PM
Hi Chophop..

By no means is this an artificial horizon. That needs at least 2DOF to work.
This unit is only designed to stabilize camera mounts or stuff that needs to remain at a certain angle without the drift from normal gyros.

I suspect that some folks might want to try using 2 IMU's together with an AP2000 from Spartan R/C, or any other CCPM mixer, so that the helicopter has a reference to gravity.
I'd like to try that in the near future.

I have built one prototype of an artificial horizon 2DOF, and it's fascinating to hold the LCD in your hands and go around the corridors with the IMU in your hand pretending to be an aircraft. Kid like grin on my face !!
I have drove around with it on my car dashboard, and its performance held up very well.

HoaRC
Nov 22, 2008, 06:48 PM
Great job. Very impressive! I am clueless however

what is the practical purpose of this?

Chophop
Nov 22, 2008, 06:53 PM
And think of an 8 bit MCU at 10mhz. Ha, that's what I had to work with. And you wet feathered egg crackers gripe about 40 mips !
I went through all of it, and decided a phase comparator feeding a differentiator was the only way to make up for the lack of math ability. The differentiator was for 360*, and extra sensitivity for direction reversals.

CH

gmamo
Nov 22, 2008, 07:20 PM
Chophop..

That's so cool. You did it in analog..

Chophop
Nov 22, 2008, 07:50 PM
I only did the schematic and didn't get around to actually building it because the gyro was too heavy, my ultralight was already marginal for FAR 103.
It would be so much easier to adjust software than to fiddle with a differentiator. Those things get sort of touchy.
The basic idea was compare the gyro's phase output to a reference oscillator, and to count between the leading phase edges. When they were at 0* while the differentiator was above 0 in either direction, reset the counter. A 0 to 359 counter circuit provides the smiley stuff. :D

CH

AndyKunz
Nov 22, 2008, 08:16 PM
Hi Andy,

Tried with fixed point using 16bit integer. Not too happy.
Values get filled up pretty quick.
Long Int works better, but that's 32 bit.. therefore back to floats.
The resolution when using 32bit math is much better.

Yes, I would have recommended 32 bit fixed. Floats still require 32 bits of storage but a lot more time to manipulate.

Looks good, though. Can't say anything bad about the response.

Andy

gmamo
Nov 23, 2008, 04:44 AM
Andy..

I'll try to persevere a bit more with L_Intg. Perhaps in the long run it'll be worth it. I'll let you know how it goes. I'll try to measure the two processes separately with the scope. Thanks for your help.

Chophop
Nov 23, 2008, 07:55 AM
gmamo,
Do you get an accumulative error that builds from the lack of sensitivity in detecting initial and ending movement ? I keep visualizing such a thing.

CH

gmamo
Nov 23, 2008, 01:50 PM
Depending on what's your bit depth when sampling.
However already at 10bit, the resolution is good enough.
At 12 bit, its much better.
Then it depends on the gyro sensor you use, and what's the noisefloor from it and the noise coming in from the carrier( engine, vibrations, etc etc )

Gord_W
Dec 04, 2008, 09:55 PM
I have already done a fully working unit with microchip PIC 16F series, however I am not happy with the resulting lack of processing power when trying to cram 32 bit floating point math into an 8 bit machine.

Are you using this math to multiply a variable times a constant?

If you are using a constant multiplier have a look at:

http://www.piclist.com/techref/piclist/codegen/constdivmul.htm

It makes fixed point multiplication very fast and small size. For example if you want x * 0.1446 you get an equation like

;Requested(0.144600) attained(0.144531) error(0.047545%)
;
; -- basic equation
; 1/8x + 1/64x + 1/256x
;
; -- factored equation
; ( ( ( x ) / 4 + x ) / 8 + x ) / 8

You will note that this is just a bunch of adds and right shifts.

Good luck with your project.

Regards,

Gordon Williams

gmamo
Dec 05, 2008, 10:55 AM
Hi Gordon,

Thanks for the heads up on that link.
I was not aware of that.

I am not on P16 anymore for this project. Switched to P18 and the onboard 8x8 helps a little bit in giving me faster times.