Software Design

Our software was designed around two principles: the display must be updated, and power ought to be conserved. All else stems from this. Power conservation was acheived by having the microcontroller sleep almost all of the time it isn't doing useful work; busy waits are avoided in most cases. The display is updated every half a millisecond, and the chip checks whether it has work to do at this point. When the display is incremented, counters are updated telling other tasks how much time has passed. If a sufficient number of half-millisecond ticks have occurred, a given task will execute; when all tasks for a given tick have completed, the chip sleeps.

Display Update

The LED displays are updated by an interrupt which occurs every half millisecond. The display update follows this sequence: the displays are turned off, 16 bits are synchronously clocked out to two 8-bit shift registers wired in series, and the displays are turned back on. Each row of the LED array is on only one-eight of the time; the dual 7-segment display is on three-eights of the time as it requires more power. The display update interrupt also increments the task counters and will wake the chip if it is asleep.

Keypad Input

Reading in data from the keypad requires little processing and much waiting. The requires that one wait 5 milliseconds before reading in data after reqesting a given measurement. This is implemented by reqesting data immediately after reading in data, and only reading in data every 20 half-millisecond ticks. The input is processed only after a complete set of 11 reads have completed, at which point input disambiguation (analogous to debouncing for mechanical buttons) takes place in a seperate task.

SSC Simulation

The SSC simulation runs every n ticks if enabled, where the value of n and whether the simulation is enabled are chosen by the user interface. It updates internal variables. Another function translates these into an output buffer area which is read by the display-update routine. The PIC C version differs from our earlier VHDL implementation in several significant ways. It implements the same instructions. C, however, has a number of advantages: commands are executed serially rather than in parallel, actually making it easier to perform several complex logical operations (this is why instructions like ADD M(X), formerly three-stage, now only takes two; oddly enough, this is actually a closer model of architecture in many respects, though we were sometimes forced to use temporary variables to achieve the desired behaviors), C arrays are far easier to understand and implement than Altera's RAM and ROM MegaWizard functions, which largely function in a "black box" manner. One of the major disadvantages was the poor auto-indenting of the CCS PIC C compiler.

< Hardware | Troubleshooting >


Alexandr Pshenichkin and Cortland Setlow
Swarthmore College