Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to accurately count seconds?

I currently am working on a digital watch that tells time in hexadecimal. I have everything working on it even! The displays, switches, and even the duration of a minute is functioning. However, past a minute is where things get less than desirable...

Currently I have a 4 MHz crystal oscillator inputting into the microcontroller, a PIC16LF68. At the end of the code I have it set to increment a counter. It takes somewhere between 107 and a 108 loops for a second to pass. So after that many loops (just picking one at random) it will increment the second counter. Obviously after a long enough period of time has passed its fast or slow.

Is there a better way to implement this? I know I could try to make the code slower, so it lines up better with another count number, but that seems like is a rather sporadic solution.

0 Kudos
Message 1 of 3
(155 Views)

This NI forum is mostly for National Instruments products and there is probably a better place elsewhere to ask your question.

0 Kudos
Message 2 of 3
(136 Views)

What is the best way to accurately count seconds?

 

A hydrogen maser

 

SCNR

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 3 of 3
(110 Views)