Real knight rider flasher - PWM LED Chaser

Microcontroller Topics
Post Reply
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Real knight rider flasher - PWM LED Chaser

Post by Rksk » Wed Dec 14, 2011 12:08 pm

Intro
I was searching a way to build a Kitt-scanner (the classic effect seen on the car in theKnight Rider TV series) since long time. After lots of searches I found the solution.

This neat little circuit provides 8 LEDs directly driven from the PIC along with a single mode control switch. The firmware elsewhere on this page drives the LEDs with a 5 bit PWM signal providing each of the 8 LED channels with four levels of intensity; off, dim, mid, bright. A number of sequences are programmed into the firmware to provide some interesting visual effects and chase sequences, including the classic effect seen on the car in the Knight Rider TV series.

The software has sequential, random and manual sequence run modes and manual advance to the next sequence in any mode. The selected sequence and mode are also saved to non-volatile memory so it will always restart in the selected mode.

You can use it with different sized LEDs and mixed colours, as well as fewer than 8 LEDs. As well as using it as a LED chaser it is great for adding effects to toys and models.

However, if you just want a cool LED chaser without having to write any code, a ready written LED chaser program including 34 chase effects with source code files are provided at the bottom of this page.
[media]http://www.youtube.com/watch?v=SKe67xZG8Sg[/media]


Schematic
Schematic
Schematic
Schematic.jpg (55.03 KiB) Viewed 5393 times
User Operation Guide
The program has three modes of operation.

1.Manual mode will run the same sequence continually. When the switch is pressed it will skip to the next sequence in program memory.
2.In auto-sequential mode, the program runs through each sequence in program memory until it reaches the end of all defined sequences at which point it restarts from the first one.
3.In random mode the program selects sequences randomly.

When the code is running in any mode, a short press of the switch will make the controller skip to the next sequence.

To enter setup mode, press and hold the switch. Once it enters setup mode one of three LEDs will light indicating the current run mode. A short press of the switch cycles through the three modes. When the desired run mode has been selected, press and hold the switch to exit setup and return to run mode.
pwmLEDmo.jpg
pwmLEDmo.jpg (12.68 KiB) Viewed 5393 times
The current mode and selected sequence are automatically saved to the PICs internal non-volatile EEPROM memory 10 seconds after the last switch press. When the LED chaser is next powered up it will load and start running using the saved mode and sequence.

Description of Sequence Data
The data used to create the sequences is held in a separate include file. You can add, remove or edit this data to create your own chaser sequences.

To make the creation of the data file easier a set of macros have been defined which are used to create the sequence data. This is described in the below image.
pwmseqflow.jpg
pwmseqflow.jpg (124.59 KiB) Viewed 5393 times
If you download the source code and look at the file named pwmc_SeqData.inc you can see the data used in the project. You might want to edit this file as a starting point to create some sequences of your own.

Notes:
1.In manual mode, when the repeat count reaches zero it will restart the same sequence, to advance to the next sequence press the switch.

2.In Random mode it will the select a random sequence number to run. If the Mirror flag is true for that sequence it will also randomly choose to mirror the data or not.

3.In auto-sequential mode if the Mirror flag is true it will run the sequence and then repeat it with the data mirrored.

Firmware
The PIC microcontroller requires programming with the firmware which you can download below.
ASM code.zip
(16.93 KiB) Downloaded 1030 times

Supported PICs
The PIC 16F628A is a newer revision of the 16F628. As far as the circuit and firmware on this page are concerned the two are functionally identical and you can use either part.

The PIC 16F84A can also be used with the firmware on this page. You will however need to make changes to the hardware design and PCB layout to include an external 4Mhz crystal and load capacitors or a ceramic resonator, since the 16F84A doesn't have the internal oscillator of the 16F628A.

The PIC16F84A and 16F627/627A only have 1K of program memory. You will need to remove some of the sequences from the pwmc_SeqDat.inc file before assembling the code otherwise it won't fit in the limited program memory on these devices. (MPLAB will generate errors if the code is too big for the device)
Post Reply

Return to “Microcontrollers”