• AVR Freaks

AnsweredHot!Low Power Battery Monitoring with PIC10F320

Author
erikblue
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/04/30 13:00:16
  • Location: 0
  • Status: offline
2020/03/23 15:58:58 (permalink)
0

Low Power Battery Monitoring with PIC10F320

Hi, 
I'm currently using a PIC10F320 to monitor a Li-Ion cell voltage and cut it off from the load when the voltage gets too low.  It seems like from the datasheet I should be able to get down to 4uA of current if I stay in sleep and have the watchdog wake me up periodically (looking at D024 datasheet spec).  But I'm only able to achieve ~25uA quiescent on average, which tends to drain the battery too much over time.  I wonder if I'm even going to sleep actually as I'm operating the main oscillator at 500kHz.  I also notice the quiescent current spikes up to 200uA at 2V Vdd and I can't understand why exactly.
 
Attaching my project in case someone can take a quick look at my settings or has some suggestions.  I am not a PIC expert, but I've tried many things including turning of the FVR and ADC before going to sleep.  Unfortunately I do need to keep one I/O active during sleep (to turn on a power path MOSFET), so I understand that this will impact my sleep current, although I haven't found any information how it will impact.
 
Thanks for any help,
 
Erik
 
post edited by erikblue - 2020/03/24 08:04:06
#1
davea
Super Member
  • Total Posts : 212
  • Reward points : 0
  • Joined: 2016/01/28 13:12:13
  • Location: 0
  • Status: online
Re: Low Power Battery Monitoring with PIC10F320 2020/03/23 16:23:39 (permalink) ☼ Best Answerby erikblue 2020/03/23 21:29:00
0
you are correct it should be less then 2uA in sleep
with WD wakeup, turn it on and do 1 ADC convert using
FRC as the clock for the ADC then turn it off
and back to sleep
if FRC is not the clock and ADC is on all the time then that's why
also any floating pins will draw extra current 
what is the FVR used for ?? 
post edited by davea - 2020/03/23 16:24:58
#2
mbrowning
USNA79
  • Total Posts : 1684
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: online
Re: Low Power Battery Monitoring with PIC10F320 2020/03/23 16:34:30 (permalink)
+1 (1)
A PIC10F320 is only rated down to 2.3V. At 3V, base current in sleep is 15uA. At 2V anything can happen.
 
You are using the wrong part. Should be using PIC10LF320.
 
In addition, RA2 is set to output low (LATA=0, TRISA=0), but with digital input buffer disabled for analog mode (ANSELA=4). So whatever analog signal you are trying to measure on RA2 is being driven low, probably drawing additional current.
 
edit - oops, I had a very old "preliminary" datasheet.
 
post edited by mbrowning - 2020/03/23 16:37:28
#3
erikblue
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/04/30 13:00:16
  • Location: 0
  • Status: offline
Re: Low Power Battery Monitoring with PIC10F320 2020/03/23 16:36:57 (permalink)
0
I was setting ADCCON to 0 before going to sleep.  I will look at the FRC.  Do you have any thoughts why current consumption gets high near 2V Vdd?
 
FVR is used in a strange way.  I am basically measuring VDD indirectly by measuring FVR.
 
So, I should set any extra pins to strong drive low?
#4
mbrowning
USNA79
  • Total Posts : 1684
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: online
Re: Low Power Battery Monitoring with PIC10F320 2020/03/23 16:39:42 (permalink)
+2 (2)
erikblue
FVR is used in a strange way.  I am basically measuring VDD indirectly by measuring FVR.

This is how I always use FVR. I don't want to give up measurement range.
 
At 2V you are operating below rated voltage. anything can happen.
#5
erikblue
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/04/30 13:00:16
  • Location: 0
  • Status: offline
Re: Low Power Battery Monitoring with PIC10F320 2020/03/23 16:41:58 (permalink)
0
mbrowning
You are using the wrong part. Should be using PIC10LF320.
 
In addition, RA2 is set to output low (LATA=0, TRISA=0), but with digital input buffer disabled for analog mode (ANSELA=4). So whatever analog signal you are trying to measure on RA2 is being driven low, probably drawing additional current.
 



Well, the Li-Cell can go up to 4.4V, so that's why I selected the PIC10F320.  Thanks for the tip on RA2, I will check that.
#6
piticbogdan
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2018/12/02 17:58:02
  • Location: 0
  • Status: online
Re: Low Power Battery Monitoring with PIC10F320 2020/03/23 17:17:37 (permalink)
0
did you disabled FVR circuit buffer (ADFVR) before sleep ?
post edited by piticbogdan - 2020/03/23 17:24:08
#7
erikblue
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/04/30 13:00:16
  • Location: 0
  • Status: offline
Re: Low Power Battery Monitoring with PIC10F320 2020/03/23 18:12:35 (permalink)
0
piticbogdan
did you disabled FVR circuit buffer (ADFVR) before sleep ?

Yes, I selected "00 = ADC Fixed Voltage Reference Peripheral output is off."
#8
erikblue
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2019/04/30 13:00:16
  • Location: 0
  • Status: offline
Re: Low Power Battery Monitoring with PIC10F320 2020/03/23 18:42:16 (permalink)
+1 (1)
I got down to 10uA with davea suggestions to clock the ADC with FRC.  I have unused I/Os strong drive low.  Then I found this VREGCON register which manages the integrated voltage regulator for the PIC10F320 devices that can operate >3.6V.  If I set VREGCON = 0x02, this enables the lowest power consumption for the voltage regulator in sleep.  Now I'm sitting at about 3uA, much better!  Thank you all for your help.
 
I wish I could get low power while in POR, though.  Once I get near 2-2.2V or so the current shoots up to 200uA as I said previously.
 
#9
davea
Super Member
  • Total Posts : 212
  • Reward points : 0
  • Joined: 2016/01/28 13:12:13
  • Location: 0
  • Status: online
Re: Low Power Battery Monitoring with PIC10F320 2020/03/23 21:05:24 (permalink)
+3 (3)
also if your not using the programing pins
they will float, turn on WPU's for them
and the debugger will still work
#10
Howard Long
Super Member
  • Total Posts : 791
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: Low Power Battery Monitoring with PIC10F320 2020/03/24 14:13:02 (permalink)
0
--ignore will repost--
post edited by Howard Long - 2020/03/24 14:17:12
#11
Antipodean
Super Member
  • Total Posts : 1811
  • Reward points : 0
  • Joined: 2008/12/09 10:19:08
  • Location: Didcot, United Kingdom
  • Status: offline
Re: Low Power Battery Monitoring with PIC10F320 2020/03/24 14:15:42 (permalink)
+1 (1)
erikblue
Once I get near 2-2.2V or so the current shoots up to 200uA as I said previously.

 
That sounds like the gates are going into linear mode, as the Vdd gets below the gate threshold voltage.
 
Can the LF part not be powered from 5V?

Do not use my alias in your message body when replying, your message will disappear ...

Alan
#12
Howard Long
Super Member
  • Total Posts : 791
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: Low Power Battery Monitoring with PIC10F320 2020/03/24 14:18:46 (permalink)
0
I can get 180nA at 5V in sleep with no WDT. With the WDT it's 530nA @5V.
 
One problem with this device is that if you use the INTOSC, it starts at 8MHz, so there's inrush current from that. In some tests I've done previously with other devices, I used a 32kHz watch crystal or external RC which limits the inrush where I can't boot with the LFINTOSC.
 
Even with a 32kHz watch crystal, below the 2.3V all bets are off, I've seen these devices essentially having a negative resistance response, which makes starting them up from a severely degraded battery impossible in some scenarios.
 
For really low power wake up, you can pick a device with the ULPWU option, which gives you about 150nA sleep current with periodic wake up if you're careful.
 
Some devices can be set to start up with LFINTOSC or RC which will greatly reduce the inrush current, and you won't need a crystal. There are a few that operate 2 to 5.5V with integrated ADCs e.g. 12F683, 12F675. The 12F683 includes a ULPWU as well as ADC and RC oscillator at boot. I'm not sure if there's a 2.0-5.5V device that can boot with LFINTOSC, and has an ADC.
 
More recent 8 pin devices in the PIC12F1xxx and PIC16F1xxxx range only go down to 2.3V. These more recent devices are quite a bit easier to work with.
 
The PIC10F322 code below twiddles RA2 to give an indication of where it is, initial reset (quick twiddle) or the WDT timing out (toggle every 4s or so). There is indeed quite a long start up time of several hundred ms at around 500uA current draw with VREGPM1==1 whjen the device comes out of sleep. IF should run on a PIC10F320 too, I just don't have them in stock.
 


// PIC10F322 Configuration Bit Settings
// 'C' source line config statements
// CONFIG
#pragma config FOSC = INTOSC // Oscillator Selection bits (INTOSC oscillator: CLKIN function disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled)
#pragma config WDTE = SWDTEN // Watchdog Timer Enable (WDT controlled by the SWDTEN bit in the WDTCON register)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select bit (MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
#pragma config LPBOR = OFF // Brown-out Reset Selection bits (BOR disabled)
#pragma config BORV = HI // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), high trip point selected.)
#pragma config WRT = ALL // Flash Memory Self-Write Protection (000h to 1FFh write protected, no addresses may be modified by PMCON control)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <xc.h>
#define _XTAL_FREQ 8000000
int main(void)
{
NOP();
NOP();
NOP();
// All resets including WDT timeout mess with these registers
TRISA=0;
ANSELA=0;
if (STATUSbits.nTO) // If not a WDT time out...
{
LATA=0;
LATAbits.LATA2=1;
__delay_ms(250);
LATAbits.LATA2=0;
__delay_ms(250);
LATAbits.LATA2=1;
__delay_ms(250);
LATAbits.LATA2=0;
__delay_ms(250);
LATAbits.LATA2=1;
__delay_ms(750);
LATAbits.LATA2=0;

}
else
{ // WDT timeout
LATAbits.LATA2=!LATAbits.LATA2; // Toggle RA2 on WDT timeout, LATA isn't busted by WDT reset
}

// These registers need setting after any reset including WDT
// WDTCONbits.WDTPS=0b01011; // 0b01011 = 1:65536 (Interval 2s nominal) (Reset value)
WDTCONbits.WDTPS=0b01100; // 01100 = 1:131072 (217) (Interval 4s nominal)
VREGCONbits.VREGPM1=1; // 1 => Power-Save Sleep mode enabled in Sleep. Draws lowest current in Sleep, slower wake-up.
WDTCONbits.SWDTEN=1;
SLEEP();

while (1)
{
NOP();
}
return 0;
}

#13
ric
Super Member
  • Total Posts : 26159
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Low Power Battery Monitoring with PIC10F320 2020/03/24 14:19:52 (permalink)
+1 (1)
Anti podean
Can the LF part not be powered from 5V?

No. VDDMAX is 3.6V for the LF.
Absolute Max is 4.0V
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#14
ric
Super Member
  • Total Posts : 26159
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Low Power Battery Monitoring with PIC10F320 2020/03/24 14:23:36 (permalink)
+1 (1)
Note to everyone, do NOT quote posts from anti-podean without mangling his username, or your posts will vanish, just as his signature states.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#15
davea
Super Member
  • Total Posts : 212
  • Reward points : 0
  • Joined: 2016/01/28 13:12:13
  • Location: 0
  • Status: online
Re: Low Power Battery Monitoring with PIC10F320 2020/03/24 18:35:12 (permalink)
+1 (1)
void SYSTEM_Initialize(void)
{
    //PMD_Initialize();
    PIN_MANAGER_Initialize();
    //OSCILLATOR_Initialize();
    WWDT_Initialize();
    CCP1_Initialize();
    CLC2_Initialize();
    TMR2_Initialize();
    TMR0_Initialize();
    CLC1_Initialize();
    CLC4_Initialize();
    CCP2_Initialize();
    ADC_Initialize();
    CLC3_Initialize();
    TMR1_Initialize();
    ZCD_Initialize();
}

void main(void) {
   OSCCON1 = 0x50; // LFINTOSC
   SYSTEM_Initialize();
   AVG_tmp = 5000;
   do{
      AVG_tmp--;
   }while(AVG_tmp != 0); // APX 5 SEC
   OSCILLATOR_Initialize();
   INTERRUPT_GlobalInterruptEnable();
   INTERRUPT_PeripheralInterruptEnable();

the 5 sec delay is only to let the supercap charge up
#16
Jump to:
© 2020 APG vNext Commercial Version 4.5