Timer and 12F509


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2006
    Posts
    60

    Default Timer and 12F509

    Hello

    I want to use the PIC 12F509 to monitoring one impuls in a Timewindow from 0 to 16 seconds, that means on power up a Timer starts and if i not receive one impuls until 16 seconds the programm stop, if the impuls come the Timer cleared to count again.

    The 12F509 have no interrupt pin, than i must poll the pin, correct?
    Have anyone make this with a 12F509? I have not programmimng anything with Timer, have anyone a sample code for the 12F509 with Timer

    Thanks
    Best Regards
    Pedro

  2. #2
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default 16.0000000000 seconds or

    Hi,

    How accurate do you need this 16 seconds to be and how long is is the signal you are looking for?

    A simple way would be polling the pin in a tight loop with a short delay inside.

    Lets say you have a delay of 10 ms in the loop and do this loop 1600 times you should end up with a 16 second time window.

    If you need more accuracy yuu can adjust the delay by using delay_us if timing is critical..

    You didnt mention the clock frequency but unless it is really slow it will be hard to get 16 seconds time by just using a timer... in that case you need to reset it several time or count how many times it overflows... or something

    /me
    Last edited by Jumper; - 3rd November 2008 at 14:05.

  3. #3
    Join Date
    Jul 2006
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Hello Jumper

    I have two Jumpers that i read at power up to choose four possible timings
    16 seconds, 18, 19 and 20 seconds
    I want use on the PIC 12F509 the internal 4Mhz oscilator

    Best Regards
    Pedro

  4. #4
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default So?

    I might be slow.. but I still dont understand fully.


    You have 2 jumpers you can read at startup to set the time window.. so you get 4 different times (16,18,19,29 sec).. I am with you this far.

    Then you say you look for something to happen during this time window... if it happens.. then you start a new time window to look again... if it doesnt you stop the program.

    so...

    power up
    check input pins
    load a word variable with the correct time (1600 for 16 s and 2000 for 20 sec)

    start_again:

    n=0
    for n =0 to word variable
    check for your signal
    if you find your signal goto start_again
    Delay_ms(9)
    Delay_us(1000) ' here you can adjust the loop time
    next n

    STOP


    This could work unless you are looking for 16.000000000000000 seconds or similar. By adjusting the delay_us() time you can calibrate the loop time.

    Since you doesnt seem to have anything else to do during this time why do you want to use the timer?
    /me

  5. #5
    Join Date
    Jul 2006
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Hi Jumper
    You are right, i don't need to use the Timer

    Thanks

    Regards
    Pedro

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