Friday, December 15, 2017

Poor filtering is poor

I noodled around with the data from the road test, passing it though a 25-tap lowpass FIR filter. Here are the results -- purple is original, and green is filtered. The X axis is in seconds:


Looking more closely, we have:


Notice the 1 second delay, and the DC bias. Clearly this is not okay.

Now it's true that I studied signal processing at some point in my life, but that was literally 30 years ago. :) So I have a big ramp-up I need to do, and clearly I need to learn about, and implement, a proper Kalman filter.

The data above is nominally at 20 Hz, but because I have had trouble getting timers to work on my Arduino, what this really means is that I acquire data with a 50 millisecond delay in between. This is no way to acquire data. :)

And finally, it's possible that the road environment has more turbulence than flight, so it may be that the filtering requirements for flight are less stringent, which would mean I could defer the fancy filtering until later.

Therefore what I've learned here is:
  1. I need to move to flight testing sooner;
  2. This means I need to figure out my airplane mounting again -- the mount I bought was a bit wobbly, and maybe I should move to using a Citabria that has 2 struts for more stability;
  3. For this testing I need to buckle up and add my 2 other sensors to my probe and hope I don't fry them;
  4. I also need to get Arduino timers working so my data is at a consistent sampling rate (no sense paying for a flight test then using crappy sampling); and
  5. Meanwhile, I need to start learning about Kalman filtering.
That should keep me busy.



2 comments :

  1. I've used arduino extensively over the years. Timers & Interrupts are fairly easy to use. Just look at the spec sheet to see which pins accept them.

    Delays are always a bad idea.

    You might also want to take a look at the Teensy boards. Those are much better with the amount of program storage, running faster, and lots more interrupts & timers. You can also buy their bootloader chips for when you custom design your own device.

    ReplyDelete
    Replies
    1. Cool, thank you. The problem I have with timers was using stuff like Timer1 --

      https://playground.arduino.cc/Code/Timer1

      For some reason the danged thing doesn't call my callback functions.

      As for the Teensy -- thank you, that's a great recommendation. Right now I'm standardizing on the Sparkfun Fio V3 because it integrates a lot of stuff like battery charging and built-in headers for the XBee. And in any case processing speed is not my bottleneck. My Arduino code just reads bits from the sensors via I2C, converts them to engineering units via a linear scaling, then sends comma separated data "sentences" wirelessly.

      Delete