|
|
View previous topic :: View next topic |
Author |
Message |
SAMY Guest
|
16F88 consumption problem |
Posted: Tue Dec 02, 2008 3:36 pm |
|
|
Hi I'm working on a pic project and I need to get the max battery life... so I'm using a 16F88 and the sleep instruction...
I use the internal RC oscillator at 2mhz, and a low dropout regulator with 10uA quiescent current.
When I use the sleep instruction, the current consumption goes to 240uA... but... its too high... and when I touch the pic, the current drops to 60uA...
what can I do to get 100 - 50 uA current consumption???
thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Dec 02, 2008 3:45 pm |
|
|
If you touch it and something changes, you probably have floating inputs.
Change all unused i/o pins to be low level output pins.
For example, if pins B0 and B1 are not used in program and have
no external connections, then add this code to make them into low
level outputs:
Code: | output_low(PIN_B0);
output_low(PIN_B1); |
This assumes you are using "standard i/o" mode, which automatically
sets the correct TRIS with the code above. Standard i/o mode is the
default mode of the compiler.
If that doesn't help then post a short test program that shows the problem. Example:
Code: | #include <16F88.h>
#fuses INTRC_IO, NOWDT, NOBROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
//======================
void main()
{
output_low(PIN_B0);
output_low(PIN_B1);
sleep();
while(1);
} |
|
|
|
SAMY Guest
|
|
Posted: Wed Dec 03, 2008 8:13 am |
|
|
I changed a few things on the program... the consumption drops to a UNSTABLE 70uA... but when i touch the circuit... the consumption rises to 120uA and stays there... UNSTABLE...
this is my code:
Code: |
#include <16F88.h>
#fuses INTRC_IO, NOPROTECT, PUT, NOMCLR, NOWDT, NOBROWNOUT, NOLVP
#use delay(clock=2000000)
#use rs232(baud=9600, xmit=PIN_B5, rcv=PIN_B2)
#use standard_io(A)
#use standard_io(B)
#use i2c(master, sda=pin_B1, scl=pin_B4)
#define EEPROM_SDA PIN_B1
#define EEPROM_SCL PIN_B4
#define RTC_SDA PIN_B1
#define RTC_SCL PIN_B4
#include <24256.c>
#include <DS1307.c>
#define led1_on output_high(PIN_A6)
#define led1_off output_low(PIN_A6)
#define led2_on output_high(PIN_A7)
#define led2_off output_low(PIN_A7)
#define buzer_on output_high(PIN_B0)
#define buzer_off output_low(PIN_B0)
#define rs232_on output_high(PIN_B3)
#define rs232_off output_low(PIN_B3)
#define start input(PIN_B6)
#define reset input(PIN_B7)
void main(void)
{
set_tris_a (0b00000000); //Ra7-Ra6-Ra5-Ra4-Ra3-Ra2-Ra1-Ra0
set_tris_b (0b11000100); //Rb7-Rb6-Rb5-Rb4-Rb3-Rb2-Rb1-Rb0
setup_uart(FALSE);
setup_spi(false);
setup_adc(false);
setup_comparator(NC_NC_NC_NC);
setup_CCP1(CCP_OFF);
SETUP_ADC(ADC_OFF);
output_low(PIN_A0) ;
output_low(PIN_A1) ;
output_low(PIN_A2) ;
output_low(PIN_A3) ;
output_low(PIN_A4) ;
output_low(PIN_A5) ;
output_low(PIN_A6) ;
output_low(PIN_A7) ;
output_low(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
output_low(PIN_B3);
output_low(PIN_B4);
init_ext_eeprom();
//ds1307_set_date_time(dia,mes,ano,dow,hora,minutos,segundos);
ds1307_init();
sleep();
while(true)
{
}
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 03, 2008 1:23 pm |
|
|
There are many problems in your code. First, it's much too long for
a test program.
Then, you are setting all pins low. I didn't suggest that in my post.
I said only set unused i/o pins low. You are setting pins low
that are connected to pull-up resistors for the i2c devices. With two
10K resistors (for example), this will cause a load of 0.5ma each.
Quote: | #use standard_io(A)
#use standard_io(B)
set_tris_a (0b00000000); //Ra7-Ra6-Ra5-Ra4-Ra3-Ra2-Ra1-Ra0
set_tris_b (0b11000100); //Rb7-Rb6-Rb5-Rb4-Rb3-Rb2-Rb1-Rb0 |
Here you have invoked standard i/o but you're setting the TRIS.
In standard i/o mode, the compiler automatically sets the correct TRIS
for you. You don't have to do it.
Quote: | setup_spi(false);
setup_adc(false);
setup_comparator(NC_NC_NC_NC);
setup_CCP1(CCP_OFF);
SETUP_ADC(ADC_OFF); |
These modules are turned off upon power-on reset of the PIC.
You don't have to turn them off again with code. Remove this code.
Quote: | output_low(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
output_low(PIN_B3);
output_low(PIN_B4); |
Presumably you have a MAX232 type chip attached to the Rx and Tx
pins of your PIC. The idle state of the MAX232 receiver is to put out
a high level. When you set Pin B2 to a low-level output, you are
"fighting" the high-level output coming from the MAX232. That's not
right. Remember, I said only unused i/o pins should be set low.
Pin B2 (and others) are used. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|