Low power aplication on 12F629


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    May 2010
    Location
    Chile
    Posts
    25

    Default Low power aplication on 12F629

    I'm building a coin battery (CR2032) operated clock with a 12F629

    The program uses TIMER1 interrupt configured to reload at 100hz and refresh variables each time.

    On the main loop there is just a button push check loop to deliver time in case of pushing it.

    For extending the battery life I tried to lower the cristal frequency (from 4M to 32K) but without luck in picbasic, I also disabled all hardware not in use (TMR0, WPU, VREF, COMP) and the pull-up on the button (GPIO3) is at 100K.

    Right now the circuit is drawing 0,5mA and that is low but maybe i missing something else


    My question is:
    Did I miss something else to reduce power?

    Also,
    I was wondering if someone can point me up for some tips on how to proper design (software and hardware) for low power in timing aplications without using external RTCs
    Because right now i'm guessing

    Thanks
    "If at first doesn't work, kicking it wont help either"

  2. #2
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Low power aplication on 12F629

    Quote Originally Posted by El_AMPo View Post
    Right now the circuit is drawing 0,5mA and that is low but maybe i missing something else


    My question is:
    Did I miss something else to reduce power?
    A quick look at the datasheet suggests you could save considerable power by using sleep mode. Conceptually you set up the watchdog to wake you up after a certain number of clock cycles, then go to sleep and draw only nano-Amps until you are awakened. I believe you can set the watchdog, using the prescaler, to 128 clocks (or 64, or 32, etc.). If the processor has nothing to do, you can reset the watchdog, then go to sleep and get awakened after an exact number of clock cycles, increment your counters and display, and do anything else you need to do before resetting the watchdog and going back to sleep. If you can sleep 1/2 the time, you can save 1/2 the power - it's pretty linear.

  3. #3
    Join Date
    May 2010
    Location
    Chile
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Low power aplication on 12F629

    The problem with the watchdog is that it's not a reliable clock source for timing applications.
    Maybe running the Timer1 counter from the main crystal while the pic processor is sleeping.
    I know that can be done with an external (extra) oscillator, but I have no idea if it can be routed to the main one.
    "If at first doesn't work, kicking it wont help either"

  4. #4
    Join Date
    Feb 2011
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Low power aplication on 12F629

    Try the 12f635 or the 12f683.

    The 12F629 does not have the OSCCON @ [8F - hex] , register so you can't set the speed it is stuck at 4MHz.
    You will need to read the DATA SHEET a bit more closely -- as always it is buried in the fineprint

    some hints: * learned from observation, please let me know if I'm wrong : )

    0. Set the 2007 Register BIT FIVE [5] to ZERO [0] *****************
    ----> I currently do this just before programming in the programmer configuration menu.
    ***** This disables the master reset and allows you a. to ignore it, b. use GPIO.3 as an input. ---> for the pros I have not figured out how to set this in PBasic. more rtf is in order.

    1. SLEEP and NAP are not affected by the cpu speed [really helpful]
    2. PAUSE will be affected by the timer speed, >> will shift the number
    3. To save power turn off the outputs when you are not using them ie. TRISIO = $FF
    --- You can use this instead of GPIO = XX to turn off your lamps

    I also had trouble with setting PBasic to work on slow CPU

    Here's my kludge on the 12f683 : )

    This is blinking some lights in a special pattern [code not shown] when off the cpu uses between 40-60 nano Amp!! Yes, NANO amps!
    on a cr2016
    Code:
    -----------------------------------------------
    The circuit is:
    pin
    1 - BATT+  not even a cap to pin.8 [ground] :)
    2 - LED1 +
    3 - LED2 +
    4 - NC
    5 - LED3 +
    6 - LED4 +
    7 - BUZZER.minus ---> *** this PIN is a SINK, shorts to ground so turn it to ZERO in GPIO.0 when you want it to work -- other end of the BUZZER TO to batt+, use GPIO.0
    8- BATT -
    
    LED1-4 - combined together then 100ohm to pin.8 [ground]

    My typical header -- all commented on 12f683 for this program
    Code:
    '
    ' FOR LOW POWER DISABLE AS MANY FEATURES AS POSSIBLE.
    ' ** FOR 12F675 un-COMMENT CMCON=7, ANSEL=0, ADCON0=0
    ' ** FOR 12F629 COMMENT ALL
     '   CMCON = $07  'CMCON — COMPARATOR CONTROL REGISTER  ALL DIGITAL
    '    TRISIO = %11111011   '  tristate mode  1=INPUT
    ' 	TRISA  = %00001000	' Set PORTA.0 to input   A.3 input ONLY  1=in
    ' 	TRISA  = %00001000	' Set PORTA.3 input
    '	ADCON1 = %01100000	' Set a2d convert at clk/6 [slowest]
    '	ADCON1 = %00000000	' Set a2d convert at clk/2 [fastest]
    '	ANSEL  = %00000000  ' AN0/RA0 as analog input     1=ANALOG
    '	ADCON0 = %00000001	' .7=10bits left justify result!! / .0 1=a2d ON
    '	ADCON0 = %00000000	' .7=10bits left justify result!! / .0 1=a2d ON
    '   WPUA =   %00000000  ' TURN ON WEAK PULLUP 1=ON VALID=.5.4.2.1.0

    Code:
    ' lifted right from the data sheet     : )
    '
    'low speed osccon 31khz 
    ''bit 6-4 IRCF<2:0>: Internal Oscillator Frequency Select bits
    '                               correction 
    '                               by shifting
    '                                   |
    '                                   v
    '       111 =8MHz
    '       110 =4MHz (default)         0
    '       101 =2MHz                   1   2
    '       100 =1MHz                   2   4
    '       011 =500kHz                 3   8
    '       010 =250kHz                 4   16
    '       001 =125kHz                 5   32
    '       000 =31kHz (LFINTOSC)       7   128
    
            OSCCON.6 = 0
            OSCCON.5 = 0
            OSCCON.4 = 0
    speed_shift  CON   7   '  use 0-7 : oscillator / delay correction by shifting
    
    
    ' BYTES
    led           VAR byte   '  lower 6 bits only  for GPIO
    
    ' WORDS
    X       var	word
    
    
    ' TEST ALL LAMPS GPIO.1.2.4  3=INPUT ONLY
    
    ' Delay for ~3 seconds
    X= 3000     ' START UP DELAY TIME
    '
    ' could of done this as a short gosub 
    '
    led =    $02 
    TRISIO = $FE - led
    GPIO =   led
    Pause X >> speed_shift       ' Delay for on time in milliseconds
    led =    $04 
    TRISIO = $FF - led
    GPIO =   led
    Pause X >> speed_shift       ' Delay for on time in milliseconds
    led =    $10 
    TRISIO = $FE - led
    GPIO =   led
    Pause X >> speed_shift       ' Delay for on time in milliseconds
    led =    $20 
    TRISIO = $FF - led
    GPIO =   led
    Pause X >> speed_shift       ' Delay for on time in milliseconds
    
    
    ....
    
    
     LED = %00110110                    ' GPIO.1.2.4.5
      
         TRISIO = $FF    ' TURN OFF OUTPUTS TO SAVE POWER
         GPIO= led       ' Chose which LED to Turn ON
    
    
    ' LED ON fast blink # led 
         TRISIO = $FF - led  ' Enable output - fast blink # led
        Pause  128  >> speed_shift 
    
    ' LED OFF
        TRISIO = $FF    ' TURN OFF OUTPUTS TO SAVE POWER
        Pause  256  >> speed_shift      'time in mS
    
    end
    Last edited by ofuzzy1; - 23rd February 2011 at 03:25.

  5. #5
    Join Date
    Feb 2011
    Posts
    26


    Did you find this post helpful? Yes | No

    Default disabling the master clear bit MCLR OR MCLRE or using gpio.3 or pin4 or RA3

    Want to use pin4?
    It will only be an INPUT.

    ' WHEN PROGRAMMING PROGRAM $2007.5 TO LOW THIS WILL ENABLE GPIO.3 / RA3 AS AN INPUT
    '
    ' Set the 2007 Register BIT FIVE [5] to ZERO [0] *****************
    ----> I currently do this just before programming in the programmer configuration menu.
    '
    'OR
    see: http://www.picbasic.co.uk/forum/showthread.php?t=14421

    ' change the config file
    ' OR IN THE C:\PBP\chip.INC
    ' i.e. C:\PBP\12F683.INC


    change this line to:
    device pic12F683, intrc_osc_noclkout, wdt_on, mclr_off, protect_off

    and this line to:
    __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF

    Code:
    ;****************************************************************
    ;*  12F683.INC                                                  *
    ;*                                                              *
    ;*  By        : Leonard Zerman, Jeff Schmoyer                   *
    ;*  Notice    : Copyright (c) 2005 microEngineering Labs, Inc.  *
    ;*              All Rights Reserved                             *
    ;*  Date      : 08/31/05                                        *
    ;*  Version   : 2.46a                                           *
    ;*  Notes     :                                                 *
    ;****************************************************************
            NOLIST
        ifdef PM_USED
            LIST
            include 'M12F683.INC'	; PM header
            device  pic12F683, intrc_osc_noclkout, wdt_on, mclr_off, protect_off
    ;        device  pic12F683, intrc_osc_noclkout, wdt_on, mclr_on, protect_off
    
            XALL
            NOLIST
        else
            LIST
            LIST p = 12F683, r = dec, w = -302
            INCLUDE "P12F683.INC"	; MPASM  Header
            __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
    ;        __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    
            NOLIST
        endif
            LIST
    Last edited by ofuzzy1; - 23rd February 2011 at 05:00.

  6. #6
    Join Date
    May 2010
    Location
    Chile
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Low power aplication on 12F629

    Quote Originally Posted by ofuzzy1 View Post
    Try the 12f635 or the 12f683.

    The 12F629 does not have the OSCCON @ [8F - hex] , register so you can't set the speed it is stuck at 4MHz.
    You will need to read the DATA SHEET a bit more closely -- as always it is buried in the fineprint
    It's quite similar your chip configs to what i'm using. 12F683 seems like a nice little chip, but still for timing applications you need an external Xtal, INTRC its not enough after some days running.

    What would be handy is how to configure the 12f629 to run in LP xtal mode AND make it work in picbasic. No problem if the pause periods run slower you can always compensate for that, but the chip refuses to work in LP
    "If at first doesn't work, kicking it wont help either"

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Low power aplication on 12F629

    but still for timing applications you need an external Xtal, INTRC its not enough after some days running
    Sounds like a test is in order. Are you saying that after a few days the clock is no longer at said speed? by how much? I can see a test such as this:

    Code:
    main:
     toggle port pin
     goto main
    this will give some freq out. so if we let it run a few days, we can see the new freq out.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  8. #8
    Join Date
    May 2010
    Location
    Chile
    Posts
    25


    Did you find this post helpful? Yes | No

    Default Re: Low power aplication on 12F629

    Quote Originally Posted by cncmachineguy View Post
    Sounds like a test is in order. Are you saying that after a few days the clock is no longer at said speed? by how much? I can see a test such as this:

    Code:
    main:
     toggle port pin
     goto main
    this will give some freq out. so if we let it run a few days, we can see the new freq out.
    It's a clock keeping code so you work "accumulating cycles", if you use an RC source, even if you calibrate it to a perfect frequency within a few days you will have noticeable drift because of temperature changes during the day and voltage drop from the battery. Crystals also suffer from drift but much less noticeable, and if you want better than that you will need temperature compensated RTCs or OCXO (oven controled crystal oscillators) both an overkill for my clock.

    Talking about INTRC 4mhz clock... anyone was able to calibrate the value at 5 volts via oscal value?.
    The factory default is calibrated at 4mhz 1% BUT at 3.5V 20șC if I remember well. So at 5V it's like 1.1Mhz per instruction actually (measured), that means goodbye serial comms and reasonable good timing.
    "If at first doesn't work, kicking it wont help either"

  9. #9
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Low power aplication on 12F629

    1.1Mhz per instruction actually (measured)
    WOW, thats 10%!!!!
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 1

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