Log in

View Full Version : Monitor supply voltage of chip?



robbo78
- 24th February 2016, 18:53
Hi everyone, I need some help with monitoring battery supply voltage to the chip. I am supplying the pic (12f683) with a 3.7v 18650 battery. Basically I want to trigger a comparator interrupt when the voltage hits the 2.8v mark, which will then put the pic into low power mode (sleep/nap).

My problem is that as the supply voltage is coming from the same battery that I want to monitor the voltage from, I cant seem to find a way to use comparator or adc. This is because the voltage reference (supply voltage) is dropping at the same rate as the pin that I will be reading from, it doesn't matter if I use a divider or not, I just cant find a way.

Can anyone help with this or is it impossible without a separate/fixed voltage input to the chip?

LinkMTech
- 24th February 2016, 19:31
I think a fixed Vdd to the PIC set below the "low battery" level is your only recourse with this one.
Then a simple voltage divider to monitor the battery level with the A/D to trigger sleep mode after that.

If you're not sourcing much through the 12F1683, a small 2.?V zener is all you'll need for Vdd.

Heckler
- 24th February 2016, 19:50
The datasheet for the 12f683 shows that it has an internal Fixed Voltage Reference that can be used to compare against the supply voltage.

pedja089
- 24th February 2016, 19:57
There is more than one way to to this. All you need is fixed reference voltage.
Eg 0,6V from diode(if you can tolerate drift about 2mV/degC), some pic have built in diode for temp. monitoring, or pic fixed reference(FVR), or voltage from some blinking LED(Do battery check when LED is on).
So you can feed fixed voltage on ADC pin, and use Vdd as reference for ADC. If Vdd is lower than ADC result are higher and reverse.
Some pic have FVR on ADC multiplexer(or internal diode), so there is convenient way to do that, without loosing io pins.
If you are using external fixed reference, you can use IO pin to turn on/off reference to minimize current draw.

Heckler
- 25th February 2016, 01:40
Hey Robbo,

If you decide to use the internal Fixed Voltage Reference you might want to take a look at my second post in this tread... http://www.picbasic.co.uk/forum/showthread.php?t=19035

and read this thread also... http://www.picbasic.co.uk/forum/showthread.php?t=17321

sorry that my post about the FVR earlier was so short but I was at work.

towlerg
- 25th February 2016, 02:49
have a look at AN1072. Darrel wrote a piece about the subject.

pedja089
- 25th February 2016, 08:44
Heckler
According to microchip's datasheet( http://ww1.microchip.com/downloads/en/DeviceDoc/41211D_.pdf ) PIC12F683 doesn't have Fixed Voltage Reference.

robbo78
- 25th February 2016, 10:01
Thanks for all the replies! Yes the 12f683 doesn't have a FVR, so that's out the question. I think I am going to go with "LinkMtech's" idea and just use a 2.4v Zener to regulate the chips supply, then a divider onto a pin for reference.

Thanks for your help.

amgen
- 25th February 2016, 13:47
microchip has a to92 voltage detector...... different voltages and draws 1 microamp....
http://ww1.microchip.com/downloads/en/DeviceDoc/21434g.pdf

pedja089
- 25th February 2016, 14:08
@robbo78
That solution is not good for battery.
With zener regulator current draw from battery is same in if pic is sleep mode as in run mode.
If you use zener, then feed that voltage into analog pin, and then do ADC. This way current thru zener can be few uA instead few mA.

towlerg
- 25th February 2016, 15:10
I don't know how wedded you are to the PIC12F683 but PIC12f617 looks similar but with a 0.6v ref but no EEPROM (although it can self write so that needn't be a show stopper).

Dick Ivers
- 25th February 2016, 16:41
PIC 12F1822 has FVRs and eveyrthing else you need.

peterdeco1
- 25th February 2016, 17:07
I recently made a low battery warning for a 12V lead acid battery using a 12F675. B+ 12V powers the PIC through a 3.3V LDO regulator.The same B+ 12V goes to the ADC pin through a 220K resistor. The ADC pin then has 47K to ground. Here's the code I used. It flashes an LED when the battery gets weak. Perhaps you can tweak the code and circuit for your application to put the PIC in low power mode.

ANSEL = 0 'all inputs digital ADC command will convert it to analog
CMCON = 7 'comparators off
DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1K device
TRISIO = %00000001 'INPUT ANA0 FOR ADC READINGS
GPIO = 0 'ALL OUTPUTS LOW
BATTEST VAR BYTE
@ DEVICE MCLR_OFF, WDT_ON, BOD_ON, PWRT_ON, PROTECT_ON

TEST:
Clear 'CLEAR BATTEST
ADCIN 0,BATTEST 'TEST CHARGE
IF BATTEST <= 166 Then GoSub BLINK
GoTo TEST

BLINK:
High GPIO.2
Pause 500
Low GPIO.2
Pause 500
Return

towlerg
- 25th February 2016, 18:29
PIC 12F1822 has FVRs and eveyrthing else you need.

Oh yes, thats nice. I don't understand why I didn't find that in the truly horrible Microchip selector... but of course, it's terrible.

Heckler
- 26th February 2016, 03:34
@ pedja,

sheesh, your right, I'm not sure which datasheet I was looking at but it wasn't for the 12f683. :D

As others have pointed out there are other choices such as the 12f1822, etc. that do.

Acetronics2
- 26th February 2016, 16:27
The datasheet for the 12f683 shows that it has an internal Fixed Voltage Reference that can be used to compare against the supply voltage.

hi, Dwight,

not really a reference for the 683 ...




- Programmable on-chip voltage reference
(CVREF) module (% of VDD)

so, here it is not possible to reach the goal ...

Alain

robbo78
- 26th February 2016, 19:02
@robbo78
That solution is not good for battery.
With zener regulator current draw from battery is same in if pic is sleep mode as in run mode.
If you use zener, then feed that voltage into analog pin, and then do ADC. This way current thru zener can be few uA instead few mA.

Good idea! I have just found this part which is a bit of a "cheat", and quite cheap? - http://www.farnell.com/datasheets/1669371.pdf

EDIT: Just realised that "amgen" already stated this :o


microchip has a to92 voltage detector...... different voltages and draws 1 microamp....
http://ww1.microchip.com/downloads/e...Doc/21434g.pdf