All About Circuits Forum  

Go Back   All About Circuits Forum > Circuits and Projects > The Completed Projects Collection

Notices

The Completed Projects Collection A collection of completed projects from All About Circuits forum members. Comment, ask questions, and add to their ideas.

Reply   Post New Thread
 
Thread Tools Display Modes
  #1  
Old 05-01-2012, 07:01 PM
MMcLaren's Avatar
MMcLaren MMcLaren is online now
Senior Member
 
Join Date: Feb 2010
Location: Michigan, USA
Posts: 646
Default Project: PIC 4-Digit 99 Minute Timer

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 board
Select All
Software

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...
Attached Images
File Type: jpg 4-Digit #2.jpg (77.7 KB, 863 views)
File Type: jpg 4-Digit Silk.jpg (61.5 KB, 91 views)
File Type: jpg 4-Digit Schematic.jpg (107.4 KB, 716 views)
File Type: jpg 4-Digit #3.jpg (182.2 KB, 100 views)
Attached Files
File Type: hex 16F1828 4-Digit Photo timer.hex (2.0 KB, 94 views)
File Type: txt 16F1828_4-Digit_Photo_timer.c.txt (14.4 KB, 134 views)

Last edited by MMcLaren; 06-12-2012 at 02:58 AM.
Reply With Quote
The Following User Says Thank You to MMcLaren For This Useful Post:
RRITESH KAKKAR (05-03-2012)
  #2  
Old 05-03-2012, 05:06 AM
Bill_Marsden's Avatar
Bill_Marsden Bill_Marsden is offline
Super Moderator
 
Join Date: Mar 2008
Location: Dallas, TX (GMT-5 w/ DST)
Posts: 19,042
Blog Entries: 5
Default

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.
Reply With Quote
  #3  
Old 05-03-2012, 07:36 AM
MMcLaren's Avatar
MMcLaren MMcLaren is online now
Senior Member
 
Join Date: Feb 2010
Location: Michigan, USA
Posts: 646
Default

Quote:
Originally Posted by Bill_Marsden View Post
What replaces the crystal oscillator?
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:
If you add the crystal and 2 capacitors, do they take over the timing function? If they do, is it more accurate?
Adding the crystal and capacitors and modifying the program will allow using the crystal as the time base for the timer function. A 32 kHz watch crystal is typically rated at 30ppm and so accuracy should improve dramatically. I'll be testing the 32.768 kHz crystal option soon and I can probably provide a second version of the 99 Minute Timer program that supports the crystal time base in the future, if requested.

Quote:
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.
I'd love to see what you come up with, Bill. I also think this project board would be a good candidate for the Seeed or Itead PCB service. Basically, both of these Chinese companies offer ten 50x50 mm (1.97"x1.97") boards with plated through holes, solder mask, and silkscreen for $13 (including shipping). I can make this design fit into that size footprint but I don't have the funds to take advantage of the service. However, if someone is interested in ordering boards from Seed or Itead, I would be happy to layout the board and provide the Gerber files for it (maybe that person will send me one of their ten boards in return for the favor, grin).

Cheerful regards, Mike, K8LH

Last edited by MMcLaren; 05-03-2012 at 08:25 AM.
Reply With Quote
  #4  
Old 05-06-2012, 12:44 PM
SgtWookie's Avatar
SgtWookie SgtWookie is offline
Expert Member
 
Join Date: Jul 2007
Location: In the vast midwest of the USA; CST
Posts: 22,038
Default

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.
Reply With Quote
  #5  
Old 05-06-2012, 12:57 PM
Bill_Marsden's Avatar
Bill_Marsden Bill_Marsden is offline
Super Moderator
 
Join Date: Mar 2008
Location: Dallas, TX (GMT-5 w/ DST)
Posts: 19,042
Blog Entries: 5
Default

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.
Reply With Quote
  #6  
Old 05-06-2012, 02:02 PM
MMcLaren's Avatar
MMcLaren MMcLaren is online now
Senior Member
 
Join Date: Feb 2010
Location: Michigan, USA
Posts: 646
Default

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.
Reply With Quote
  #7  
Old 05-06-2012, 05:25 PM
panic mode's Avatar
panic mode panic mode is offline
Senior Member
 
Join Date: Oct 2011
Location: Mississauga, Ontario
Posts: 1,096
Default

is that what you count on for buzzer too? listed part number is rated for only 1.4..2V
Reply With Quote
  #8  
Old 05-06-2012, 10:48 PM
Bill_Marsden's Avatar
Bill_Marsden Bill_Marsden is offline
Super Moderator
 
Join Date: Mar 2008
Location: Dallas, TX (GMT-5 w/ DST)
Posts: 19,042
Blog Entries: 5
Default

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.
Reply With Quote
  #9  
Old 10-23-2012, 02:28 PM
MMcLaren's Avatar
MMcLaren MMcLaren is online now
Senior Member
 
Join Date: Feb 2010
Location: Michigan, USA
Posts: 646
Default

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
So, anyone interested in a 4-digit Alarm Clock program? Or, would anyone like an updated 99-minute timer program that uses the crystal timebase?

Cheerful regards, Mike
Attached Images
File Type: jpg Clock v1.jpg (63.9 KB, 221 views)

Last edited by MMcLaren; 11-07-2012 at 03:01 PM.
Reply With Quote
  #10  
Old 10-23-2012, 07:53 PM
SPQR SPQR is offline
Senior Member
 
Join Date: Nov 2011
Location: Los Angeles
Posts: 379
Default

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.
Reply With Quote
Reply   Post New Thread

Tags
, , , ,


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:35 PM.


User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License.
Powered by vBulletin
Copyright ©2000 - 2014, vBulletin Solutions, Inc.