Minimizing power use w/ 12f683


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305

    Default Minimizing power use w/ 12f683

    Gents,
    I'm using a 12f683 on a battery, shematic attached, to sequence through some LEDs. When someone pushes a button the program, portion attached, runs just fine and draws around 20mA. While idle it draws around 3.5mA with MCLR, WDT, BOD and CPD off. I need to figure out a way to cut down on the idle current draw or else the recipient will have to change batteries every quarter. I've tried SLEEP and NAP but the program can't run during that time so the system appears dead during that time.

    Please note: On the schematic, the 5V regulator is shown as a LT1585. I couldn't find a TO-02 regulator in the SWcad library so I used the 1585 symbol. I also couldn't find a switch so you'll have to use your imagination. The attached program had to be recreated since MicroCode studio won't load on this computer.

    Please don't sharpen your barbs too much, I'm new at this programming stuff. Your thoughts and ideas are appreciated.
    Attached Images Attached Images

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


    Did you find this post helpful? Yes | No

    Default Re: Minimizing power use w/ 12f683

    I'm confused (imagine that-LOL). Are any LED's on during the idle time? When you say it appears dead, I assume you mean it won't respond to the switch. (of which I see nowhere in the program where it would)

    I think you need to configre it so either the switch causes an wake up interrupt, or put it to sleep for short periods then wake up and check the switch. maybe 1 ms nap (power nap?)

    Just my thoughts.
    -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!

  3. #3
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: Minimizing power use w/ 12f683

    You've presumably seen this doc...

    http://ww1.microchip.com/downloads/e...hapter%202.pdf

  4. #4
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Minimizing power use w/ 12f683

    Well, yes, I do mean that while the program is in sleep or nap the system appears dead meaning the switch won't start the program. There are no LEDs lit during idle time. I've used gpio.3 by way of MCLR_OFF to trigger the start of the program. My concern with napping the program is a too short pressing of the button not starting the program. Then pressing the button again......

    Although I hadn't seen the documentation you hyper-linked, I was doing most of that. My circuit and program had no circuitry other than the pic being powered when the LEDs were not being sequenced. I was trying to find if there were any other fuses or whatever I could turn off to draw less power.

    One of the guys in my shop suggested a solution I hadn't thought to employ. I hooked the anode of a diode up to each gpio used for the LEDs and connected the ganged cathodes to a relay. I used the contacts of the relay to trigger not only the pic but actually turn on the whole circuit then added a pause at the end to allow the relay to deenergize and viola, I'm now pulling less than 1mA. I'm not real sure what is causing that current draw as everything is powered through the normally open contacts and only connected when the relay is energized. But that is all I had time for when work called and I had to quit working on this project.

    I'll get a circuit uploaded soon.

  5. #5
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Minimizing power use w/ 12f683

    If you think you draw a lot of power now, wait until you add a relay! If you were to go down that path, use FETs as switches, not relays as relays are serious power hogs.

    But there is a simpler way. Pin 5 (GP2/INT) can be configured to be an external interrupt. So rearrange your hardware to connect the switch there, then in your software, simply put the device to sleep, drawing nano-amps, until a switch transition generates an interrupt and wakes it up. Then run your routine and go back to sleep, waiting for the next interrupt.

    Details are in the datasheet.

  6. #6
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: Minimizing power use w/ 12f683

    Thanks for the suggestion. I will try a FET. Although even with the relay the average power use is considerably decreased. The chip itself takes about 4 mA, the LEDs about 20mA (remember only one is lit at at time), and the relay another 20mA. This draw will be only for about 10 seconds maybe 6 times a day. Just running the chip without the relay, granted without sleep/nap or interrupt, all day long at 4 mA/24 hrs would be alot more power overall.

    As for rearranging and using a pin to create an interrup, well, I was trying to light 20 LEDs off one chip with as little extra stuff as possible. The only way that can be done is use all 5 I/O pins and make gpio.3 an input for the start of the program. It's somewhat shown here

    http://ww1.microchip.com/downloads/e...Doc/01146B.pdf

    If I'm missing something then please let me know.

  7. #7
    Join Date
    Feb 2011
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Minimizing power use w/ 12f683

    there's not much in your circuit than should be drawing power when 'off'.

    1. change the 1k on pin4 ra3 to 47k
    2. use TRIO=$FF when you want to turn off stuff completely
    3. have you considered running the chip slower?
    -- you can use 125khz and use "9600 baud serial" out to give you "real" 300 baud
    --my usb>serial won't work on 75baud otherwise I'd use 32khz for debugging

    Code:
    'low speed osccon 31khz 
    'bit 6-4 IRCF<2:0>: Internal Oscillator Frequency Select bits
    '                               correction 
    '                               by shifting
    '                                   |
    '                                   v   Min Pause times
    '       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 = 1
    speed_shift  con   5   '  use 0-7 : oscillator / delay correction by shifting
    ' PAUSE is affect by this, see the above minimum pause times
           
    '
    ' FOR LOW POWER DISABLE AS MANY FEATURES AS POSSIBLE.
    ' ** FOR 12F675 un-COMMENT CMCON=7, ANSEL=0, ADCON0=0
    ' ** FOR 12f683 un-COMMENT CMCON0=7, ANSEL=0, ADCON0=0
    ' ** FOR 12F629 COMMENT ALL
    '   CMCON = $07  '12F675 CMCON — COMPARATOR CONTROL REGISTER  ALL DIGITAL
       CMCON0 = $07  '12F683 CMCON0 — COMPARATOR CONTROL REGISTER  ALL DIGITAL
    '    TRISIO = %11111011   'SET TO ALL OUTPUTS  1=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
    
    'constants
    
    ALL_INPUTS          CON     $FF     ' Set to all inputs to save power
    LAMP_OFF            CON     $00   
    LAMP_ALL            con     $36     'GPIO.1.2.4.5
    
    
    'IO assignments
    SERIAL_PIN  var GPIO.2

    Main code snippets:
    Code:
            X= 250              ' DELAY TIME in milliseconds
            led = lamp
                gosub Lamp_ON
    ' turn OFF LED        time = 750mS
            X= 750  : gosub OFF_Lamp

    those called subroutines
    Code:
    ' Speed affected by the CPU clock speed
    Lamp_ON:
        TRISIO = ALL_INPUTS - led
        GPIO =   led
        Pause X >> speed_shift ' Delay for on time in milliseconds
        TRISIO = ALL_INPUTS    ' Set to all inputs to save power
    Return
    
    OFF_Lamp:
        TRISIO = ALL_INPUTS 
        Pause X >> speed_shift ' Delay for on time in milliseconds
    Return
    
    ' *** SLEEP & NAP Speed *NOT* affected by the CPU clock speed
    ' NAP uses slow clock mS 0=18,1=36,2=72,3=144,4=288,5=576,6=1.52s,7=2.304s
    ON_Lamp_Short:
        TRISIO = ALL_INPUTS - LAMP
        GPIO =   LAMP
        NAP x 
        TRISIO = ALL_INPUTS   ' Set to all inputs to save power
    Return
    
    OFF_Lamp_Short:
        TRISIO = ALL_INPUTS   ' Set to all inputs to save power
        NAP x 
    Return

Members who have read this thread : 2

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