Name:

Password:

or

Flight Controller Progress #1

by Octapoo

Wednesday, November 18, 2020 at 09:36:00 UTC

Return to the Summary in Ecstatic Lyrics Blog

This is where I'm at with this so far...

Basically I'm following the plan I outlined here, just kind of slowly because I've not had a lot of energy so I've just been kind of doing a little bit at a time. Of the four ATmega328 chips, three have the code written for them. I wrote the code for the PWM output chip in C as well, as it's so convenient. I just disabled interrupts while it creates the PWM output.


I also gave the compass that's included in the GPS a try, and it took a while to figure out how to initialize it properly, but once I figured that out, it works perfectly. So I stopped calculating direction based on GPS movement and just use the compass alone now.

Also, interesting fact: The magnetic field here doesn't point just north, it points like 60° into the ground. So I'm calculating which way I'm facing using two vectors, one from the accelerometer which points up, and one from the compass which points almost down. However, it points a bit north too, so it works.

I haven't begun putting the code to fly the plane into the chip that will do that, but the code to process the gyroscope and accelerometer and compass and GPS is all in one chip and, I forget how long it takes to execute, I just remember that chip is mostly idle. I think it was only like 2 ms of the 15 ms available. More time is spent just waiting for the data to be transmitted serially over the i2c bus. Granted, I did heavily optimize it to use as few trigonometric function calls as possible it calls sin & cos once each, and atan2 three times but there's still a lot of multiplication going on and some division so I'm still impressed at how quickly that floating point math gets done on an 8 bit CPU.

There's still a lot to do before this will be flying a plane but it's coming along.

Comments


If you were logged in, there would be a comment submission form here.
Creating an account is easy. You literally just type in a name and a password.
I don't want your email address, so there won't be any links in any emails to click.

Return to the Summary in Ecstatic Lyrics Blog