Counting miliseconds between ON and OFF


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    130

    Default Counting miliseconds between ON and OFF

    Hi,

    I'm trying to count how many milliseconds pass between I power off an uC cutting its battery power and the subsequent power on.

    I need to measure around 500 miliseconds.

    The circuit its very simple: a 12F675 and a led on port 2

    What would be the best electronical solution? I was thinking about using a capacitor for storing some power after batery shutdown.

    Any ideas would be greatly appreciated. Thanks in advance!!


    Pablo

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


    Did you find this post helpful? Yes | No

    Default

    Depending on the state of port pins, HIGH or LOW, it may change.

    For example, if you have a LED on a pin and it is ON, then the capacitor you have, say 220uF, will last less compared to OFF state of that LED.

    This should be very easy to experience though.

    Just make sure, when the LED is OFF, the PIC itself will draw very small current and the capacitor may keep powering the PIC very long, too. Thus, the PIC will be running "secretly" although you may think that it is not running.

    -------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Thanks for the prompt reply Sayzer, the led turns on as soon the uC is powered, so I need to put that on the scale to size the capacitor accordingly.

    You think I need to go 220uF?
    Well, I guess I'll try the best solution at the bench


    Pablo

  4. #4
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    I forgot to ask, how can I detect that the power went off so I can start counting?


    Thanks!

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


    Did you find this post helpful? Yes | No

    Default

    Have an input pin tied to the power source before the cap;

    When the power is OFF, you can detect it while the cap is still powering the PIC.

    This way, you can save your variables before the cap is completely gone.


    ------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  6. #6
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Clever, very clever and fast also! Thanks again Saizer!


    Pablo

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