GERMS @ 20Hz ALPF
Another day, another couple of indoor test flights, experimenting with the IMU accelerometer low pass filter, to see if that would help extract the GERMS info. Previously, it was set to 2 (92Hz bandwidth); today I tried 4 (20Hz)
The good side is it clearly did – the acceleration and deceleration now stands out clearly at the 1.5, 3.5 and 5s points corresponds to the transitions to ascent, hover, and descent.
Also there was no horizontal drift – during yesterday’s flight, there was drift of half a meter or so. Clearly yesterday some of the noise on the accelerometer X and Y axes had contributed to the X and Y axis velocities leading to horizontal drift.
The down side is that the lower bandwidth also filtered out some of the Z-axis real acceleration, so during nominal “hover”, Phoebe actually continued to climb slightly- that’s why there’s no spike at 7.5s like yesterday’s graph; Phoebe was still in the air when the flight ended so the post-flight ground impact didn’t register in the stats.
The gyro does offer a dlpf setting for each axis in the MPU-9250; it’s a shame there’s only a single setting of the accelerometer covering all 3 axes.
At least it seems like my GERMS filter idea could work in principle, even if in practise the MPU-9250 can’t be configured to play nicely together with the GERMS filter.
I’ll try 3 (41Hz) accelerometer DLPF tomorrow to see whether this is the perfect comprise.
I collected these diagnostics from a couple of indoor flights this morning. The flight is 7.s long:
- 1.5s to get the props spinning to hover speed on the ground
- 2s climb at 30cm/s
- 2s hover
- 2s descent at -30cm/s.
This was using the complementary filter with tau set to 5s but the GERMS stats were collected to get a better idea what’s going on.
This shows two things – there’s a lot of noise in the raw data blue line, and the red trend line cleary shows an oscillation which is hiding the peaks and troughs of net acceleration / deceleration at 1.5, 3.5 and 5.5 seconds.
This set show raw accelerometer values, and the measure of gravity that comes after the raw data has been passed through the butterworth filter. Three things of interest here:
Acceleration and Gravity
- The grey line of raw acceleration is still noisy, but does show the peaks and troughs better at 1.5, 3.5 and 5.5s
- The green butterworth filter line is doing a lovely job of extracting gravity from the noisy accelerometer data
- There’s oscillation in both the X and Y accelerometer readings, best seen in the blue and orange trend lines.
The flights were perfect to look at – only these diagnostics show these subtle problems.
The next steps then are to sort increase the P gain and decrease the I gain to stop the oscillations. With those gone, it’ll hopefully allow the GERMS stats to show only the deviations from real gravity, and thereby filter it out from the angle calculation as the complementary filter does now.
One point in passing, I have to drop the hover speed PWM value from the long standing 1500ms to 1400ms PWM; The new 4S batteries are clearly showing that 3S is not enough.
I’ve just managed to squeeze in a couple of test flights before the rain came in, and something is messing up the germs fusion code; noise from the props caught by the accelerometer is my best guess. I’ll keep tinkering so see whether I can improve this; I’m fairly sure the theory is good, but the reality is swamped by noise.
Just in case the theory is flawed, I’ve uploaded the code to GitHub – just search for germs – it’s commented out so this code is still flyable. Feedback welcome via comments to this post.
In passing, this update includes a minor fix to the RTF timing, and some tweaks to the diagnotics to keeps the separation between screen and logs clearer.
Finally, I can confirm the 4S cell battery works much better, though I do wonder whether the extra power from the motors has actually increased the noise due to the extra torque making the prop motion more jittery as it steps between motor coils – the motors are able to curtail angular momentum of the props better, pulling them back from overshoot?
Sorry it’s quieter than ever – the weather is against me testing the GERMS filter code, so I’ve been twiddling my thumbs. I have found some odd behaviour from the IMU that’s worth sharing.
The SMPLRT_DIV register sets how often the data registers are updated, and therefore how often the data ready interrupt goes high. Normally the ADC sampling frequency is 1kHz, and the data registers are updated at a reduced frequency defined thus:
1kHz / (1 + SMPLRT_DIV)
Setting SMPLRT_DIV to 0 should give data ready interrupt (DRI) at 1kHz; 1 should product 500Hz, 2 should give 333Hz etc etc.
But what I’m seeing is that with SMPLRT_DIV <= 3, the DRI happens at 250Hz. SMPLRT_DIV >= 3 work fine producing 250Hz (3), 200Hz (4), 166Hz (5), 143Hz (6), 120Hz(7), 111Hz (8), 100Hz (9) etc etc etc. Because I’m using the DRI as the clock for the code, that means 250Hz is the fastest I can use. That’s no problem really – that’s plenty fast enough allowing 4ms per sample during which I can run the motion processing, but it’s not a limitation that’s been documented in the specs
In passing I’ve fixed a rounding error bug in the pre-flight RTF period. Not important really, but actually fixing it was what exposed the DRI frequency limit.
I’ll upload to GitHub in the next day or so once I’ve had a chance to check I’ve not broken anything.
I flew my new experimental fusion filter several times this morning; Phoebe barely got off the ground. After several flights reconfiguring the GERMS (Gravity Error Root Mean Square) filter to no avail, I just ran the normally successful code, and that too failed to get off the ground in exactly the same way. So it’s battery power at cold ambient temperature rather than the GERMS filter. Phew!
So I now have a couple of 4S GensAce 2300mAh batteries on order; the higher voltage (compared to the 3S version) means that even with the higher internal impedance at lower temperatures, there should still be enough power for the motors; at the same time, the low temperature higher impedance should help to warm the cells and so keep the impedance low enough. It’ll probably be Tuesday before the batteries arrive, and so Wednesday before GERMS testing can resume. Weather forecast is looking good for the week ahead. Onwards and upwards, hopefully!