Re: [PIC] High Power Consumption for a Battery operated application - Electronic Safe
| Newsgroups | gmane.comp.hardware.microcontrollers.pic |
|---|---|
| Message-ID | <[email protected]> |
Francois, I haven't gone over your Program yet, but I can make a couple of suggestions. Use the slowest clock speed that will handle your application. If you reduce your clock speed from 4 MHz to 1 MHz the PIC will consume only about 1/3 the power. See Microchip 16F88 Data sheet chart 18.2 I would not enable weak pull-ups on port B. The weak pull-ups are turned off anyway when using the pins as outputs Weak pull-ups only work when pins are used as inputs. Maybe later on I may have other suggestions. Joel T. Curneal [email protected] On 2025-01-07 13: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