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.

Digital clock tips

Status
Not open for further replies.

metallica_boy

New Member
I'm new in microcontroller but i have been reading programing it and i need to make digital clock i made some easy progam by it.
I need some tips about digital clock i will use TMR0 timer on pic16f887 and it has 8 bit timer/counter i need to make interrupt comand when it counts 60s increment minutes by 1 and when it counts 60m increment hours by 1 and return to 1h at 12h .
i will use 4MHZ crystal
any tips plz :confused:
 
Hi,

There are several ways to create a real time clock.

You can use an external clock chip like the DS1307 or use timer0 as you say, though 4mhz does not divide neatly down to 1 second, but if you see Roman Blacks Zero Error 1 second clock in this forum it can be done.

Timer 1 is also designed for a cheap 32k watch crystal to be attached to act as 1 second timer, I have used this on many projects, see the datasheet for details.

Also mention what programming language you are using
 
There are lots of PIC clock code examples on the internet and on this forum, you should download some and look at the way they have counted seconds and minutes, hours etc. Some of that depends on your display type, which you have not mentioned.

As for making an accurate 1 second using TMR0 and a 4MHz xtal, there are lots of C code examples on this page;
https://www.romanblack.com/one_sec.htm
and it is quite easy to do.
 
Not the best picture but this is a pendulum clock I built the other year from a dead hard drive servo mech, the display is on the pendulum weight, it uses a 32khz xtal in conjunction with timer 1, the code for it is easy and the clock maintains 3 seconds a week without any adjustment.
Not much more I can do for you though the code for this is asm.

jitter 002.jpg
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top