PIR1.0 stays ever 1 ?!


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default calibration of a timer

    hello all

    to the entry above
    no one an idea why timer1 runs without a start command? did i done something obviously incorrect? thanks for a feedback

    the application is like a stop watch. i will control a loop of about ten minutes and this should be very exact. means about 20ms in relation of 10 minutes. to verify that in real time i need a good idea to control them in real world. for that i send a short serial command after start and one more after stoping the timing sequence. i look at the serial terminal on the pc for the timestamp (resolution 1/100s) when the messages arrived. unfortunalety the difference is not on each run the same.. i think it is a problem of the buffer at the pc end. pic is stable i think.

    anyone a good idea how i could verify and measure them also?

    thanks a lot
    i know it's only microcontrolling, but i like it!

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


    Did you find this post helpful? Yes | No

    Default

    mischl,

    I've found that you can rely 100% on the power-on states shown in the datasheets. So, there's no way that it's just starting by itself without something in the program doing it.

    Check all those "Magic Numbers" that were probably Cut&Paste at the top of the program. Make sure you aren't setting the wrong bit's somewhere.

    Of course, if we had the top of the program, we could look too.

    And, oh yeah. Third time for this link today...
    instruction execution time
    http://www.picbasic.co.uk/forum/showthread.php?t=365
    <br>
    Last edited by Darrel Taylor; - 7th March 2006 at 21:16. Reason: execution time
    DT

  3. #3
    Join Date
    Jan 2005
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    dear darrel

    thanks a lot for your message. alone the commitment "it must work" helps me a lot. i tested now a bit and it works fine! unfortunalety i don't know why... it seems that i had somewhere a "magic number" which i've deleted once ....

    also thanks for the instruction execution time link, i know them ;-)

    probaply i was not really clear : my problem is not "how many cycles i need" because i'm knowing that, my problem is "how long is acycle in realtime"?
    menas the instruction time on a 20mhz is 200ns. if i repeat them 5 million times, i need a second. but when the instruction time is only 199ns (only a shift of 0.5%) i get not 1.000s.

    so when i make a long time measurement for my ten minute timer, i should see if there is a small shift. that's what i need to check. so the idea was to send out a serial command at start sequence and send anotehr at end sequence. in theorie, this are xyz cycles equal to 10 minutes at the microcontroller. but my tests are around 50ms too short. ok, not the world. but when i want to build a timer for videoframes (25 frames a second) it's one frame away...

    so in fact that not ever get the same result, i first of all search for a exact method to measure before i want to calibrate. does anyone know how this is done at the olympic timer example?

    thanks a lot
    i know it's only microcontrolling, but i like it!

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


    Did you find this post helpful? Yes | No

    Default

    The problem may not be in the measurement technique.

    More than likely, it's due to two things. The first being ON INTERRUPT. Since it waits until the current Line of code has finished before it branches to the interrupt handler, you never know when the interrupt will actually be handled. If a Long Running statement like SEROUT is in progress when an interrupt occurs, it may be several milliseconds before it gets to the handler.

    The second problem comes from just Loading the required "Count" into the timer on each interrupt. This causes it to lose however many cycles it took to get to the handler.

    If you ADD the "Count" to the current timer value, it can compensate for the lost time. The way it works is ... Once the timer overflows from 65535 and creates an interrupt, the timers value is now 0, and the timer is still running. Once it finally gets to the interrupt handler, the timer value shows exactly how long it took to get there. So now, if you add "Count" to the timers value (plus the time it actually took to add it), you'll have accounted for everything, and Time will count normaly.

    Using the ADD technique with ON INTERRUPT will definately help. But, I would suggest moving to ASM interrupts if you need to keep Long Term time accuracy, or Short term precision.

    HTH,
    &nbsp; Darrel

    P.S. Since you mentioned it. Melanie's Olympic Timer shows one way to do the ADD thing. See the SetTimer routine.
    Last edited by Darrel Taylor; - 8th March 2006 at 23:16. Reason: Olympic sized Omission

Similar Threads

  1. Thermo 7 segments - little problem
    By fratello in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 27th July 2013, 07:31
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. 32 bit square root
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 6th May 2009, 03:37
  4. one line led light make image
    By bioul in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 12:19
  5. HSERIN doesn´t work
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th July 2007, 14:23

Members who have read this thread : 0

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