View Full Version : Count down clock
Aurbo99
01-02-2008, 12:23 PM
This was in last nights chat, I thought I'd post it here before I loose my train of thought.
http://ourworld.compuserve.com/homepages/Bill_Bowden/pic_ck.htm
Contains the code for a PIC 16f628 clock
but its displaying on small 7 segment led displays.
Now jump to this board it has two areas of interest, one being the unit itself
http://www.kmitl.ac.th/~kswichit/Led/Led.html its shows a 595 driven display needing some input for the clock.. Butcher an old alarm clock for its guts or use a pic as suggested last night.
The second being the circuit showing the scalable led segments'
I think if you take the first Link, and adopt the scalable led segments from the second and run them from a-g on the first.
Only thing needed is to mode the pic code in the first URL to count down instead of up.
This link uses a pic 16f84 to count down but only displays min,sec
http://www.piclist.com/techref/microchip/cntdn/index.htm
A few links to scare or inspire...
HOLY SMOKES!!! --> http://forums.bit-tech.net/showpost.php?p=1185721&postcount=284
Making them big... --> http://forums.bit-tech.net/showthread.php?t=70643&page=23
great I need to add another line to my "Xmas to do list"
Ben
Frankz
01-02-2008, 07:26 PM
I see countdown clocks mentioned on various forums every year.
It would be nice if someone could come up with a fairly standard design for one, like is done for controllers.
Frankz
01-03-2008, 10:13 AM
here:
http://computerchristmas.com/ForumBoard/read.php?f=4&i=1414&t=1316
(and multiple other posts in that thread)
Peter Olsen came up with a countdown clock using a picaxe and a real time clock and 595's. He's driving 8 segments, instead of 7, the extra segment used to create letters instead of digits.
Couldn't this be simplified to use mbi5027's, stick with 7 segments just for a clock display, and switch ssr's?
.
acewingman
01-09-2008, 05:54 PM
Found this really cool 2' x 12' clock that looks real simple to make and it is HUGE!
http://www.sparkfun.com/commerce/present.php?p=GPSClock-1
Each segment is attached to a RJ45 jack and looks like it can be controlled just like mini 7 segment leds...
P. Short
01-09-2008, 06:13 PM
Frankz,
If Peter has a working countdown clock (too many posts in that thread for me to read), and you can get the design files, it should work.
--
Phil
Aurbo99
01-20-2008, 01:54 PM
Here is my first crack at this.. had it on the Breadboard last evening but never put power to it. Still hacking away at the code for the 18F4620
Why an 18F4620? It came as a free sample x3, has more than enough ouputs to handle digits individually.
Still not sure if this will fly or smoke.. but its here for you all to rip apart..
I'm still tempted to put in a ULN2003 or some similar IC to carry the loads for the LED's
Cheers
Stevehttp://users.eastlink.ca/~lsjdupuis1/images/CountDown2.bmp
Aurbo99
01-20-2008, 03:25 PM
This version, I think will be safer to use as the ULN2003 will protect the uC from the led current.
Time to get this thing ticking.. I hope. =)
http://users.eastlink.ca/~lsjdupuis1/images/CountDown1.bmp
P. Short
01-20-2008, 04:01 PM
The LED drive circuitry isn't quite right. Since the 2N5401 transistors aren't wired up correctly, I'm not sure what voltage you were going to use for driving the LEDs, but you need a lot more than 5V to drive five LEDs in series. Also, you need some method of controlling the current through the LEDs.
--
Phil
Wombat
01-20-2008, 04:54 PM
the transistors look like PNP transistors and are showing wrong. you would need NPN transistors and have the emmiter going to ground. and also a higher supply voltage to the LED's. I would also suggest a resistor in the emmiter leg to do a constant current source limiting to the LED's
Aurbo99
01-20-2008, 05:58 PM
My bad..
I had 12 and 24 volts set up.. I labelled it as 5
I'm looking at keeping it 12VDC.
All the Q's do look backwards.. dont they..
Back to the drawing board..
Cheers
Aurbo99
01-20-2008, 06:01 PM
go figure..
I posted versions 2 and 1 in that order..
I was supposed to post version 12 and 13..
Now how can I delete those to avoide more embarrassment. =P
Aurbo99
01-20-2008, 06:49 PM
OK,
This was the last revision on the schem.. Hopefully it addresses the goof ups on the previous two images.
I'm beyond my comfort zone on this project so be gentle =P
But I've learned a hell of a lot so far.
http://users.eastlink.ca/~lsjdupuis1/images/CountDown14.bmp
Wombat
01-20-2008, 07:02 PM
Why did you use the transistors when you already have the driver chip as you are only drawing about 20ma from the LED's as they are in series just put them directly on the ULN 2003 chip and have common Annode going to the supply so you dont need the PNP transistors
Wombat
01-20-2008, 07:05 PM
you have the display as a common Annode so that wont work with the PNP transistors Has to be Common Cathode
pixeldigger
01-20-2008, 08:02 PM
Not wanting to hijack,
But I am making my own countdown board with coro, 50 light strings, SSRs and a NI-DIO-96, controlled by VB6.
Anyone interested when I finish ,Ill share the code.
Wombat
01-20-2008, 08:17 PM
another thing with your design is the DP output needs an NPN driver before the PNP transisitor otherwise you'll put 12V though the PIC chip
Smoke will escape!!!
Wombat
TERBObob
01-20-2008, 08:48 PM
Enlarge maybe ?
http://www.webx.dk/oz2cpu/clock/countdown.htm
TERBObob
01-20-2008, 09:09 PM
Dupicate post --- sorry
Wombat
01-20-2008, 09:22 PM
not much different design that one.. its mainly the output drivers that are wrong with this design how its hooked up to the PIC is not much different.
I would just use the same setup he has now and run it with resistors in each LED leg into the ULN 2803 chip. then use an extra NPN transistor on the Decimal Point 1K resistor to PIC
that will give up to 50mA drive to the LED's plenty for this design
Wombat
Aurbo99
01-20-2008, 10:42 PM
Cant really make any excuses for my mistakes folks..
headcold + drugs + boredom = my schems..
Thanks for correcting the glaring errors.
I'll redo the schem tomorrow after work..
Aurbo99
01-20-2008, 10:59 PM
Why did you use the transistors when you already have the driver chip as you are only drawing about 20ma from the LED's as they are in series just put them directly on the ULN 2003 chip and have common Annode going to the supply so you dont need the PNP transistors
Ok, drop the Q's all together and connect the ULN2003 as it is minus the Q's to "a-g" segments.
RD0-RD7 do not go to a-g but rather goes through a ULN2803 and is CA instead of CC?
Man, I really spun myself around on this one..
Thanks again for the critiques.. keep them comming! =)
Wombat
01-20-2008, 11:47 PM
Sorry if I confused you I think I confused myself earlier. You will need to have the PNP transistors as well for the Anode's of the displays. the 8th Display will need both NPN and PNP to drive the Anode.
You will need the driver ULN2003 chip for the cathodes of each segment a-f and DP will need NPN transistor to drive the DP Cathode.
I hope that is less confusing
A ----|>----- K
Wombat
Aurbo99
01-31-2008, 02:07 PM
Okay..
I'll be semi-afk the next week or so while I prep for my 6 month tour.
Here is my current CDC with what I hope are all the schematic glitches out of the way.. I had to go back to my old dusty books!
I'll mill my pcb once I can get my new pcb mill running.
Take a look, let me know what you think.
http://users.eastlink.ca/~lsjdupuis1/images/CountDown41.bmp
Aurbo99
02-13-2008, 07:46 PM
OK.. I've reached a crossroads on this project.
The circuit looks ok, the bugs seemed to be worked out according to the datasheets.
Where I'm stuck is simple. I cant code the PIC. :confused:
While its very easy to program a PIC.. its something entirely different to create a code that make it sing and dance.
What I need to do now is to have the PIC latch to the 595/2003 chip and light up each segment one at a time and then move on to the next digit.
Any PIC from a 16F627a to the 18F6420 would work in theory.
So I'll throw this out to you guys. Whats needed to advance this project any further at this point is a test code.
Lets narrow it to something many of you have programmed and perhaps coded for.
PIC =16F627A or 16F628
Latch/Driver = http://focus.ti.com/lit/ds/symlink/tpic6c595.pdf
Project = test each segment of each digit..
Once I can get my hands on a test code in BASIC, I can twiddle away at it over the summer to get the timer code running.
and Now the Crossroads..
Change the WHOLE layout.. to a 5x7 led matrix with scrolling message capabilities.. sort of a mini LedTriks.. the parts count will not change much..
The digits already use up 35 led's per Digit.. and a 5x7 will also use 35.. so no real change there.
The specialized 595/2003 combo reverts back to a normal 595 and transistors.
The dual voltages are removed.. everything goes back to 5vdc.
Without any overly specialized code a larger 18F Pic could handle some extra text.
The countdown clock becomes a scrolling countdown clock with added text capablities.
Need some input of this folks..
Steve
Aurbo99
02-14-2008, 11:33 AM
I found a bit of code that uses a 10F200 and a 595 to run a routine.
I looked at the code, written in C, I think I was able to change it to use a 16F627A by comparing the #defines pins between the 10F200 and the 16F627A.
If one of you coders could take a look and tell me if I'm on the right track with this, it will help move this project a bit closer to completion.
If I'm understanding this correctly, then the following things change on the last schem.
Input buttons RA1-RA5 are removed.. A single button circuit is now on RB7 which will just advance each segment in order.
RC3 - RCK becomes RB6 - DIMM
RC4 - SRCLK becomes RB5 - CLK
RC5 - SER becomes RB4 - DATA
#Include <16F627A.h>
__Config(UNPROTECT&MCLRDIS&WDTDIS); //Configure Word
#define Fuc_key RB7
#define DIMM RB6
#define CLK RB5
#define DATA RB4
unsigned char disp_data;
unsigned char key_pressed,last_key_pressed;
unsigned char Value;
unsigned char time;
//The total of cathode
const unsigned char Digital_TAB[]={0xff,0xfc,0x60,0fda,0xf2,0xb6,0xbe,0xe0,0xfe,0xf 6,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
void change(void);
void LED_data(void);
void LED_display(void);
void delay_2ms(void)
{
unsigned char i,j,k;
for(i=0:i<5:i++)
{
for(j=0;j<200;j++)
k--;
}
}
void change(void)
{
key_pressed=Fuc_key;
if(key_pressed==0)
}
}
last_key_pressed=key_pressed;
}
void LED_data(void)
{
unsigned char i;
for(i=0;i<19;i++)
}
if(i==disp_data)}Value = Digital_TAB[i];}
}
}
void LED_display(void)
{
unsigned char i;
unsigned char U;
U=Value;
for(i=0;,i<8;i++)
{
DATA = U & 0x01;
CLK = 0;
U = U>>1;
}
CLK =0;
CLK =1;
}
void main(void)
{
OSCCAL=0;
TRIS = 0B11111000;
OPTION = 0B10011111;
while(1)
{
change();
LED_data();
DIMM =1;
LED_display();
DIMM = 0 //Active-low Output Enable
delay_2ms();
}
}
Cheers
Steve
P. Short
02-14-2008, 12:17 PM
The code is hard to read because there are so many typos in it, as well as not being very family safe.
--
Phil
P. Short
02-14-2008, 12:49 PM
Here is a version that should be a little bit better. I took the code that you wrote, cut and pasted it into an editor, and tried to fix the syntax and functioning as best I could. There appeared to be stuff missing (especially in the 'change' routine), and lot of minor syntax errors (wrong brackets, colons instead of semi-colons, etc). The changes that I made were based on what I thought would be sensible, not on any knowledge of the exact language that you're using.
There is no guarantee that I caught all of the syntax errors, nor any guarantee that I didn't introduce new ones.
--
Phil
#Include <16F627A.h>
__Config(UNPROTECT&MCLRDIS&WDTDIS); //Configure Word
#define FuncKey RB7
#define DIMM RB6
#define CLK RB5
#define DATA RB4
unsigned char disp_data;
unsigned char key_pressed,last_key_pressed;
unsigned char Value;
unsigned char time;
//The total of cathode
const unsigned char Digital_TAB[]={0xff,0xfc,0x60,0xda,0xf2,0xb6,0xbe,0xe0,0xfe,0xf 6,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x00};
void change(void);
void LED_data(void);
void LED_display(void);
// The actual delay may vary, depending on the actual processor clock speed
void delay_2ms(void)
{
unsigned char i,j,k;
for(i=0;i<5;i++)
{
for(j=0;j<200;j++)
k--;
}
}
void change(void)
{
key_pressed=Funckey;
// increment disp_data when key is released
if ((key_pressed==1) && (last_key_pressed==0))
{
disp_data = disp_data + 1;
if (disp_data == 19) // make sure that disp_data isn't too big
{
disp_data = 0;
}
}
last_key_pressed=key_pressed;
}
void LED_data(void)
{
if ((disp_data >= 0) && (disp_data<19))
{
Value = Digital_TAB[disp_data];
}
}
void LED_display(void)
{
unsigned char i;
unsigned char U;
U=Value;
for(i=0;i<8;i++)
{
CLK = 0;
DATA = U & 0x01;
CLK = 1;
U = U>>1;
}
}
void main(void)
{
OSCCAL=0;
TRIS = 0B11111000;
OPTION = 0B10011111;
// Some PICS may need additional initialization to turn off the analog
// features of the processor (such as comparators and ADCs).
while(1)
{
change(); // handle switch transitions
LED_data(); // do output lookup
DIMM = 0;
LED_display(); // clock data to the 595 (or 595 clone)
DIMM = 1; // Rising Edge Latch Enable
delay_2ms();
}
}
Aurbo99
02-14-2008, 12:57 PM
Thanks Phil.
No clue about the errors.. I typed it exactly as posted and changed only the #defines..
Thanks for the corrections..
Time to see what it will do if anything.
Cheers
Steve
Powered by vBulletin® Version 4.1.10 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.