Simple PIC based timer needed, any advice appreciated.


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Posts
    4

    Question Simple PIC based timer needed, any advice appreciated.

    Im new to this forum so hello everyone! Sorry if this is posted in the wrong place.

    I need a simple timer that will pulse for 2 seconds once in every (approx) 24 hours. Physical size must be small as it is to be fitted into existing equipment. Hence why I thought of a PIC solution. 5 volts available and it would need to trigger a miniture relay. Permanently connected to power so would need to reset and then wait a further 24 hours and send a pin high for 2 seconds again.

    I know its a simple request but Ive had no luck in finding anything on the web, so if anyone could point me in the right direction that would be very much appreciated!

    Chris

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    You could use instant interrupts elapsed timer example. Then look for the flag daychange. Check out this example for 24 hour timer: http://darreltaylor.com/DT_INTS-18/elapsed.html Keep an eye on DaysChange, and you should be able to make it happen.
    http://www.scalerobotics.com

  3. #3
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default

    Hi Chris,

    Every 24 hours starting when? Starting with power-up?

    How precise for the 24-hour interval? Is ±10 secs / day from internal oscillator ok? Or, do you need crystal precision?

    Regards, Mike

  4. #4
    Join Date
    Aug 2010
    Posts
    4


    Did you find this post helpful? Yes | No

    Default Timer

    Thanks for replies.
    I need this to force a hard reset on some telematics equipment. The devices do have built-in timers that can be used for a variety of events, including a system reset. However in practice they fail after a couple of months. This is why we need to have a completely independent timer that we can rely on to do its job. Like I say it would be permanently connected to 5 volts, so would need to start timing on power-up. Also after its 2 second 'on' period, restart again. The 24 hours isnt critical, just an ideal figure, once a day. If this fluctuated and became 22 hours or 26 hours, or a mixture it wouldnt ever be a problem. Neither is the 'on' time 2-5 seconds is fine.
    Thanks again.
    Chris

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quick and dirty
    Code:
        CNT_1 VAR BYTE
        CNT VAR WORD
        HIGH PORTC.4
        PAUSE 2000
        low PORTC.4
        PAUSE 2000
    START:
        FOR CNT_1 = 0 TO 24
        FOR CNT = 0 TO 600
        HIGH PORTC.4
        PAUSE 6000
        NEXT CNT
        NEXT CNT_1
        LOW PORTC.4 
        PAUSE 5000
        GOTO START
    Dave
    Always wear safety glasses while programming.

  6. #6


    Did you find this post helpful? Yes | No

    Default 24 hr tmr

    the devices with the 8 mhz int osc are about 1%, (12f283 for example) pretty good timing.
    i would blink an led at 1 sec and use the 1 second as a time base. the led just shows that your ckt is doing something.
    there are 86400 seconds/day but a var word is only 16 bit - max 65535 count so use 2 second count inc up to 43200.

    start:
    while count < 43200
    high led
    pause 1000
    low led
    pause 1000
    count=count+1
    end while
    outputRSTpin=1
    pause 2000
    outputRSTpin=0
    count=0
    goto start

    don f
    Last edited by amgen; - 15th August 2010 at 20:32.

  7. #7
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default

    Chris,

    Would you like to try it on a 55 cent 6-pin 10F200? I just simulated a 63 word program with "cycle accurate" 23:59:58 "off" time and 00:00:02 "on" time. Accuracy will be as good as you can get with the internal oscillator.

    Regards, Mike
    Last edited by Mike, K8LH; - 16th August 2010 at 01:56.

  8. #8
    Join Date
    Aug 2010
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Mike, that looks interesting. I would like to try that. Using this type of chip how will it perform months down the line. eg in 7 months will I still be getting a 2 seconds 'on' once in 24 hours? What I suppose Im trying to ask is, will it gradually lose time or make time or fluctuate +/- so keepinmg an average of 24 hours?

    thanks again

  9. #9
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    224


    Did you find this post helpful? Yes | No

    Default

    Hi Chris,

    The example I wrote will maintain a 24 hour cycle as long as it's powered up but the internal oscillator only has a 1% tolerance at room temperature so it will drift. Over a period of several months you might be an hour off from where you started but you should still be getting an interval very close to 24 hours. If that's a problem then you probably should use an 8-pin PIC (12F629, 12F617, 12F635, 12F675, 12F683) and a crystal which should get you accuracy to within a minute or so per year.

    Cheerful regards, Mike

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Mike,
    Do you plan on posting the code so Chris can use it or just continue talking about it?
    Dave
    Always wear safety glasses while programming.

  11. #11
    Dagwood's Avatar
    Dagwood Guest


    Did you find this post helpful? Yes | No

    Default Re: Simple PIC based timer needed, any advice appreciated.

    Hi All,Very new to Pic Programming and very new to your forum. I found this thread searching Google for ideas on progrmming a PIC on a 24hour cycle. Ok the problem, I have a JDM programmer and when I try to write to a 10F200 PIC all I get is, [IMG]file:///C:/DOCUME~1/BENSHE~1/LOCALS~1/Temp/msoclip1/01/clip_image001.png[/IMG]I have tried running it from the ZIF sockets and the off board connectors????Am stuck now??? Any ideasCheersDagwood

  12. #12
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: Simple PIC based timer needed, any advice appreciated.

    Moved from Schematics.

    Robert

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