Project: PIC 4-Digit Single-Chip 24 Hour Clock

Thread Starter

MMcLaren

Joined Feb 14, 2010
861
Ok on using a different piezo, Bill, but I think you should take a closer look at the display footprint. Our display outlines look like they're the same size but my display has 16 pins with 0.4" spacing between rows while your display has 18 pins with 0.3" spacing between rows.
 
Last edited:

upand_at_them

Joined May 15, 2010
940
Since this is a modern PIC with an automatic internal pull-up on MCLR I think the 10K resistor pull-up can be done away with as long as the config is set to enable MCLR. I haven't tried it yet.
 

Thread Starter

MMcLaren

Joined Feb 14, 2010
861
Since this is a modern PIC with an automatic internal pull-up on MCLR I think the 10K resistor pull-up can be done away with as long as the config is set to enable MCLR. I haven't tried it yet.
Please note that the 10K resistor on RA3 is a "pull-down" to allow scanning the switches for active hi signals...

Cheerful regards, Mike, K8LH
 

upand_at_them

Joined May 15, 2010
940
This is an interesting project. I always learn something by building someone else's project. Thanks for posting it, Mike. I managed to squeeze it onto a 4x6cm board, which is smaller than the Radio Shack board. Although the roomier board makes for more space to grip when pressing the buttons.

I made some small changes. One is to swap pins A2 and A1. Using A1 for the buzzer prevents in-circuit serial programming with the PICKit2/3. Which is another change I made...adding a programming header. The header also serves as the power input. And I added a jumper to select the use of colon or decimal point.

30ppm on the crystal is about 1 second per 9 hours. The only watch crystal I had was spec'd for 50ppm, which is about 1 second per 5.5 hours...although it seems to be running better than that. I used 15pF for the caps since that's what the load calculation produced.
 

upand_at_them

Joined May 15, 2010
940
Thought I would clarify my previous statement in case anyone else decides to build this project and incorporate a programming header. It appears that my problem was the buzzer that I was using. The type with an internal oscillator driver does indeed interfere with in-circuit serial programming when sharing the RA1 pin, which is why I switched it to RA2. I swapped that buzzer for a less expensive magnetic transducer that is close to what MMcLaren used and it does not appear to affect ICSP. I did have to use a 220 ohm resistor to get the transducer to work across a range of power supply voltages, though, which may also have helped with ICSP. So just be aware of this.

Red LED display, I got around 12mA supply current with "0:00" on the display. Blue LED is around 9mA.
 

soyez

Joined Aug 17, 2020
51
I'd like to share a relatively simple "single chip" 4-digit LED Clock project that uses a PIC16F1828 microcontroller, a 32768 Hz crystal time base, a four digit LED display, and just a handful of other parts. This low parts count design is due in part to experiments with some very bright miniature multiplexed 4-digit displays which are available from Sparkfun in red, green, yellow, white (all $1.95), and blue ($2.50) colors.


Hardware

The circuit was built on a Radio Shack prototype board (sku 276-149) with a plastic laminated paper silk-screen glued onto the component side of the board. I used 30 guage Kynar wire and point-to-point wiring on the copper side of the board.

The circuit does not include column/digit driver transistors and relies on the combined ~250 ohm RDS(ON) resistance of the PIC I/O pin high side and low side FET drivers for segment current limiting. The display is refreshed one segment at a time (1/32nd duty cycle) to provide even brightness across the entire display.



Parts List
Rich (BB code):
1 ea. PIC16F1828-I/P (DIP package)
1 ea. 0.1-uf (100nf) ceramic capacitor
2 ea. 22-pf ceramic capacitors
1 ea. 32768 Hz (12pf) watch crystal
1 ea. 10 kOhm, 1/8th watt carbon film resistor
4 ea. 1N914 or 1N4148 silicon switching diode
1 ea. Sparkfun COM-09483 Red Common Anode 4-Digit Display
4 ea. generic momentary contact switch
1 ea. Soberton GT111P Piezo Speaker

Misc. sockets, connectors, prototype circuit board
Software

The HEX file in the ZIP file attachment can be used directly with a PICKIT2, PICKIT3, or similar device programmer to program the PIC16F1828. The program source file is also included in the ZIP file attachment. The program was written using the free/lite version of BoostC from Sourceboost and it uses 339 of the 4096 words of program memory available in the 16F1828.

The program configures the 16F1828 to run from the internal oscillator at 8-MHz and the Timer 2 module is configured to generate 250-usec (500 cycle) periodic interrupts. The Timer 1 low power oscillator is enabled for the 32768 Hz crystal. The ISR (interrupt service routine) is responsible for refreshing one new segment of the display each interrupt and it also polls Timer 1 for one second time-base intervals for the RTC. All thirty two segments of the display are updated once every 8-msecs for a 125-Hz refresh rate (1/32nd duty cycle).

Operation

The <SET> switch is used to toggle between "set" and "run" modes. Press <SET> to enter "set" mode and the "hours" display group will flash at a 2-Hz rate. While in "set" mode the <Rt> arrow key is used to toggle between the "hours" and the "minutes" display groups and the <Up> and <Dn> arrow switches are used to increment (+) or decrement (-) the value of the current flashing display group. The "hours" display group will rollover from 23 to 0 (+) or 0 to 23 (-) and the "minutes" display group will rollover from 59 to 0 (+) or from 0 to 59 (-). The <Up> and <Dn> arrow switches will repeat when held down. Press <SET> again to exit "set" mode and enter "run" mode (display stops flashing). While in "run" mode, the <Up> arrow, the <Dn> arrow, and the <Rt> arrow switches are disabled. Those switches are still sampled and debounced in the interrupt service routine and you'll still hear a "new press" beep when you press one of them, but they're ignored and cleared by the logic in the program.

Observations

This is the first time I've used a 32768 Hz crystal and so far it seems reasonably accurate, gaining just under one second per day, which I believe is within the 30 ppm crystal spec. I suspect this could be improved by grounding the crystal case and trying slightly different capacitor values (or a ceramic trimmer capacitor). Anyway, the accuracy is acceptable, for now, and I'm really looking forward to experimenting with some of the interesting PIC low power sleep modes that utilize the low power 32768 Hz crystal oscillator.

I hope someone finds this project useful.

Cheerful regards and happy Holidays, Mike
This seems to be a similar schematic as the clock circuit you posted. I have a half structured PCB for it on the off chance that it is. Right?

I'll likely place it into the activities gathering and post a connection on this post and in the other string when I am finished.
 
Top