GSE, Instrumentation and Test Equipment

Digital Data Acquisition (DAQ) System

Firmware Page

Last Update, February 27, 2009, by Stephen Daniel

Data Capture Firmware

The DAQ system is built around a PIC 18F2455 microprocessor from Microchip.

The process was chosen for the following reasons:

  • We had familiarity with the PIC 18 line, including a significant investment in development tools.
  • This chip is available in a through-hole (DIP) package, avoiding the need to fabricate a complex surface-mount PCB
  • This chip has both a USB module and an SPI module to facilite communication with other parts of the system.

Unfortunately the chip has relatively little program and data memory. The memory limitations provided some challenges to the firmware design.

High Level Architecture

After some experimentation we settled on the following high-level architecture for the firmware.

  • The first 2KB of program memory are used as a USB bootstrap. This code is a lightly modified version of Microchip's USB bootloader. This code is never used during normal operation of the DAQ system.

  • The next 4KB of program memory is a flash-memory bootstrap. During normal operation when the PIC comes out of reset this code examines the position of the mode switch and selects a firmware package to load. The firmware is read off flash and run.

  • The last 18 KB of program memory are used to implement the various operating modes of the DAQ system. At present the following modes are implemented:
    • Mode 0: Run the UBS boot loader. This is mode is used to update the flash bootloader.
    • Mode 1: Runs a module that makes the contents of flash memory available over the USB as a USB mass storage device. A PC can see the flash memory as a small external hard drive.
    • Mode 2: Runs a module that implements a USB comm port. A PC can connect to this using a tool such as PuTTY or Hyperterminal. Users can interact with the DAQ system to control and configure it.
    • Mode 3: Runs a module that captures data onto the flash memory.

The various firmware modules do not directly interact except during system initialization.

Firmware Availability

The modules in the firmware that communicate over the USB are using Microchip's USB framework. Microchip's licensing allows me to freely distribute the binaries. I am unclear if I can distribute the sources. More work is needed.

The source code to mode 3, the data capture code, is free of licensing restrictions and my intent is to make it avaliable under a GPL.

I have not yet done the work to package up the binaries or the available sources, so I am not providing a link here. Interested parties should contact me directly.

PIC Tool Chains

The modules that use the USB hardware use Microchip's C compiler. However due to budget constraints, I use that C compiler in its free mode, which limits some object code optimization. The code has been carefully written to fit within the size limits listed above even with the optimization partially disabled.

The code to capture and store data was written using the BKND CC8E compiler, which I purchased. For small PIC 18 projects this compiler generates excellent code and is very easy to work with. Unfortunately code written for this compiler is not compatible with Microchip's compiler, or vice versa. (Both compilers extend the C language in useful and incompatible ways.)