EV Logger
A MSP430 based datalogger for an electric vehicle
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Electric Vehicle Datalogger

Introduction

This project uses an MSP430 (specifically, the MSP430F5529) to log data from various channels to be used on an electric vehicle. This project is designed for use on the MSP-EXP430F5529LP experimentation board which is available from Texas Instruments.

Specification

There are six analogue channels broken out on the development board, plus a user potentiometer. Additionally, there is a CMA3000 3-axis accelerometer which is capable of running at up to 400Hz. The analogue channels (including the pot) are sampled and logged at 1kHz. The accelerometer is also logged at this frequency though analysis of the output will confirm that its value only changes at 400Hz.

Software Architecture

The software documented here is written specifically for the project, but libraries and hardware abstraction layer utilities are used from various sources which are documentented in the code. Licenses for these parts of the code are respected and as such, copyright notices will be found in some source files where they were used as the basis for the code.

The main functionality for the datalogger is in the Logger module. The overall architecture overview is that we set up a timer to interrupt at the log frequency, which collects available data and puts it into a buffer ready to be transferred to the SD card. It then invalidates the data and triggers another conversion run such that on the next interrupt, the new data will be ready.

A software controlled RingBuffer is used to store data before it is transferred to the SD card, and a full ring buffer implementation can be found in the Logger module. This is generic and can be used in other projects. The size of this buffer is controlled by SD_RINGBUF_LEN, and should be as large as possible for best performance but should never be smaller than the sector size (usually 512 bytes for FAT16).

The peripherals are controlled by separate modules, see ADC, Accelerometer, UART particularly. Documentation for how these are configured can be found in the relevant source files; here it suffices to note that CPU time is minimised by use of DMA in the case of the ADC and an interrupt controlled finite state machine (FSM) in the case of the accelerometer. The UART is principally for debugging purposes and is not set up for speed (it currently busy-waits during transmits) and as such, should not be used in production runs of the firmware builds.

The onboard peripherals, perticularly the CPU core clock and system wall clock timer are controlled by the System module, relevant documentation is contained within.

Building the Firmware

A Makefile is provided to build the firmware using the GNU mspgcc toolchain. Builds of this toolchain are available for Windows, OS X and Linux though on Windows you will need to set an IDE up as appropriate since the Makefile will not work (unless you use cygwin). To build the firmware using the Makefile please change to the source directory and run $ make. Flashing the device is done using mspdebug over the Spy-by-Wire interface, and can be enacted by running $ make flash. Cleaning the build directory (deleting all object files, dependency list files and binaries) can be done using $ make clean.

Authorship

Jon Sowman, University of Southampton j.sow.nosp@m.man@.nosp@m.soton.nosp@m..ac..nosp@m.uk. Please get in touch with any questions or comments.