Elapsed Timer Demo


Closed Thread
Results 1 to 40 of 112

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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

  2. #2
    Join Date
    Jul 2005
    Posts
    65


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by Darrel Taylor
    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>

    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

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Jul 2005
    Posts
    65


    Did you find this post helpful? Yes | No

    Thumbs up That amazing Darrel

    Darrel,

    I will be waiting for the answer.



    Good luck

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Almost there. &nbsp; I keep getting sidetracked.

    I hope you're using MPASM. I've been unable to make it work with PM.
    <br>

  6. #6
    Join Date
    Jul 2005
    Posts
    65


    Did you find this post helpful? Yes | No

    Smile

    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

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    In fact, i don't know why PM still exist since it doesn't work anyway with any 18Fs. I always use MPASM.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    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>

    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

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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

  10. #10
    Join Date
    Aug 2005
    Location
    Italy
    Posts
    4


    Did you find this post helpful? Yes | No

    Exclamation Elapsed Timer @ 48 Mhz with USB.

    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

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Mark, and thanks!
    Is there a TimerConst that work with osc @ 48 MHZ ?
    Yes there is.
    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

  12. #12
    Join Date
    Feb 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    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.

  13. #13
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by hackableFM View Post
    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. ...
    It can do the things you are suggesting.

    But it's not a replacement for a battery backed-up RTC chip.
    Any RESET will lose the accumulated time.

    I have used it as a clock running on-chip, but on power-up it reads the time from an RTC. That way it doesn't have to continuously read the time via I2C and it's always available from the internal time clock.
    <br>
    DT

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. Get elapsed time while TIMER samples pulses
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th March 2009, 16:27
  3. Elapsed Timer Demo in a PIC12F675
    By Leonardo in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 21st November 2008, 00:01
  4. Totally Baffled with Elapsed Timer
    By CocaColaKid in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th June 2008, 21:01
  5. Darrel Taylor Elapsed Timer
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th March 2008, 01:22

Members who have read this thread : 4

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts