3D Robotics

### Discussion forum for UAVDevBoard, Sparkfun's 3-axis IMU-based autopilot board

This is the place to discuss the new open source IMU-based autopilot board by Bill Premerlani.

#### Replies

• Can we use Sparkfun 3-axis IMU-based autopilot board for helicopter ?
• Hi Bill,

Looking at the offset correction in the MatrixNav code:

zaccel.offset = zaccel.value - 2*GRAVITY ; // GRAVITY is measured in A-D/2 units

and

gplane[2] = ( zaccel.value>>1 ) - ( zaccel.offset>>1 ) ;

... the following struck me.

Say you have a 12 bit ADC resolution and a full scale range of +/-8 g (just for illustration). That gives a GRAVITY value in A/D digits of 256 digits/g.

When the accelerometer is 100% vertical an ideal world accelerometer would read 256 digits on the Z axis due to gravity. If a plane rolls to the right this reading will decrease with a corresponding amount. Similarly, a decrease will also be seen when the plane rolls to the left.

If the accelerometer leans a little to one side during calibration it may read 245 for instance, the offset then being 11.Say the accelerometer leaned to the right during calibration and the plane performs a right roll, the raw value will decrease and so will the corrected value. But, and this is the problem, if the plane rolls to the left, the raw value will increase first (and so will the offset corrected value) until it reaches the full scale A/D value and only then start to decrease as it should.

From the code I can see that there is no compensation for the above and would expect it to introduce a bit of instability - specifically during roll maneuvers which centers about this incorrectly increasing window. From all the successes I read about in this forum I can only guess the the effect of this is minimal, but I would love to hear your take on this.

Best regards,
Elardus
• Hi Bill,

I have some questions about the code CORNER:
- what means this and what exactly happen in the navigation when I define CORNER?
- are there other code like this (something to define a circle, with radious and direction, or a selectable angle of turn)?

Thank you and best regards.

Ric
• Hi Bill,

yesterday I made 4 more flights.
During the first two flights the plane, in wp mode, made anything else than I programmed, to the point I thought I was wrong again with the wp programmation.
During the 3th and 4th flight the plane made the sequence without mistakes.
I have to say that I also made two fpv flights, with another plane, and during the second I lost the gps lock (from 7 sats). The plane, equipped with a Remzibi osd, was no more able to get gps lock in flight. It only got a lock several minutes after landing.
Could this be the issue with wp sequence issue too?

Btw, I take care to set the calibrations at the best I can do, and the stabilisation was awesome (I like wery much how the imu lock the plane when going up at 45 deg and full power).

I changed the gains to have tighter turns in wp mode (Yawkp from 0.07 to 0.1, Rollkp from 0.25 to 0.15 and Rollkd from 0.125 to 0.1). The plane turn very tight but it need a bit more elevator.
I wasn't able to find the value to change this.
Do I have to change the pitch gains (I don't think so, pitch stabilisation and recover are good, until now)?
Is there another value to set right elevator vs.banking?
Would this be simply solved using altitude hold (but for this I need a new ESC, mine does not arm, do you remember?)?

Thank you very much!

Ric
• Bill,

in the meantime I have another question (ok, a couple :)).
How does the plane know where is South? I guess this is the reason you say to fly the plane at least two minutes before enter in WP mode.
The question is: is it the same in wich direction? Is it just enough to circle over head or is it better to fly straight? Is the same from wich direction you start the wp sequence?

Sorry, but I would like to understand the better I can how this device work.

Thank you!

Ric
• Hi Bill,

I just went from flying field.

On 4 flights I noticed that:

- first flight a lot of drift. I forgot to wait for the board to fit the external temperature!!!

- the waypoint sequence had a strange behaviour. It begin in the right way but it does not execute the right sequence (no CROSSTRACKING). I already had a look at the code and I guess it is correct. I think N-E-S-O do have the same positive negative value here in Europe too, is that true?

- if I pause the sequence and start it again would it begin from the last wp? It seem so. I tryed to toggle the switch 5 times and it seems that it begin the sequence from start. Could you confirm this please?

- when the model reaches the first wp (home) it begin to dive. I fly with altitude hold disabled and half throttle. Is it possible that the plane search to hold the altitude from throttle position?

- in the last flight drift appair again, stabilisation was not working well: mystery!?

Best regards.

Ric
• I couldn't resist a quick flight test with the TwinStar, and too much wind. The first attempts to turn on the stabilization were tragic, with the plane just spinning out of control. It seemed to be working fine on the ground, so I landed and checked it again. It still seemed fine, but the second flight acted just the same.

I'm sure Bill's laughing now, because he probably already realizes what I did. Yep, I had the aileron throw reversed. Doh! I had all this set up properly on the first board, but ended up ordering a second board as well. After the regulator changes, I installed the second board, which had the switches in their default position, NOT the position I put them in on the first board. I was just so convinced they were moving the right direction, I didn't question it until after the second flight.

Flipping the switch of course makes a world of difference. Stabilization works reasonably well for stock settings. The ailerons have too much gain, and the elevator not enough, but I'll start working on that.

Waypoint mode tried really hard to work, but the wind and poor flying qualities of the TwinStar kept it from being fully successful. I had a simple box set up, and it made the first 3 corners, but the last was upwind from far away. Ultimately, I became uncomfortable with my ability to see the plane from that distance, and brought it back manually. The main problem was the TwinStar wanting to balloon up, and more throttle makes that even worse. The AP really wasn't to blame for this.

All in all, a very promising first attempt :-)

Thanks,
Rusty
• Hi,

I'm a little confused. I tried to better understand the difference between define or not CROSSTRACKING in the waypoints menu.
My english does not allow me to have a satisfactory comprehension of that.
Could you please explain how CROSSTRACKING work and the difference?
In wich cases is it better to use CROSSTRACKING or not?

Another couple of questions about GPS:
what exactly happen when GPS signal is lost in WP mode?
How many satellite the board needs to set home?
I ask this because I usually fly in an area with high mountains all around and then very bad GPS (4-7 satellites, often 4-5, depends on weather and moment).
I noticed that if I put the plane in wp mode (not crosstracking) it reaches the first wp at about 50m from the start position (home).

Thanks!

Ric
• Bill,

Since you mentioned working on new software, I would like to make a suggestion (request). In the quadrocopter world where I usually hang out, we also have gyros and ACC sensors of course. While the gyros should be calibrated every flight, the ACC really only needs to be done once, as long as you don't change the board mounting angle.

For our typical aircraft, that have no landing gear, I find it difficult to simultaneously plug in the battery, and hold the plane level, and still for 10 seconds. If the only requirement was to hold it still, you could just let it lay on the ground in whatever attitude gravity allows.

If this PIC has the ability to save the ACC cals in non-volatile memory, the suggestion would be to remove the ACC calibration from the initial power up routine. You'd have to create a trigger to do the cal only when needed, such as some combination of stick positions, or a jumper using one of the extra pins on the board.

Thanks for reading requests from the software challenged :-)
Rusty
• Bill,

I just made 4 success flights with the IMU on my old Robbe's Arcus.
Wow, I was very impressed by the efficiency of this device! Even with the base settings it works very well.

Stabilisation is awesome. From inverted flight it recover the model in a fraction of a second without overshoot or strange habits, and the same is from any flight attitude.

In wp mode it turn around very gently, holding the heading and the attitude very well. I only want it a bit responsive. I'm going to increase a little the P aileron's gain.

I'm not a programmer, I'm only a well experienced RC pilot. I can watch at the code and try to change something. Is for that that I appreciated a lot the clarity of your code, with all the explanations and, most important of all, the well explained values (what they means, meters, real degrees, binary degrees etc; what they do and wich are the maximums allowed).

Of coarse I have now to fine tune the Pid settings, and to comprehend the most I can of this device.

I tryed my plane without altitude hold (I disabled it), but I miss it. Now I have to find a solution, berhaps another esc.
Could you please tell me wich ones are already tryed and working?

Thanks for such a great device and program.

Best regards.

Ric