RE: [PIC] High Power Consumption for a Battery operated application - Electronic Safe
"Francois Robbertze" <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.pic |
|---|---|
| Message-ID | <[email protected]> |
Thank you for all the input. I think my problem is solved. I will now peek it for even better power consumption by adjusting the times before the pic go into deep sleep, lower the voltage etc. The problem was the following: I have weak pull-ups activated on port B but an external resistor was pulling port B6 low for the reset button :( My configuration seems fine because the pic now go into deep sleep at 32KHz and the current draw is about 2uA. (0.2 mV across a 100 Ohm resistor) Theoretically the batteries should last for 144 years :) I need to order pic controllers and will rather get the PIC 16LF88 and drop the voltage to about 3 Volt. (That is 2x AA batteries) I still have a 1K Ohm pull-up resistor connected on port B6 and the reset switch pull the input low when pressed. For some reason the weak pull-ups does not do the job. Regards Francois -----Original Message----- From: Piclist <[email protected]> On Behalf Of John Lawton Sent: 08 January 2025 04:50 PM To: [email protected] Subject: Re: [PIC] High Power Consumption for a Battery operated application - Electronic Safe A few thoughts. What is the current consumption with the PIC held in reset, does that show you anything not noticed about the hardware, causing the high current consumption? Are there any resistive loads for the keypad sensing, that might cause unexpected current consumption? Are the keypad lines left in an inactive or input mode between reads? John On 07/01/2025 19:14, Francois Robbertze wrote: > Hi, > > > > I need help with the power consumption on a battery operated project > (Keypad > safe) > > I have a lot of safes and the controllers is damaged. I want to create > new controllers for these safes and try to use what is available > > > > Details: Current Power is supplied by 4xAA Batteries. Power is dropped > to > 4.8 volt through 2 diodes. > > > > I used PICBASIC Pro and the software works perfect except the current > draw is about 1.56mA. The datasheet show on page 167 a current draw of > 1uA in sleep mode. I use the PIC16F88. That is with the programmer > disconnected.( I measure about 156,8mV volt drop over a 100Ohm > resistor ) > > > > What am I missing or doing wrong? > > > > The Software in short: > > > > Config: > > __config _CONFIG1, _INTRC_CLKOUT & _WDT_OFF & _LVP_OFF & _CP_OFF > & _BOREN_OFF & _MCLRE_ON & _DEBUG_OFF > > __config _CONFIG2, _FCMEN_OFF & _IESO_OFF > > > > Pin Setup: > > Row1 VAR PORTA.0 '4x3 Keypad > > Row2 VAR PORTA.1 > > Row3 VAR PORTA.2 > > Row4 VAR PORTA.3 > > > > Col1 VAR PORTB.0 > > Col2 VAR PORTB.4 > > Col3 VAR PORTB.5 > > > > ' Other pins > > Solenoid VAR PORTA.4 ' Solenoid control pin > > Beeper VAR PORTB.3 ' Beeper control pin > > ResetButton VAR PORTB.6 ' Reset button > > Led var PORTB.2 ' heartbeat > > > > Initialize: > > OSCCON = %01101110 'set int rc osc to 4mhz > > > > CMCON = 7 ' Disable comparators, PORTA as digital I/O > > ANSEL = 0 ' Set all pins as digital I/O > > ADCON0 = 0 ' a to d off > > ADCON1 = 0 '?? > > T1CON = 0 > > T2CON = 0 ' timer 2 off > > CCP1CON = 0 ' capture compare off > > TXSTA = %00000000 '?? > > RCSTA = %00000000 '?? > > > > PORTA = 0 ' Initialize PORTA to 0 > > PORTB = 0 ' Initialize PORTB to 0 > > > > TRISA = %00000000 ' Set PORTA direction (input/output as needed) > > ' RA0 - RA3 keypad row - outputs > > ' RA4 - stryker - output > > ' RA5 - reset mclr - set as input > > ' RA6 - RA7 osc > > TRISB = %01110001 ' Set PORTB direction > > ' RB0 - col1 > > ' RB1 - nc > > ' RB2 - LED > > ' RB3 - Buzzer > > ' RB4 - Col2 > > ' RB5 - Col3 > > ' RB6 - nc Programmer > > ' RB7 - nc Programmer > > > > > > OPTION_REG.7 = 0 ' Enable weak pull-ups on PORTB > > OPTION_REG.6 = 0 ' TRIGGER INT ON FALLING EDGE > > > > I then enable interrupt : > > INTCON = %10011000 ' enable change on port[B4-B7] > and ext int on port b > > > > ON INTERRUPT GOTO Handleinterrupt ' Interrupt Service Routine > > > > Main Routine: > > > > Check for KeypressedFlag > > Check for ResetPressedFlag > > > > Flash LED > > > > Goto Sleep: > > > > OSCCON = %00000010 '32KHz > > > > asm > > sleep > > endasm > > > > OSCCON = %01101110 '4MHz > > > > .and goto Main > > > > Here is my Interrupt Handler. > > Disable > > HandleInterrupt: > > if resetbutton = 1 then > > ResetPressedFlag = 1 > > resume > > endif > > > > IF INTCON.1 = 1 THEN ' Check external INT (RB0) > > KeyPressedFlag = 1 ' Set flag for RB0 > > INTCON.1 = 0 ' Clear external INT flag > > ENDIF > > > > IF INTCON.0 = 1 THEN ' Check IOC interrupt > > 'IF (PORTB & %00110000) <> %00110000 THEN > > KeyPressedFlag = 1 ' Set flag if RB4 or RB5 changes > > 'ENDIF > > INTCON.0 = 0 ' Clear IOC flag > > ENDIF > > > > RESUME > > enable > > > > I am currently using the PIC16F88. I tried to drop the voltage below > 4Volt with disastrous effects. > > > > Should I get another PIC? . I don't want to replace the batteries > every month. > > > > Regards > > > > Francois > > > -- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at https://mailman.mit.edu/mailman/listinfo/piclist