Sunday, April 11, 2010

AHRS

That's "Attitude and Heading Reference System", and the next big part of the helicopter project (possibly the biggest part, if this off-the-shelf solution doesn't work out).

The plan is to use this board from SparkFun: it contains a 3-axis accelerometer, 3-axis gyro, 3-axis magnetometer, and a ATmega328 processor with bootloader setup for in-circuit serial programming. And at least one group has built an AHRS out of it. I haven't looked through their code, but if they're at all competent it should give some indication of the board's capabilities.

What I'll need to evaluate is its susceptibility to drift (this is the big one; I think this'll be what ultimately limits the system's performance) and the level of noise (also problematic, but at least I have ways of dealing with it). When I get to the stage of implementing the control system, I can add the plant dynamics into the estimator model (I wonder if the microprocessor is up for calculating Kalman gain matrices) and that should only make it better, right?

Next steps:
  1. Get the thing running with the pre-flashed firmware. Check that output values are reasonable and look for drift. Also try running it in the refrigerator to check temperature compensation.
  2. Install the AHRS code and evaluate its performance. If necessary, write some client software to display its output (maybe MATLAB or Java, for easy graphics).
And on the Arduino side:
  1. Get Arduino talking to servos (will require 3.3V to 5V hardware)
  2. Get Arduino talking to receiver (will probably require 3.3V to 5V hardware). An oscilloscope would be nice.
  3. Get Arduino talking to both at the same time (try powering everything off helicopter 5V regulated supply)
In terms of hardware, will need something with enough connectors for the servos and receiver, as well as 5V to 3.3V level shift. And for integration:
  1. Get Arduino talking to AHRS (over software SCI at first, then try SPI)
And that should be it. Arduino mini has 18 I/O pins available, need 3 for SPI, 6 inputs (from receiver), 6 outputs (to servo, ESC). That leaves 2...which I might use 2 for I2C to a camera module. Hmm...I guess I should take a look at serial interface servo signal drivers...I might even be able to find a 5V driver with a 3.3V serial interface.

update: No magical chip to read/output servo signals. My search mostly turned up tutorials on how to implement it on a PIC or AVR, which is probably a bad sign. A 12-bit PWM generator might work: at 60 Hz, I'd get 8 bits of resolution for pulses between 1 ms and 2 ms, which is...okay. Well, I can control the output timing to have no overlaps, so I guess I could deal with the output latency of a shift register or I/O expander. That saves 3 or 4 pins.

Ultimately, anything involving measuring or generating a precise servo pulse would require a crystal or else a clock line from the Arduino. And programming a PIC (and therefore designing ICSP into the servo I/O board) would be more trouble than it's worth. Right?

update 2: ATmega328 doesn't have a bajillion input capture/output compare channels like the HC12. Also, it's an 8-bit processor! How quaint. It does allow any I/O pin to trigger a pin change interrupt, though, so I can use that ISR with a free-running timer to measure pulse lengths. And I'll stagger the output pulses.

Also, I don't really need the extra pins at all. This count just shows that I have exactly as many as I need. And if I really need to, I can cannibalize the SCI Tx/Rx pins.

No comments:

Post a Comment