![]() |
|
|||||||
| The Completed Projects Collection A collection of completed projects from All About Circuits forum members. Comment, ask questions, and add to their ideas. |
|
|
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
I'd like to present a relatively simple 4-digit 99 minute timer project. The low parts count design is a result of experiments with some very bright miniature 4-digit displays available from Sparkfun that come in red, green, yellow, white (all $1.95), and blue ($2.50) colors.
In addition to the Digital 99 Minute Timer presented here, the circuit design, with minor modifications, might support several other projects, including, but not limited to; () Digital Voltage Monitor () Digital Thermometer () Digital Thermostat () Repeating On/Off Interval Timer () Digital Alarm Clock () Digital Clock/Calendar/Alarm/Timer () Digital Stopwatch () Digital RPM Indicator Requirements You'll need a programmer of some sort to program the PIC16F1828 device and you'll also need a regulated 5 Vdc power source to power the circuit. You'll also need a simple transistor, opti-isolator, SSR (Solid State Relay IC), or similar driver circuit which will take its input from the active high output signal on the RA2 pin. The output circuit you choose depends on what you need to drive (relay, etc.) Hardware The wiring diagram shows several components that are not required for the 99 Minute Timer application. Specifically, you don't need to install the crystal and capacitors in the oscillator block and you don't need to install the two discrete 'A' and 'B' LEDs for this particular project. The little 4-digit displays are so bright that I decided to drive them one segment at a time (1/32nd duty cycle) directly from the PIC16F1828 I/O pins (no column/digit driver transistors). Due to the low duty cycle, I omitted current limiting resistors for the cathode segments, relying instead on 250 ohms combined RDS(ON) resistance of the I/O pin FET drivers inside of the PIC (about 150 ohms for a high-side 'sourcing' FET driver and about 100 ohms for a low-side 'sinking' FET driver). While the circuit supports any color display, please note that the red, green, and yellow displays have a VF of 2.1 volts, while the white display is 3.1 volts, and the blue display is 3.4 volts. This means that while the blue and white displays are bright and easily visible in a brightly lighted room, the red, green, and yellow displays are a bit brighter. I hope to add a software PWM brightness control to a future version of the program. Parts List Code:
1 ea. PIC16F1828-I/P (DIP package) 1 ea. 0.1-uf (100nf) ceramic capacitor 1 ea. 10 kOhm, 1/8th watt carbon film resistor 4 ea. 1N914 or 1N4148 silicon switching diode 1 ea. Sparkfun COM-09481 Blue Common Anode 4-Digit Display 4 ea. generic momentary contact switch 1 ea. Soberton GT111P Piezo Speaker Misc. sockets, connectors, prototype circuit boardSelect All The attached HEX file can be used directly with a PICKIT2 or PICKIT3 to program the PIC16F1828 device. The program was written using the free/lite version of BoostC from Sourceboost. While you can use the Sourceboost IDE (Integrated Development Environment), I chose the option to install BoostC into the MPLAB IDE. The program uses packed BCD "minutes" and "seconds" variables and the code to increment and decrement those variables may look a little strange to some programmers. Operation The <SET> switch is used to toggle between "set" and "run" modes. Press <SET> to enter "set" mode and the "minutes" display group will flash at a 2-Hz rate. While in "set" mode the <Rt> arrow key is used to toggle between the "minutes" and the "seconds" display group and the <Up> and <Dn> arrow switches are used to increment or decrement the value of the current flashing display group. The "minutes" display group will rollover from 99 to 0 or from 0 to 99 and the "seconds" 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). In "run" mode you press the <Rt> arrow switch to start or stop the Timer. An active high signal is available on the RA2 pin when the Timer is running. While the Timer is running and counting down, the <SET> switch, the <Up> switch, and the <Dn> switch 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. If you have any questions, please ask... Last edited by MMcLaren; 06-12-2012 at 02:58 AM. |
| The Following User Says Thank You to MMcLaren For This Useful Post: | ||
RRITESH KAKKAR (05-03-2012) | ||
|
#2
|
||||
|
||||
|
What replaces the crystal oscillator? If you add the crystal and 2 capacitors, do they take over the timing function? If they do, is it more accurate?
I may take the time to make a PCB for this design. If I do I will publish it here. I will get with you off line.
__________________
.. "Good enough is enemy of the best." An old engineering saying, Author unknown. General info: If you have a question, please start a thread/topic. I do not provide gratis assistance via PM nor E-mail, as that would violate the intent of this Board, which is sharing knowledge ... and deprives you of other knowledgeable input. Thanks for the verbage Wookie. |
|
#3
|
||||
|
||||
|
This project uses the factory calibrated internal oscillator running at 8 MHz. It's rated at 1% accuracy so it's probably more accurate than what you might expect from an ordinary 555 RC oscillator but you could still be off by plus or minus one minute at the end of 99 minutes.
Quote:
Quote:
Cheerful regards, Mike, K8LH Last edited by MMcLaren; 05-03-2012 at 08:25 AM. |
|
#4
|
||||
|
||||
|
That would be great - but ... a PCB would be of somewhat limited usefulness unless any individual using it would want to come up with their own gamma correction PWM scheme, unless you would also care to publish yours.
As it stands now, without such a scheme, there is no current limiting on the 7-segment LED display, so both the PIC and the display would be operating at far higher current than their ratings. I suggest that it would be quite challenging for a beginning programmer to come up with a suitable gamma corrected pwm scheme in time to prevent the display or PIC I/O pins from burning out. It might be a good idea to leave optional provisions for resistors on the board.
__________________
General info: If you have a question, please start a thread/topic. I do not provide gratis assistance via PM nor E-mail, as that would violate the intent of this Board, which is sharing knowledge ... and deprives you of other knowledgeable input. |
|
#5
|
||||
|
||||
|
Something I learned in the last couple of years, with CMOS operating at low voltage (which 5V qualifies) you don't need current limiting, the CMOS transistors do it just fine by themselves. The low voltage on the power supply is critical though, but this works well on CMOS 555's and 4017s. The clock project I am working on for the next submission also uses this.
The key is the power supply voltage though, it must be low. Goes to my tag line, it is good enough.
__________________
.. "Good enough is enemy of the best." An old engineering saying, Author unknown. General info: If you have a question, please start a thread/topic. I do not provide gratis assistance via PM nor E-mail, as that would violate the intent of this Board, which is sharing knowledge ... and deprives you of other knowledgeable input. Thanks for the verbage Wookie. |
|
#6
|
||||
|
||||
|
Hi Sarge,
I understand your concerns but they may not be relevant. I'm using the RDS(ON) resistance of the PIC I/O pin FET drivers for current limiting. If you get a chance, could you test the circuit? I could write a version of the program for the 16F690, if that would help. Anyway, I'd be delighted if you could show me how to get more than the 30-mA "peak" current spec for those RED displays using "direct drive" from a pair of PIC I/O pins which have a combined RDS(ON) resistance of approximately 250-ohms (VDD = 5 vdc). As for adding software brightness control... I have it working on an example (assembly language) Clock/Calendar/Alarm/Timer program but it will be a while before I can add that brightness control code to the 99 Minute Timer (C) program. I suspect there are many people who will just duplicate the project but for those few that want to study the code, I'm taking extra time to convert my assembly language code to C because I feel C code may be easier to understand. Cheerful regards, Mike Last edited by MMcLaren; 05-06-2012 at 02:31 PM. |
|
#7
|
||||
|
||||
|
is that what you count on for buzzer too? listed part number is rated for only 1.4..2V
|
|
#8
|
||||
|
||||
|
No, the buzzer is piezo device. There are many devices like these that can be overvoltaged safely, as long as some common sense is use. It is fundamentally a high impedance device, and draws almost no current.
__________________
.. "Good enough is enemy of the best." An old engineering saying, Author unknown. General info: If you have a question, please start a thread/topic. I do not provide gratis assistance via PM nor E-mail, as that would violate the intent of this Board, which is sharing knowledge ... and deprives you of other knowledgeable input. Thanks for the verbage Wookie. |
|
#9
|
||||
|
||||
|
FYI: I just added a 32.768 kHz watch crystal (and capacitors) to the circuit and initial tests indicate it's working great. This is the first time I've ever used a 32.768 kHz crystal and the low power Timer 1 oscillator module.
I don't have a new 99-Minute Timer program that uses the crystal time-base yet but here's my first "test" program that I used to verify that (1) I could initialize TMR1OSC correctly, (2) poll the TMR1IF flag correctly, and (3) preload TMR1 registers correctly for precise one second or half second overflows; Code:
;******************************************************************
; *
; File: 16F1828 32k v1.asm *
; Author: Mike McLaren, K8LH *
; (C)2012: Micro Application Consultants *
; : All Rights Reserved *
; Date: 22-Oct-2012 *
; *
; First Attempt Running Low Power 32.768-kHz TMR1 Oscillator *
; *
; *
; MPLab: 8.84 (tabs=8) *
; MPAsm: 5.44 *
; *
;******************************************************************
#include <P16F1828.INC>
errorlevel -302
list st=off
__CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _LVP_OFF
radix dec
;---< variables >--------------------------------------------------
cblock 0x20
endc
;---< constants >--------------------------------------------------
;******************************************************************
; reset vector *
;******************************************************************
org 0x000
v_res
clrf STATUS ; |B0
bra init ; |B0
;******************************************************************
; interrupt vector *
;******************************************************************
org 0x004
v_int
;******************************************************************
; main init *
;******************************************************************
;
; setup TMR1 for operation as low power 32.768-kHz oscillator
;
init
banksel T1CON ; bank 0 |B0
movlw b'10001101' ; 10------ TMR1CS source TMR1OSC
; --00---- T1CKPS prescale 1
; ----1--- T1OSCEN TMR1OSC 'on'
; -----1-- T1SYNC asynchronous
; ------0- unused
; -------1 TMR1ON timer 1 'on'
movwf T1CON ; |B0
;
; setup INTOSC for Fosc = 8-MHz operation (Tcy = ~500 nS)
;
banksel OSCCON ; bank 1 |B1
movlw b'01110000' ; |B1
movwf OSCCON ; INTOSC = 8-MHz |B1
stable btfss OSCSTAT,HFIOFS ; osc stable? yes, skip, else |B1
bra stable ; |B1
;
; configure I/O ports
;
banksel ANSELA ; bank 3 |B3
clrf ANSELA ; ADC off, digital I/O |B3
clrf ANSELB ; " |B3
clrf ANSELC ; " |B3
banksel LATA ; bank 2 |B2
clrf LATA ; |B2
clrf LATB ; anode digit enable pins 'off' |B2
movlw 0xFF ; active lo segment lines 'off' |B2
movwf LATC ; cathode segments 'off' |B2
banksel TRISA ; bank 1 |B1
clrf TRISA ; |B1
clrf TRISB ; |B1
clrf TRISC ; |B1
banksel 0 ; bank 0 |B0
;******************************************************************
; main loop *
;******************************************************************
loop
btfss PIR1,TMR1IF ; TMR1 rollover? yes, skip, else |B0
goto loop ; loop (wait for rollover) |B0
bcf PIR1,TMR1IF ; reset TMR1 interrupt flag and |B0
bsf TMR1H,7 ; set b15 for 1.0 second period |B0
bsf TMR1H,6 ; set b14 for 0.5 second period |B0
;
; flash segment A on left most digit at one second intervals
;
bsf PORTB,4 ; digit 1 anode hi (enabled) |B0
movlw 1<<RC0 ; mask for segment A cathode |B0
xorwf PORTC,F ; toggle digit 1 segment A |B0
bra loop ; loop forever |B0
;******************************************************************
end
Select All
Cheerful regards, Mike Last edited by MMcLaren; 11-07-2012 at 03:01 PM. |
|
#10
|
|||
|
|||
|
This newbie would love to do it!
I really like projects like this where I get something useful, have fun making it, and learn about electronics. (e.g., I just learned that sometimes you don't need current limiting resistors in line with LED's if you don't supply too much voltage, and have other semiconductors in line - posts 5 and 6 - thanks!) The potential use for other projects is also VERY interesting. I'll add it to my long "to make" list. Thanks very much for the post. |
|
| Tags |
| 4digit, minute, pic, project, timer |
Related Site Pages
|
||||
| Section | Title | |||
| Textbook | The Unijunction Transistor (UJT) : Thyristors | |||
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| can someone help me with my uc project (PIC & temperature sensor & LCD)? | voyage | Embedded Systems and Microcontrollers | 6 | 05-25-2011 08:36 PM |
| Creating timer in PIC | RG23 | Embedded Systems and Microcontrollers | 33 | 03-11-2011 04:40 PM |
| Pic project help for car ac condenser fan | 540itouring | The Projects Forum | 1 | 02-08-2011 08:02 PM |
| Minute clock timer alarm for one second | Nature Calls | General Electronics Chat | 3 | 05-13-2010 11:04 AM |
| Project for a 12 hour timer to relay | Flakman | The Projects Forum | 8 | 01-07-2010 10:56 AM |
| Thread Tools | |
| Display Modes | |
|
|