Surviving 1 second without battery power


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Peu

    NO, you did not understand ...

    1) You enable BODEN, nothing else required ...

    2) AT program start, you first read the BOR bit

    3) If BOR Bit = 0 THEN (and only IF ) you increase the EEPROM content : That means power is back, and did not reach ZERO !!! ( no Pb to write , then ...)

    4) If BOR Bit = 1 power has gone to ZERO ( and BOR bit has been reset ) ... just read the EEPROM content .

    5) you SET BOR bit

    6) you run your "lighting" program ...

    Think simple !!!

    Alain
    I still have a doubt: when does the BOD bit goes from the initialization value ZERO (table 9-6) to ONE (No Brown-out Detect occurred) in a cold start scenario?

    At cold start the circuit should read the stored eeprom value not write a new one


  2. #2
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Im reading different PIC datasheets so shed some light about the BOD sequence, but most of them share the same wording, Im really lost.

    I made a little proggie to test what I've learned in this thread, but it does not work, maybe Im missing something stupid, but after many hours of trying, maybe what I need is a good rest:

    Code:
    @ device pic12f683,INTRC_OSC_NOCLKOUT , wdt_on, mclr_off, protect_off, bod_on
    
    CMCON0 = %00000111     ' Disable comparator
    VRCON  = %00000000     ' disable
    
    
    '       I/Os
    TRISIO = %00000000      ' no inputs      
    
    ' definitions
               
    BODD var PCON.0
    
    gpio=%00000100            'I know program cold started
    pause 1000                'gpio.2 green led pin5 indicates coldstart
    gpio=%00000000   
    
    loop:
    
    if BODD=0 then           
        gpio=%00000010        'GPIO.1 red led PIN6 shows a BOD state
        pause 1000
        gpio=%00000000
        BODD=1
    endif
    goto loop
    then the schematic is pretty simple, a ceramic capacitor at the power lines for storing some battery, a couple of leds at the specified pins and a momentary switch that allows me to cut VDD for a moment.

    It does not vork

    [edit] Maybe I need to check for POR=1 and BOD=0 to know for sure that a BOD reset happened

    Help!
    Last edited by peu; - 13th March 2008 at 02:11.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Thumbs down

    gpio=%00000010 'GPIO.1 red led PIN6 shows a BOD state
    pause 1000


    Here is the best reason ( may be others ... I must check ) for your gadget not to work ...

    THE DEVICE MUST DRAW AS LITTLE CURRENT AS POSSIBLE !!!

    Your led leads VCC voltage to ZERO ... so ... POR and not BOR !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Rest helped clear my mind

    I will test this code as soon I arrive at my office:

    Code:
    @ device pic12f683,INTRC_OSC_NOCLKOUT , wdt_on, mclr_off, protect_off, bod_on
    
    CMCON0 = %00000111     ' Disable comparator
    VRCON  = %00000000     ' disable
    
    
    '       I/Os
    TRISIO = %00000000      ' no inputs      
    
    ' definitions
     
    ' init values
    
    if PCON.0=0 then
      gpio=%00000100            'Brown-out detected turn on LED on PIN5
    else
      gpio=%00000010            'Brown-out NOT detected turn on LED on PIN6
    endif
    
    'main loop
    
    loop:
    goto loop
    I can't imagine simpler code to test the BOD function. Do you see something wrong?

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    Was not so easy ... but finally got it !!!

    all the trick is in the bits setting and testing scheduling ... Always keep in mind the processor will re-start from the beginning.

    Have fun ... the ( let's be modest ! ... A ) working listing waits for your first try ...

    Other trick : May be you'll have to test greater values capacitors ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,
    Was not so easy ... but finally got it !!!
    all the trick is in the bits setting and testing scheduling ... Always keep in mind the processor will re-start from the beginning.
    Have fun ... the ( let's be modest ! ... A ) working listing waits for your first try ...
    Other trick : May be you'll have to test greater values capacitors ...
    Alain
    You know...I was thinking...
    In this type of project, there's nothing that says the PIC has to turn itself completely off right away.
    Why can't it stay running for, say 10 seconds, after the LED is powered off.
    So, the process looks like this:

    Initial power on with an initial mode...
    LED lit, PIC waiting...
    button pressed, LED off, PIC still waiting...
    If one second passes without a button press, the PIC shuts itself off.
    If a button press happen inside of one second, the mode changes and the 1 second timer is reset.
    Requires a bit more thought with the single button power on/off circuit, but that's easy...

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking

    Hi, Ski

    My tries show the processor runs in a Low Power mode ...

    Your solution is easy with the ADC (or a comparator ! ) instead of the BOR ... But the goal was NOT TO USE an adc.

    I know ... a '675 doesn't cost so much more than a '629.


    Just consider it was another forum " for the fun contest" !!!

    Alain
    Last edited by Acetronics2; - 13th March 2008 at 15:03.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    You know...I was thinking...
    In this type of project, there's nothing that says the PIC has to turn itself completely off right away.
    Why can't it stay running for, say 10 seconds, after the LED is powered off.
    So, the process looks like this:

    Initial power on with an initial mode...
    LED lit, PIC waiting...
    button pressed, LED off, PIC still waiting...
    If one second passes without a button press, the PIC shuts itself off.
    If a button press happen inside of one second, the mode changes and the 1 second timer is reset.
    Requires a bit more thought with the single button power on/off circuit, but that's easy...
    This is the circuit Im using:


    With this code:
    Code:
    @ device pic12f683,INTRC_OSC_NOCLKOUT , wdt_on, mclr_off, protect_off, bod_on
    
    CMCON0 = %00000111     ' Disable comparator
    VRCON  = %00000000     ' disable
    
    
    '       I/Os
    TRISIO = %00000000      ' no inputs      
    
    ' definitions
     
    ' init values
    
    if PCON.0=0 then
      gpio=%00000100        'Brown-out detected turn on LED on PIN5 (red)
    else
      gpio=%00000010        'Brown-out NOT detected turn on LED on PIN6 (green)
    endif
    
    'main loop
    
    loop:
    pcon.0=1
    goto loop
    It does not work, the minute I give it power green lits and after 5 seconds¿?¿? it goes off and red lits.

    Am I missing something?

    I can use a 12F675 or even a 12F683 if a simpler / more efficient solution is possible.

    Regarding flashlight operation, think of a flashlight without buttons, it goes on or off by twisting the body, and the battery electrical path to the LED/uC is done using the metal body. So this means when power is gone, is gone for everything. To be even more clear, here is a CAD drawing of my latest creation:


    The green you see there is the uC/driver PCB that also serves as positive contact for the battery. Ground is attached inside the flashlight head.

    To check more flashlights check: www.neoca.com.ar Thanks!

Similar Threads

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