PIC Countdown Timer

This project is intended as a countdown timer for a UV exposure box for PCB development that uses fluorescent UV lamps (it will also work with any other lamp, don’t worry). It is based around a PIC16F627 micro and has following features:

  • adjustable time in 15-second increments (up to 10 minutes)
  • lamp preheat feature
  • two button operation (with audible feedback)
  • countdown alarm (when timer reaches zero)
  • relay for lamp switching
  • 7-segment display

10 minutes?

I have chosen the upper time limit of 10 minutes which should be more than enough for most applications and initial time is set for a 5 minute countdown (I’m preparing a revised software which will load initial time from EEPROM so it can be configured manually). Step increment of 15 seconds has been chosen partially due to ease of operation because there are only two buttons – time adjustment and start/stop. Time adjustment is incremental meaning that each time you press the button time is incremented by 15 seconds. When upper limit is reached time is reset to zero and the process repeats. Start/stop button is used for, you will never guess, starting and stopping the timer with lamp preheat feature.

Serving it warm

Lamp preheat was added due to necessity – fluorescent lamps take some time to achieve full light output. It wouldn’t be a problem if it took exactly the same on every lamp turn-on, but that’s not the case as you might have guessed. What’s even worse is the fact that if you use multiple lamps with separate ballasts not all lamps will turn on at the exact moment. I have a situation where 2 out of 3 lamps turn on and the 3rd lamp still flickers for a couple of seconds then finally turns on. This kind of bugged me a little so I added the lamp preheat feature which basically turns on the lamps but doesn’t start the countdown (countdown is initiated by a second button press). If your lamps behave properly (incandescent or LEDs) you can simply double-click the start/stop button and it will skip the preheat function.

Bring it on

Countdown timer is separated into two boards – mainboard and I/O board. Mainboard PCB contains the power supply, lamp relay and PIC with its associated circuitry. I/O board contains the displays and buttons for user interface and the boards are connected via two 8-pin ribbon cables allowing you to place the I/O board where ever you want (i.e. outside the UV exposure box). Entire circuit can be powered from a small transformer with a secondary rating of 6-24V but I would recommend to keep the input voltage below 15V because of the voltage regulator IC.

Mainboard I/O Board

As you can see from the schematics, entire circuit is quite common and simple. Displays are multiplexed meaning that they are driven one by one, really fast, so they seem to be constantly on due to persistence of vision. One nice feature with the 16F62x PICs is their internal RC oscillator which is accurate enough for this purpose and frees up two additional pins. As for the power supply, 7805 IC regulator seems to be all time favorite with DIYers and I’m no exception. You might want to fix it to a small heat sink especially if you are going to put the circuit next to the lamps in a closed box.

Use the relay to switch the live (or “hot”) AC wire!

Hi-res schematics and board layouts can be found at the end of this article.

Operation

Timer operation is nice and simple, just the way I like it! As mentioned before, you adjust the time with the TIME ADJ button and start or stop the timer with the START/STOP button. While adjusting the time the display will obviously show the time. When START/STOP button is pressed once the timer will go into lamp preheat mode and the display will alternate between “HEAT” and set time (you can still adjust the time if needed). On a second button press the timer will start the countdown and the display will show remaining time. When the countdown is complete the display will show a blinking “DONE” text (or rather “dOnE” on 7-segment displays) and an alarm will sound for indication which can be cancelled by pressing any button.

Flash before use

I have provided HEX files for 16F627(A) and 16F628(A) PICs so you can use whichever you have at hand. Configuration data is in the HEX file provided you select correct device before loading the file. In any case, all fuses should be off except power-up timer. Oscillator must be configured for IntRC with I/O functionality (since RA6 and RA7 are used for driving the buzzer and relay).

Give it to me

Here is the documentation available for this circuit. You can download individual items or an entire archive if you want to save a few clicks. Each PCB layout has a component view (bottom + top + silkscreen) to assist in component placement. Layouts are 600 DPI images so keep that in mind before printing (board dimensions are also available).

Downloads

Hi-res schematics:
Mainboard, I/O Board

PCB layouts:
Mainboard, I/O Board

HEX files:
16F627, 16F627A, 16F628, 16F628A

Complete archive:
PIC Countdown Timer

Things to improve for Rev 2.0:
– remember last selected time and recall it on turn-on
– load configuration from PIC’s EEPROM (time limit, time step, audible button feedback, alarm and preheat bypass)


  1. Vane says:

    Marko sta da komentisem to ti je Prekrasen i edukativen proekt bravo za tebe,produzi samo taka..Pozdrav od Makedonija

  2. […] Arcom Leave a Reply Visited 1 times | Tags: Pic Microcontroller, […]

  3. Alberto says:

    Hi I’m from Argentina, thank you very much for the timer down the arm and it worked pefect, but I need 60 minutes you could put the hex to 60 minutes down timer.
    thank you very much

  4. Toni says:

    Hi i’m from macedonia, this is a cool project. but also I need 60 minutes you could put the hex to 60 minutes down timer.
    thanks in advance

  5. Rich says:

    A lot of searching for a UV exposure timer, and this is the one.

    Excellent layout. Good work

  6. Dragan Ilic says:

    Napravio i radi iz prve 😉

    Evo kog klipa da se vidi rad uredjaja:

    http://youtu.be/7_EiRKyL4JY
    http://youtu.be/xmRefZYdkEQ

    PCB i ostao ovde:
    http://www.elektronika.ba/forum/viewtopic.php?f=9&t=8050

    Srdacan pozdrav autoru 😉

  7. sotiris says:

    It is a nice project …. But my bread must stay in oven more than 10 min. I would like to have the asm or hex file for 99 min … if it is possible.
    Thank you ….
    I will wait to get the file to my e mail.
    (sotirishellas is my name on youtube… you can see my projects …)
    sotiris tsirikoglou (from greece)

  8. Russell says:

    Hi Marko,

    Thanks for the great post, any chance you could E mail me the source code for the timer, like to see how it’s done. Thank you

  9. Adrian says:

    Hi.
    I simulate on Proteus and the displays are not working.
    Maybe there is some adjustment to do on PROTEUS.
    Can you send me the PIC project files .c and.h.

    Regards
    Adrian

  10. Matthew says:

    Hello.

    Is there a problem if I just removed the lamp from the circuit?

    I’m mainly interested on the countdown function.

    Thank you anyway.

Leave a Reply

  • 2014: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
  • 2013: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
  • 2010: Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec