Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

single-sided pcb layout challenge

Status
Not open for further replies.
I want to make Interrup on every 1 Second using Timer1.. Plz guied me in this way.

Thanks
 
Instead, they can use displays with pins on the sides- they make the trackwork easy.
 
Ayne said:
I want to make Real time clock using PIC16F877A.( Clock Frequency 20 MHz.)

I want to ask that TMR0 or TMR1 or TMR2 interrupt is not enough accurate for time(1 Second)...

Or What is the best way for making an accurate time delay???

Thanks.
There are several ways to improve RTC accuracy. One method I use is a simple soft 'trim' routine on the 1.0-msec Timer 2 interrupts to adjust the 1-second "heartbeat" to within plus or minus 250-nsecs (with my 16-MHz xtal). This provides much finer frequency adjustment compared to a ceramic trim capacitor in the crystal oscillator circuit.

Here's what the code looks like;

Code:
;
;  ISR_Trim routine is used to adjust the RTC 1-second period to
;  within plus or minus 250-nsecs to make up for a crystal which
;  may be slightly off frequency.  The routine adds or subtracts
;  one 250-nsec count (1 Tcy) from Timer 2 for the first 'CCTR'
;  number of 1-msec interrupts each second. Theoretical accuracy
;  to within 8.0 secs/year, not including temperature drift and
;  crystal aging.
;
;   variables:  CCNT, correction count from EEPROM [00 to FF]
;               CVAL, correction value from EEPROM [FF or 01]
;               CCTR, correction counter reloaded from 'CCNT'
;                     variable each 1-second period
;
;       range:  ±255 250-nsec counts/second (±63.75 usecs/sec)
;
ISR_Trim
        movf    CCTR,W          ; correction counter 0?           |B0
        bz      ISR_Sw_Input    ; yes, branch, else               |B0
        decf    CCTR,f          ; decrement counter               |B0
        movf    CVAL,W          ; get correction value FF or 01   |B0
        addwf   TMR2,f          ; apply 1 Tcy timer correction    |B0
Code:
;
;  reload timer Trim correction counter once-per-second
;
        movf    CCNT,W          ; reload correction counter var   |B0
        movwf   CCTR            ;                                 |B0

I should mention that I can't seem to get better than about 3/4 second drift per month so it seems my fine adjustments at this point are simply chasing crystal aging and temperature drift.
 
Last edited:
Ayne said:
I want to make Interrup on every 1 Second using Timer1.. Plz guied me in this way.

Thanks

Ayne,
As you want to use a 20mhz crystal, you cannot generate an interrupt every second because timer1 cannot count high enough even with it's prescaler set to 1:8.
A good option would be to use the microchip suggestion of a 25ms interrupt by setting timer1 to 1:8 prescaler and offset to 49910 (C2F6H).
On each 25ms interrupt, the interrupt routine will have to reset the timer and decrement a counter so that every 40 interrupts it can increment the seconds.

When you have that all working, you may want to add an adjustment facility to increase or decrease the timer interval by a very small amount every x interrupts to improve the timekeeping.
 
Ayne said:
Mike, K8LH

Plz share the code here (if u don't mind).

I want to make clock similar to this but with big 7-Segment Display.

I will make my self a Big 7 Segment Display with LEDs.

Thanks.
The code is close to finished but still untested because I haven't finished wiring up the prototype board. The transistors and half of the display are wired up but I haven't touched it for many weeks now. I will try to get to it soon.

Mike
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top