SOLVED - How to calculate Timer preload


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default Re: SOLVED - How to calculate Timer preload

    What are the 10000 and 8 stand for in the equation?

    Ioannis

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: SOLVED - How to calculate Timer preload

    I couldn't tell you. See Art's thread above.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  3. #3
    Join Date
    Aug 2011
    Posts
    460


    Did you find this post helpful? Yes | No

    Default Re: SOLVED - How to calculate Timer preload

    Quote Originally Posted by Ioannis View Post
    What are the 10000 and 8 stand for in the equation?
    The 10000 comes from the fact that the intr code is assuming a 100Hz interrupt (MHz -> 100Hz = 10000),
    and the 8 is an attempt to compensate for the number of instruction cycles it takes to reload the timer.

    Demon -
    How long of a time period are you looking to measure?
    If you can live with 65536 counts (the 16-bit timer count) then you can just drop all the interrupt code, let the timer free-run, and just subtract two unsigned timer values... something like this:
    Code:
    start_time = readtimer()
    'code you wish to time is here
    elapsed_time = readtimer() - start_time

  4. #4
    Join Date
    Aug 2011
    Posts
    460


    Did you find this post helpful? Yes | No

    Default Re: SOLVED - How to calculate Timer preload

    If you let the timer free-run, then at 32MHz using FOSC/4 as the timer clock and 1:1 prescaler you can count up to 8192us (8ms) with 125ns/count.
    Setting the prescaler to 1:8 extends this to 8x8192 = 65536us (roughly 65ms), but your resolution drops to 8x125ns = 1us

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default Re: SOLVED - How to calculate Timer preload

    Tumbleweed, that's the thing. I'm still at the research phase; trying to determine what Henrik calls velocity sensing.

    Next challenge: Velocity sensing, ie a way to detect that the user wants the value to change by a lot and not have to turn the knob 600 turns. Getting that just right seems to be tricky, even the big boys don't always... (I've never tried).

    I can flick the rotary encoder at 3.5msec from low-low to high-high, but still need to determine that cut-off speed.

    https://www.picbasic.co.uk/forum/sho...000#post156000


    And then it hit me as I'm typing this post. I can use the logic probe in real-time to find that sweet spot, instead of writing code to display that on LCD (or xmit via HSEROUT). And that's where things get crazy cause all that extra code and I/O would definitely throw off my readings.

    Can't see the forest for the trees...
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. Replies: 11
    Last Post: - 23rd August 2024, 03:13
  2. large preload includes
    By longpole001 in forum PBP3
    Replies: 4
    Last Post: - 29th January 2020, 12:16
  3. T1 interrupt and preload confusion
    By amgen in forum General
    Replies: 2
    Last Post: - 14th September 2011, 04:24
  4. Hanging on SERIN2 - SOLVED!
    By blainecf in forum Serial
    Replies: 1
    Last Post: - 13th July 2006, 18:55
  5. Dmx Solved !!!!!!!
    By oscar in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 2nd July 2005, 22:57

Members who have read this thread : 2

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