Hi Darrel
I was wondering if elapsed timer code is accurate enough to make a digital clock and calender, showing time and date.
Thanks
Hi Darrel
I was wondering if elapsed timer code is accurate enough to make a digital clock and calender, showing time and date.
Thanks
Hi crematory,
That depends on the accuracy of the crystal being used, and the ambient temperature.
And, you'd probably need to have some kind of backup battery, to keep it going during any power outages.
I think I calculated it at around +/- 4 minutes per year with a standard 20mhz crystal. It was around 20 seconds/year with one of those temperature compensated TTL Oscillators.
<br>
DT
Originally Posted by Darrel Taylor
4 Minutes a year, that is more than acceptable for me, I will be happy with that in deed.
I was wondering if you can through a hint for using the rest of interrupts in the PIC when using the elapsed timer code, shall I use your way to handle other interrupts, or what should I exactly do.
Thanks Darrel
I've been working on something that'll answer that question, but it's still in bits and pieces right now. I guess it's time to finish it.
Give me a couple days to put it together. Hopefully it'll be worth the wait.
<br>
DT
Darrel,
I will be waiting for the answer.
Good luck
Almost there. I keep getting sidetracked.
I hope you're using MPASM. I've been unable to make it work with PM.
<br>
Hi Darrel
MPASM would never be a problem, I always keep tracking the new versions of microchip compiler (MPASM), as being almost there, I hope you finish it as soon as possible
Thanks alot
Hi Darrel,
Could you suggest a good "one of those temperature compensated TTL Oscillators" please ?
Also, if aging for an oscillator is stated, say, +/-5ppm a year or +/- 100ppm a year, what would it mean in your elapsed timer application?
Last question, if I modify your routine to work for 100years, forget about power failures etc., and use a good osc as you may suggest, what would be a possible problem as years pass by?
Thanks.
--------------
Last edited by sayzer; - 24th December 2008 at 18:43.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
The way I understand it is that the Total PPM error stated for crystals includes 10 years of aging.
Say you have a crystal with +/-50ppm tolerance. When you first install the crystal it will be very close to the specified frequency (+/-5ppm), and it's anticipated that in 10 years, the frequency will still be within the stated 50ppm @25°C.
Most crystals have an aging of less than 5-10 ppm per year. If you've come across a crystal that has +/-100ppm per year, throw it in the garbage.
For a recommendation, I'd still have to say the DS32KZ is the best for the price at less than $10.
http://pdfserv.maxim-ic.com/en/ds/DS32kHz-DS32KHZS.pdf
With an indoor application it will hold to +/- 2 ppm, which is 1 minute per year.
For outdoor apps, it's 7.5 ppm, or 4 minutes per year.
TCXO's for the CPU's osc at 10-20Mhz are more expensive, but some are really accurate. Like this one that holds to 0.28 ppm, or about 9 seconds/year. So after your 100 years it would only be off by 15 minutes. ($30US, 3.3V)
http://www.conwin.com/datasheets/tx/tx236.pdf
There are so many possible combinations of tolerance, compensation and time, it's difficult to give a direct answer. But for any of the possibilities, if you can come up with the anticipated PPM Error, this calculator will help to determine how much it would affect the long term timing of a clock.
Press the Recalculate button after changing the Freq or Error.
<table cellspacing="10"><tr><td valign="top"><OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" WIDTH="400" HEIGHT="250" ><PARAM NAME="MOVIE" VALUE="http://www.pbpgroup.com/CrystalErr/CrystalPPM.swf"><PARAM NAME="PLAY" VALUE="true"><PARAM NAME="LOOP" VALUE="true"><PARAM NAME="QUALITY" VALUE="high"><EMBED SRC="http://www.pbpgroup.com/CrystalErr/CrystalPPM.swf" WIDTH="400" HEIGHT="250" PLAY="true" LOOP="true" WMODE="opaque" QUALITY="high" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT></td><td valign="top">For normal crystals, the PPM tolerance is specified at 25°C. Temperature extremes in either direction can cause a 50ppm crystal to change as much as 100-300 ppm. Granted, those are extremes that would kill a human being, but somewhere in-between are the changes from summer to winter in an outdoor application.
The TCXO (Temperature Compensated Crystal Oscillator) will actively adjust the frequency according to the temperature, so that the frequency is always within the stated PPM tolerance. It usually does this by changing the voltage to a Varactor Diode, which changes the capacitance on the crystal. While it does compensate for temperature, the relative aging of the device remains the same as an uncompensated crystal.
</td></tr></table>
Happy Holidays!
DT
Hi Darrel,
first of all compliments for this excellent job.
I would use "DEFINE OSC 48", because I need to compile for PIC18F4550 using USB.
And using USB in PBP we must set "DEFINE OSC 48" due to PLL...
When I try, I always receive the error "Symbol not previously defined (TimerConst)".
So I tried setting the right TimerConst in the "Elapsed_INT-18.bas" file...
I read all in this thread, and tried using the TimerCalc form, but it seem is impossible getting: 10,000 "Ticks", 100 Freq and 48 OSC all together.
So it means it's impossible using USB and Elapsed Timer at the same time ?
Is there a TimerConst that work with osc @ 48 MHZ ?
Mark
Hi Mark, and thanks!
Yes there is.Is there a TimerConst that work with osc @ 48 MHZ ?
In 2003 I hadn't heard of a 48mhz pic
Hmmm, let's see here,
pulling up mister_e's PicMultiCalc ... (Timer Helper page)
http://www.picbasic.co.uk/forum/atta...achmentid=2957
and ... uht oh, with the existing timer load routine, the best we can do is 99.999hz. Not so good for a long-term timer.
But not a problem, increasing the timer reload time to 10 instructions (add 3 nop's), with a Timer1 prescaler of 2, the reload value is 5541.
I'm sure that will elicit more questions, but I'll let you give it a go first.
<br>
DT
I have given this a good reading over but some of it has gone straight over my head.
I intend to built a control unit based around a 16F877 which will include menu's to control output pins on the PIC, Obviously within the menu there will likely be instructions which will keep the processor busy for a few Ms at a time. My project ideas originally were to include an external clock device such as the DS1307 or the DS1603 to keep track of time whilst the rest of the program (Menu's etc etc) is running and keeping the processor busy.
I was advised on this forum to look at this thread and if this is what I think it is then it will be truly fantastic for my project.
My problem is that when the PIC returns from a menu I want it to display the time on the LCD. Am I right in what I have read in thinking (Besides setting LCD pins & oscillator etc) I can simply include all of the attached files in post number 1 of this thread but modify the 'loop' subroutine within "Test_Elapsed_LCD.pbp" file, to include my menu software?
I understand that this thread creates a time elasped counter and not a clock, but I do have in mind ideas to include buttons with which I can set the hours, minutes & seconds. I will also miss out the displaying of 'Days' when it comes to print on the LCD.
Apologies for what might seem to be a simple question to you guys but I have only been playing for a couple of months with PIC's and I am trying to learn from other people's examples.
Thanks.
hackableFM.
Bookmarks