helmet software

The software is written in MPASM for assembling with the Microchip MPLAB Integrated Development Environment. The PIC16F88 is clocked from its internal oscillator running at 125kHz and the LED flashing is done by a timer interrupt. The 8-bit timer runs with a prescalar of 32 and thus overflows at 3.8Hz.

Every pin on Port B of the PIC16F88 lights one of the LED strings through a constant current driver and flashes it in a modified pseudo-random sequence. The data to control the flashing is stored in a 64-byte look-up table. The data in this table is a 255-bit long maximal length sequence with a single 1-bit added to the end to make it 256 bits (32 bytes). Each bit in the sequence is interleaved with a 1, so that the LEDs are mostly on. Thus making the table 64 bytes in total. In order to make the effect more random, the data read from the table for each bit on Port B is evenly staggered through the extent of the table.

All of the data table reading and Port B pin setting is done in the timer interrupt, so, after reset, the pointers are set up, the initial bytes read from the table and a starting value written to the Port B pins. The code then sits in an endless loop waiting for the timer interrupt.

The interrupt code simply rotates the data retrieved from the table and sets the Port B pins accordingly. After eight rotations, new data are retrieved from the table and the pointers incremented. Should a pointer reach the end of the table it is reset back to the start. This process continues until the power is switched off again.

listing and hex files



The source code can be downloaded by clicking the button to the left.


A hex file for programming your own PIC16F88 devices can be downloaded by clicking the button to the right.

Homepage     Helmets     Hardware     DIY Kabuki Drop