Sensor monitor program for IO boards.
iomon/lib
contains modified, simplified versions of Atmel Software Framework
peripheral drivers. Insofar as possible, unused code and functionality has
been removed; particular remaining areas of bloat include the ADCIFA driver
and the various clock drivers.
iomon/src
contains the main program code, divided into files mainly by
peripheral device or support function:
cobsr.c
is a serial framing protocol which encodes data packets to ensure null bytes are never found in the content, so they can be used as packet delimiters;comms.c
is the primary serial driver code for sensor monitor output and control input;crc8.c
implements 8-bit, lookup-table-based CRC calculation;gp.c
implements ADC and GPIO interfaces;hmc5883.c
implements an I2C driver for the Honeywell HMC5883L 3-axis magnetometer;i2cdevice.c
provides a framework for writing I2C device drivers, allowing initialization and read command sequences to be defined as data structures, and handling timeouts and power-down/reset logic;main.c
contains the main entry point, initialization routine and event loop;mpu6050.c
is an I2C driver for the Invensense MPU-6050 3-axis accelerometer/gyro;ms5611.c
is an I2C driver for the Measurement Specialties MS5611 barometric pressure/temperature sensor;pwm.c
implements PWM management in response to packets received from the CPU interface;twim_pdca.c
is used byi2cdevice.c
and the various I2C drivers to handle I2C "transactions" (write/read sequences) and DMA-based I2C commands;ubx_gps.c
is a USART-based driver for the u-blox UBX binary protocol.
The iomon
program is an event loop which aggregates data received from
devices via I2C, SPI, UART, ADC and GPIO interfaces, and transmits
it in packets to a processing device. No interrupts are used, and the
per-packet processing time is guaranteed to be less than 1ms.
Each sensor has a device driver responsible for initializing it (the
*_init(void)
procedures) and reading its output (the *_tick(void)
procedures). Device driver tick procedures are called every millisecond, and
generally implement a state machine that handles:
- Detection of timeout/error conditions;
- Cycling the device power enable to ensure a hard reset;
- Start-up configuration;
- The primary read sequence and any conversions necessary to obtain usable data.
After sensor data is read, it is written to the output parameter log; at the end of the event loop, the packet is sent via the UART.
The primary configuration mechanism is the board header file, in
iomon/src/boards
. These header files provide a mapping of all MCU pins to
the appropriate functions, as well as assignments between internal AVR32
peripherals and the external devices. The board file in use is determined by
iomon/src/config/conf_board.h
.
The UBX driver requires that the GPS module has been configured appropriately, and the configuration has been saved to Flash. The required settings are:
CFG GNSS
: Disable SBAS and QZSSCFG MSG
: Enable NAV PVT on UART1CFG NAV5
: Set dynamics mode toairborne <4g
CFG PRT
: Set UART1 to UBX in, UBX out, 921600 baudCFG RATE
: Set measurement period to 250ms (or 100ms if supported)CFG CFG
: save to flash
TODO
Requires AVR Studio 6. Configure project for AT32UC3C; 1512 part is currently used but could probably run on any 0* or 1* part.
Only via JTAG at this stage; just flash the MCU using whatever Atmel programmer is convenient.
USB DFU bootloader might be added later depending on how frequently we need to re-flash in the field.
GPS configuration requires u-blox u-center
- Connect CPU board cable to 8-pin port;
- Connect cable harness to 30-pin port.