PDA

View Full Version : sleep problem help plz >>>.



Mus.me
- 14th November 2009, 06:45
hello . im runing this coge example in pic 16f913, and when it goes to sleep it still runing on 3mA i need help bcz the datasheet says it sleep mode must be 3 uA . im sure there things wrong i didnt set and i want it not to reset the program when wakeup or durinf sleep.thank you

Include "modedefs.bas"

DEFINE CONFIG_WORD_$3F31
DEFINE INT_OSC 8
WDTCON.0 = 0
OPTION_REG = %00000001
ADCON0 = 0
OSCCON.6 = 7
intcon = 0
vrcon = 0
PORTB =%00000001
PORTA = 0
PORTC = 0
TRISB = %00000001
G VAR BYTE
H VAR BYTE
L VAR BYTE
K VAR BYTE
NOTE VAR BYTE
BUZ VAR PORTB.3

MAIN:
G = G + 1
IF G => 30 THEN slp
HIGH PORTB.1
PAUSE 100
IF PORTB.0 = 0 THEN SLP
LOW PORTB.1
PAUSE 1000
IF PORTB.0 = 0 THEN SLP
GOTO MAIN

SLP:
SOUND BUZ,[126,3,00,4,126,3,00,4,126,3,00,4,126,3,00,40,120,6 ,00,8,124,6,00,10,120,6,00,8,124,6]
OPTION_REG =%00000001
PAUSE 100
for NOTE = 115 TO 127
SOUND BUZ,[NOTE,3]
NEXT NOTE
HIGH PORTB.2
PAUSE 1000
LOW PORTB.2
INTCON.0 = 0 'RBIF
INTCON.3 = 1 'RBIE
INTCON.1 = 0
INTCON.4 = 1
sleep 1800
@ SLEEP
@ NOP
HIGH PORTB.2
PAUSE 1000
LOW PORTB.2
GOTO MAIN
END

Mus.me
- 14th November 2009, 10:10
sorry i did mistikes , all wat i need is to put pic in sleep mode but very low current like datasheet says 2 uA im gettin 3 mA when it sleeps . plz help

mehmetOzdemir
- 14th November 2009, 13:46
sorry i did mistikes , all wat i need is to put pic in sleep mode but very low current like datasheet says 2 uA im gettin 3 mA when it sleeps . plz help

is there any voltage regulator on your board.(7805 - 78l05)

measure only the current off pic.

Mus.me
- 14th November 2009, 21:17
is there any voltage regulator on your board.(7805 - 78l05)

measure only the current off pic.

hi mehmetOzdemir , no im useing 3.7 battery i just think the problem in the code i dont know how to desables everythings during sleep mode. help plz

Darrel Taylor
- 14th November 2009, 21:24
DEFINE CONFIG_WORD_$3F31
DEFINE INT_OSC 8

Are you putting those in there for some other purpose?

They have no effect on your PIC.
Including setting the proper configs and OSC.
<br>

Mus.me
- 14th November 2009, 22:59
DEFINE CONFIG_WORD_$3F31
DEFINE INT_OSC 8

Are you putting those in there for some other purpose?

They have no effect on your PIC.
Including setting the proper configs and OSC.
<br>thanks DT ive took them off but still the same problem

Darrel Taylor
- 14th November 2009, 23:14
thanks DT ive took them off but still the same problem

And what did you replace them with?
<br>

Mus.me
- 14th November 2009, 23:26
And what did you replace them with?
<br> well config words is $3F31 wdte off i did sett them in the programmer loader
im sure i didnt disable somethings like comparators or registers or acd im new in pbp ,i dont understand to much the datasheet . and using internal osc .tank DT for reply ..

BrianT
- 15th November 2009, 00:08
You don't tell us what your hardware configuration is. You do not appear to be setting TRIS for ports A, C and E. They will probably have defaulted to inputs and if any are floating they can be in an undefined state and drawing high current. Make sure all unused inputs are tied high or low and are not allowed to float some mid voltage where the CMOS inputs draw high current.

Better to make all unused pins outputs and force them high or low as appropriate for your hardware.

Also, when the system goes to sleep, the high/low status of any outputs are preserved. You might find the processor is asleep but a pin is high and sourcing current to a load like your buzzer. Piezo buzzers can have high leakage. Equally the pin might be low and sinking current from the supply. Use a voltmeter and check that all i/o pins are doing exactly what you want. The WatchDog, brownout and other timers and peripherals all draw additional current and the datasheet gives the most favourable sleep current with all these devices turned off.

I find it helpful to explicitly define every hardware pin on all ports, whether used or not, with something like



'PortA
AccelY var porta.0 ' accelerometer Y axis
AccelX var porta.1 ' accelerometer X axis
ECG var porta.2 ' analog heart input
MemD var porta.3 ' M25Pxx Data TO memchip
MemClk var porta.4 ' M25Pxx clock
LED var porta.5 ' Active HIGH
SpareA6 var porta.6 '
SpareA7 var porta.7 '
TRISA = %00001111 ' lowest power
PORTA = %00000000 ' lowest power



PBP assumes the WatchDog prescaler is set to 512. SLEEP xx is only accurate if the WDTPS is 512. SLEEP causes a fairly high current spike each time the chip wakes up, approximately once per second. If you set the WDTPS to something like 2048 the sleep times are off by a factor of 4 but the wakeup current spike is reduced in frequency by a factor of 4 as well.

Getting down to lowest power is hard and needs a sensitive microammeter in my experience. I have spent months getting to minimum current on a data logger and have now got a system down below 500 nA with a PIC18F4620 at 3.7 volts. That includes 256 Mbits of memory and all peripherals.

HTH
BrianT

Mus.me
- 15th November 2009, 00:20
You don't tell us what your hardware configuration is. You do not appear to be setting TRIS for ports A, C and E. They will probably have defaulted to inputs and if any are floating they can be in an undefined state and drawing high current. Make sure all unused inputs are tied high or low and are not allowed to float some mid voltage where the CMOS inputs draw high current.

Better to make all unused pins outputs and force them high or low as appropriate for your hardware.

Also, when the system goes to sleep, the high/low status of any outputs are preserved. You might find the processor is asleep but a pin is high and sourcing current to a load like your buzzer. Piezo buzzers can have high leakage. Equally the pin might be low and sinking current from the supply. Use a voltmeter and check that all i/o pins are doing exactly what you want. The WatchDog, brownout and other timers and peripherals all draw additional current and the datasheet gives the most favourable sleep current with all these devices turned off.

I find it helpful to explicitly define every hardware pin on all ports, whether used or not, with something like

<code>
'PortA
AccelY var porta.0 ' accelerometer Y axis
AccelX var porta.1 ' accelerometer X axis
ECG var porta.2 ' analog heart input
MemD var porta.3 ' M25Pxx Data TO memchip
MemClk var porta.4 ' M25Pxx clock
LED var porta.5 ' Active HIGH
SpareA6 var porta.6 '
SpareA7 var porta.7 '
TRISA = %00001111 ' lowest power
PORTA = %00000000 ' lowest power

</code>

PBP assumes the WatchDog prescaler is set to 512. SLEEP xx is only accurate if the WDTPS is 512. SLEEP causes a fairly high current spike each time the chip wakes up, approximately once per second. If you set the WDTPS to something like 2048 the sleep times are off by a factor of 4 but the wakeup current spike is reduced in frequency by a factor of 4 as well.

Getting down to lowest power is hard and needs a sensitive microammeter in my experience. I have spent months getting to minimum current on a data logger and have now got a system down below 500 nA with a PIC18F4620 at 3.7 volts. That includes 256 Mbits of memory and all peripherals.

HTH
BrianT

THANK YOU BrianT FOR UR HELP I WILL DO THEM NOW IM ON THE DATASHEET PULLING SOME HEAR .I WILL POST RESULT NEXT TIME THANK U AGAIN ...

Mus.me
- 15th November 2009, 01:22
Include "modedefs.bas"
@ DEVICE WDT_OFF, PWRT_OFF,MCLR_OFF,CPD_OFF'IESO_OFF
PCON.4 = 1
WDTCON.0 = 0
WDTCON.4 = 3
OPTION_REG = %00000001
ADCON0 = 0
OSCCON.6 = 7
intcon = 0
vrcon = 0
PORTB =%00000001
PORTA = 0
PORTC = 0
TRISA = 0
TRISC = 0
TRISB = %00000001
I DID THIS SETTING BUT STILL 5mA IN SLEEP MODE [ @ SLEEP @ NOP]

bogdan
- 15th November 2009, 04:17
...try to add:

CMCON0.2 = 1 'Comparators Off for PORTA.0 to 3 (CM bits)=save power
CMCON0.1 = 1
CMCON0.0 = 1

VRCON.7 = 0 'CVref circuit powered down (VREN bit)=save power

Mus.me
- 15th November 2009, 05:24
@ DEVICE WDT_OFF, PWRT_OFF,MCLR_OFF,CPD_OFF
VRCON.7 = 0
CMCON0=%00000111
WDTCON.0 = 0
WDTCON.4 = 3
OPTION_REG.7 = 0
ADCON0.0 = 0
OSCCON.6 = 7
LCDCON.4=0
LCDCON.6=1
LCDCON.7=0
'CMCON = 7
intcon = 0

I DID THIS BUT STILL 5mA IN SLEEP MODE :mad:

Gusse
- 15th November 2009, 11:19
Hi there,

Any changes that you could share applications schematics with us?
Do you have discrete pull-ups or pull-downs connected to PIC IO's?
Is PIC only active part of the system?

BR,
-Gusse-

Mus.me
- 15th November 2009, 13:35
Hi there,

Any changes that you could share applications schematics with us?
Do you have discrete pull-ups or pull-downs connected to PIC IO's?
Is PIC only active part of the system?

BR,
-Gusse-hello . i have pic16f913 no pull up resistance external,i have a buzzer with 2 transistor but i take them off when the pic in sleep mode i test the current still 5.9 mA in sleep mode it goes up when wake up between 32 to 65 mA, 1 bottom in portb.0 for interrupt wakeup , and 2 leds i take them off but no change .here is my code example .nothings pluged in the ic external . im confused ..?im sure something in the registers or timers i donno how to set timers

Include "modedefs.bas"
@ DEVICE WDT_OFF, PWRT_OFF,MCLR_OFF,CPD_OFF, BOD_OFF, PROTECT_OFF,INTRC_OSC_NOCLKOUT

ANSEL = %00000000
VRCON.7 = 1 'CVref circuit powered down (VREN bit)=save power
CMCON0=%00000111
'WDTCON = %00010110
WDTCON.0 = 0
WDTCON.4 = 3
OPTION_REG.7 = 1 ' i tryed this =0 but the same problm
ADCON0.0 = 0
OSCCON.6 = 7
LCDCON.4=0
LCDCON.6=1
LCDCON.7=0
CMCON1 = 7
INTCON = 0
PCON.4 = 0
PORTB =%00000001
TRISB = %00000001
PORTA = 0
TRISA = 0
PORTC = 0
TRISC = 0

G VAR BYTE
H VAR BYTE
L VAR BYTE
K VAR BYTE
NOTE VAR BYTE
BUZ VAR PORTB.3


MAIN:
G = G + 1
IF G => 30 THEN slp
HIGH PORTB.4
PAUSE 100
LOW PORTB.4
PAUSE 1000
GOTO MAIN

SLP:
OPTION_REG.7=0
'INTCON.0 = 0 'RBIF
'INTCON.3 = 1 'RBIE
INTCON.1 = 0
INTCON.4 = 1
@ SLEEP
@ NOP
PAUSE 100
HIGH PORTB.2
PAUSE 1000
LOW PORTB.2
GOTO MAIN
END

bogdan
- 15th November 2009, 14:37
How much is the consumption when you press and hold the button (portb.0) ?

Gusse
- 15th November 2009, 15:20
How about by changing all pins to inputs before sleep?

<code><font color="#000000">SLP:
OPTION_REG.7=0
<font color="#000080"><i>'INTCON.0 = 0 'RBIF
'INTCON.3 = 1 'RBIE
</i></font>INTCON.1 = 0
INTCON.4 = 1
TRISA = %11111111
TRISB = %11111111
TRISC = %11111111
<font color="#008000">@ SLEEP
@ NOP
</font>TRISA = %00000000
TRISB = %00000001
TRISC = %00000000
<b>PAUSE </b>100
<b>HIGH </b>PORTB.2
<b>PAUSE </b>1000
<b>LOW </b>PORTB.2
<b>GOTO </b>MAIN</code>

Any effects?

BR,
-Gusse-

BrianT
- 16th November 2009, 00:27
I don't use the @ SLEEP command.

I use PBP SLEEP xxx to get a delay and low power.

HTH
BrianT

Mus.me
- 16th November 2009, 03:03
How about by changing all pins to inputs before sleep?

<code><font color="#000000">SLP:
OPTION_REG.7=0
<font color="#000080"><i>'INTCON.0 = 0 'RBIF
'INTCON.3 = 1 'RBIE
</i></font>INTCON.1 = 0
INTCON.4 = 1
TRISA = %11111111
TRISB = %11111111
TRISC = %11111111
<font color="#008000">@ SLEEP
@ NOP
</font>TRISA = %00000000
TRISB = %00000001
TRISC = %00000000
<b>PAUSE </b>100
<b>HIGH </b>PORTB.2
<b>PAUSE </b>1000
<b>LOW </b>PORTB.2
<b>GOTO </b>MAIN</code>

Any effects?

BR,
-Gusse-

hello forum my wishese to everyones , Gusse i did this still nothings and got 1 volt out from each pin and more current, i will try what u BrianT says , thank you for help .

Gusse
- 16th November 2009, 08:07
Are you sure that your PIC is not damaged?
Sound strange that current consumption gets higher when IO's are changed to inputs. I have used this very successfully. During sleep mode, only current consumption that I can see, comes from low dropout 5V regulator.

I think this is only way to put PIC into sleep for undefined period.

<code><font color="#008000">@ sleep
</font></code>
or

<code><font color="#000000"><b>ASM
</b><font color="#008000">sleep
</font><b>ENDASM
</b></code>

BR,
-Gusse-

Mus.me
- 16th November 2009, 08:21
Are you sure that your PIC is not damaged?
Sound strange that current consumption gets higher when IO's are changed to inputs. I have used this very successfully. During sleep mode, only current consumption that I can see, comes from low dropout 5V regulator.

I think this is only way to put PIC into sleep for undefined period.

<code><font color="#008000">@ sleep
</font></code>
or

<code><font color="#000000"><b>ASM
</b><font color="#008000">sleep
</font><b>ENDASM
</b></code>

BR,
-Gusse-
morning Gusse and everyones thank you for helping me .i just wake up and foundout that pic has short of 600 ohm between vcc and gnd i changed the pic the same f913 and sleep mode down to 0.063mA ,and this is my code example thank you again everyone here trying to help .

Include "modedefs.bas"
@ DEVICE WDT_OFF, PWRT_OFF,MCLR_OFF,CPD_OFF, BOD_OFF, PROTECT_OFF,INTRC_OSC_NOCLKOUT

ANSEL = %00000000
VRCON.7 = 1
CMCON0=%00000111
'WDTCON = %00010110
WDTCON.0 = 0
WDTCON.4 = 3
OPTION_REG.7 = 1
ADCON0.0 = 0
OSCCON.6 = 7
LCDCON.4=0
LCDCON.6=1
LCDCON.7=0
CMCON1 = 7
intcon = 0
PCON.4 = 0
PORTB =%00000001
TRISB = %00000001
PORTA = 0
TRISA = 0
PORTC = 0
TRISC = 0

G VAR BYTE
H VAR BYTE
L VAR BYTE
K VAR BYTE
NOTE VAR BYTE
BUZ VAR PORTB.3


MAIN:
G = G + 1
IF G => 30 THEN slp
HIGH PORTB.4
PAUSE 100
IF PORTB.0 = 0 THEN SLP
LOW PORTB.4
PAUSE 1000
IF PORTB.0 = 0 THEN SLP
GOTO MAIN

SLP:
OPTION_REG.7=0
HIGH PORTB.2
PAUSE 1000
LOW PORTB.2
INTCON.1 = 0
INTCON.4 = 1
@ SLEEP
@ NOP
PAUSE 100
HIGH PORTB.2
PAUSE 1000
LOW PORTB.2
g = 0
GOTO MAIN
END