Practical PIC Projects

   

UFO round LED Chaser Kit
for PIC16F628A (#432)

 


 

 


Description

This page is has been written to support construction of the UFO LED Chaser Kit #432K.

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.

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.   The firmware is the same as that used in the linear PWM LED chaser project.

The design is deliberately simple with each LED being directly driven from a PIC I/O pin.  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.  See FAQ

The firmware pre-programmed into the PIC16F628A supplied with the kit includes over 34 chase effects and sequences.   If you're interested in PIC micros and programming and want to modify the sequences or create new ones, the source code and programmer ready HEX files is provided at the bottom of this page. 


Schematic

Download schematic in PDF

Circuit Description

The heart of the LED chaser is the PIC 16F628A microcontroller, IC2. The program that runs on this chip controls the LEDs attached to the output port pins.  Resistors R1 thru R8 limit the current through LED1 - LED8 to a safe level that won't damage the PICs I/O ports or LEDs.  Resistor R9 provides a pull-up for the input connected to switch S1.  R10 holds the PICs MCLR reset signal high.

Capacitor C1 is used to decouple the 5 volt power supply to the PIC.  If you're building the circuit on a breadboard or stripboard you should ensure it is located close to the PICs Vdd connection (pin 14 ).

Power is supplied to the circuit via the V+/V- solder points.  The voltage regulator used is a LM2931-5.0, low-drop-out regulator and will maintain regulation with an input voltage down to 6 volts.  Input voltage for the LED chaser should be between 6 volts and 14 volts to ensure power dissipation remains within limits.  The LM2931-5.0 regulator is designed for battery powered and automotive applications and includes internal current limiting, thermal shutdown, as well as reverse battery connection without damage to itself or the circuit behind it.  Capacitor C3 is important and must be fitted to prevent instability of the regulator output

Typical current drawn by the circuit with all LEDs on is only around 80mA; with all LEDs off it's under 1mA. 

Notes:

  • The latest high brightness LEDs are very bright even with 330R current limiting resistors. However, if you do need to change these resistors for some reason take into account the absolute maximum current that the on-board voltage regulator can deliver is 100mA.
     
  • If you do change the current limit resistors to suit different LEDs you should aim for the LED current for each output to be no more than 10mA ( 80mA total for all 8 outputs)
     
  • The 330R resistors are specified so that with a LED forward voltage of 1.7 volts and the circuit operating at 5 volts the LED current will be 10mA.  LEDs with a higher forward voltage will draw less current.  Most LEDs have a forward voltage greater than 1.7 volts so the circuit will work with the majority of LEDs and stay well within the design limits of the circuit.
     
  • The LED forward voltage parameter for a specific LED will normally be found in the manufacturers data sheet.

PCB Artwork and Overlay

Download PCB component overlay

 

Download PCB artwork

Component List

This project is no longer available as a kit. 

Please see the new version of the UFO Round PWM LED Chaser project here
 


Construction notes:

Follow these instructions carefully.  Some components need to be fitted the correct way round and others look similar but have different values so must be fitted in the correct position.

click on the photo's for large version, click on the back button to return to this page.


Fig.1

Fig .2

Fig. 3
 

In Fig 1.  Start by fitting the two 10K resistors.
 
These have brown-black-orange-gold bands. It doesn't matter which way round they are fitted.

Fig 2. Next fit the eight 330R resistors. 
   These have Orange-Orange-Brown-Gold bands. It doesn't matter which way round they are fitted

Resistor colour codes explained

Fig 3.  Next fit C1 and C2.  These are marked '104' on one side.

 


Fig.4

Fig.5

Fig.6
 

Fig 4.  Fit capacitor C3.  This must be fitted the correct way round.  You will see that one lead is shorter than the other.  This short lead should go through the hole in the PCB indicated in the photo (right)

 


Fig 5.
Next fit IC2 (LM2931 LDO voltage regulator).  This has three leads and must be fitted the correct way round.  The body has a 'D' shaped profile when viewed from above and it should be fitted so it matches the marking on the PCB overlay

Fig 6. Now fit the socket for IC1.  You will see a small notch in one end.  It should be fitted so the notch is at the same end as the small semi-circle marking on the PCB overlay.
 


Fig.7

Fig.8

Fig.9
 

Fig 7. / 8. You now need to fit the switch S1.   This can be fitted to either the component side or the solder side of the PCB.  Which side you fit the switch will depend on how you are going to mount the assembled board.  

The leads on the switch are a tight fit.  Position the ends of the leads into the holes in the PCB, then push with even pressure using the tips of your thumbs on either side of the switch body. It should then snap into place. Don't try and push it into place using the button. 
 

Fig 9.  You can now solder the LEDs into position.

  The LEDs must be installed the correct way round.  Each LED has two leads and one lead will be shorter than the other.  The short lead normally indicates the LED Cathode terminal and it must be fitted into the hole toward the arrow point on the PCB overlay (see photo right)

 


Fig.10

Fig.11

Fig.12
 
Fig 10.   Solder the battery connection lead to the solder points as shown.   There is a hole in the PCB and the leads should be passed through this, then inserted into the solder points.  This provides strain relief for the wires.

At this point, if you have access to a voltmeter, apply power to the board and measure the voltage between pins 5 and 14 of the IC1 socket.  It should measure somewhere between 4.8 and 5.2 volts.  If it doesn't investigate why and correct the problem before the next step.

Fig 11.  Finally you can fit IC1, the PIC 16F628A microcontroller.  The PIC has a notch in one end of the device and assuming you have fitted the socket correctly, the PIC should be inserted into the socket with the notch in the PIC at the same end.  Referring back to Fig 10. the notch should be at the right hand end as seen in the photo.

With all parts assembled, check the underside of the board to make sure the solder joints are good and there are not shorts or solder bridges.   If the inspection is okay, you can now connect the assembled board to a battery or power supply.

The input voltage to the board should be between 6 volts and 14 volts.

Fig 12.   This photo show the completed LED chaser operating.  The LEDs have been bent at a right angle to change the visual effect of the chaser.



All #432K kits sold after 20 August 2011 will include a DPDT slide switch to enable the circuit to be switched on and off without disconnecting the battery clip.

To fit the switch, cut one of the battery lead wires about half way along its length.  Then solder the cut ends of the leads to the centre and one edge terminal on the switch as show in the photo below.

Supplied switch has two x M2 fixing holes on 19mm centres.
 

Power Supply

The board can be powered from a 9 volt battery such as a PP3, or a 12 volt battery including connection to a car electrical system.  Alternatively it can be connected to a suitable DC power supply rated between 6 and 14 volts and able to supply at least 100mA. 

In the UK you can buy a suitable power adapter from Rapid Electronics.  You'll also find similar power adapters available from retail stores and e-Bay.

Rapid Electronics   5W SWITCH MODE PLUGTOP PSU 9V 550MA RC Part # 85-2926


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.

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 Sequence data flowchart  (also available as a JPEG image right)

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:

  • In manual mode, when the repeat count reaches zero it will restart the same sequence, to advance to the next sequence press the switch.
     
  • In Random mode it will 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.
     
  • 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 supplied in the kit is pre-programmed with the firmware below so you don't need to do anything.

Should you need to reprogram the supplied PIC with the original code supplied, use the HEX file below.

The HEX files are ready to program straight into the respective PIC chip.  The latest code version 1.0.7 supports the PIC 16F628/628A and PIC 16F88 microcontrollers.

The Source code will allow you to create your own sequences and then reassemble the code to use them with the UFO LED Chaser kit.  Quick guide to reassembling firmware using MPLAB

If you need a PIC Programmer I strongly recommend the Microchip PICKit 2, this is available from suppliers world wide or direct from Microchip.  It's reasonably cheap to buy and reliable. 

Not got a programmer?  Buy a pre-programmed PIC from the On-line store

Description Filename Download link
     
Source code for 16F628A/88 pwmchaser107.zip
V1.0.7 03/04/2009
download
HEX file ready to program into the PIC.
Use with 16F628 / 16F628A only
pwmc_main107_ufo.HEX
V1.0.7  03/04/2009
download
checksum D9A8
     
     

FAQ

Can you or how can I make it it run more than 8 LEDs?

This is probably the most frequent of the frequently asked questions :-)

The project is an 8 LED Chaser and the firmware was written to work as an 8 LED chaser.

There is no quick and easy change to make it a 9, 12 or some other number of LED chaser.  If you need a chaser with more LEDs then this project is not suitable for your needs.

Will it work with 3mm LEDs?

Yes, 3mm LEDs will work as will 8mm and 10mm LEDs.  3mm LEDs can be mounted on the PCB, 8mm and 10mm LEDs would need to be connected by flying leads.

Can I use less than 8 LEDs?

Yes, since the sequences are user definable you can create sequences that use less than 8 LEDs.

I only want it to run one sequence, can it do that?

Since the current mode and selected sequence are saved to NVRAM, it always powers up in the last mode and running the last sequence.  Therefore if you select manual mode and the sequence required, it will run only that sequence until you change it.

Do the LEDs have to be the same colour?

No they don't.  If you want you can mix different coloured LEDs.  You can also mix 3mm/5mm/8mm/10mm LEDs if you want too.

Can you add a button or potentiometer to change the speed?

The sequences don't have a speed as such, the data for each step in a sequences includes a hold time which has to elapse before moving to the next step in the sequence.  This hold time is user defined and can be different for each step in a sequence.  The speed a sequence runs at is therefore fixed in the data and there is no option to speed up or slow down a sequence when it is running.  See Description of Sequence Data

Can it run from a 12volt car battery?

Yes, should work fine from a car battery.  We suggest you include an in-line fuse of 500mA in series with the power lead to the board.

Can you modify the code to run on a PIC type xyz?

The code has been written to run on three of the most popular PICs available.  If you want to modify the source code it could be made to run on other PIC types, however we won't modify the code.

 

 

Contact us: