Is this the best way to take analogue readings (pic)

Thread Starter

Torbek

Joined Apr 19, 2019
57
Hi folks, I have a pic running off a car battery, I want to take samples of battery voltage so have come up with the following circuit.

I have used a P FET (BS250, it's all I have) to switch the 14v on/off, but as the controller side is 5v max I clearly won't be able to turn this FET off...

I would be interested if anyone knows of a small 3-pin package FET that will work with 5 or 3v3 logic so I can get rid of the extra stage, I know there are a good few N types available.

Anyway, is this about as simple as I can make it?

1662109014899.png

https://photos.app.goo.gl/2JNCMMnKPgywwuPy8
 

DickCappels

Joined Aug 21, 2008
9,317
Using an AVR I managed to do this without any external parts. Maybe your PIC can also do this.

With this technique the power supply voltage (battery voltage) is used as the reference for the A-to-D converter and the A-to-D then measures the voltage out of an 1.2 volt on-chip bandgap voltage reference. The voltage of the voltage reference is already known, and can be calibrated for increased accuracy if needed.

The measured The count on the voltage reference is a function of the power supply (battery) voltage, to wit:

How its done
The "M" command causes the reference voltage measured against VDD to be displayed. If you take off the cover and measure VDD and then execute the "M" command to measure the bandgap using VDD as the reference, you can calculate the bandgap reference voltage. Knowing the bandgap reference voltage, the result of the "M" command can be use to calculate VDD in the future. this makes it possible to see how well the battery is holding up without opening the box.

First find the bandgap voltage (Vref). Measure VDD and measure the bandgap reference with respect to VDD using the "M" command..

Vref = (VDD/255) x Count

Thereafter, the VDD can be calculated by:
VDD = (255 Vref)/Count

This can also be done graphically with the Figure below.

1662115646586.png
If you would like to use a graph, here is VDD as a function of measured Vref voltages for the lowest, mean, and highest Vref for this controller.
 

DickCappels

Joined Aug 21, 2008
9,317
You can switch the bottom of the voltage divider with an I/O pin by switching the I/O pin to an input while sleeping and as an output with a logic Low on it during the measurement. I have use I/O pins of controllers like this in lots of applications over the years and not had an issue. This only works if your battery voltage is very close to the positive power supply of your controller. My application was battery powered.
 

Thread Starter

Torbek

Joined Apr 19, 2019
57
Ok folks, thanks for the replies. Been v busy recently so apologies for not responding quicker!

Ok so reason I cannot switch from the bottom is because to do so will put the full voltage onto the PIC, which would possibly destroy it, or at least the protection clamping diodes. Even if not, I don't think it's good practice to leave the pin open to 14+V.

However, I do quite like @ericgibbs option, certainly simpler than my switching arangment and seems to serve the purpose well!

Thank you Eric!
 

Ian0

Joined Aug 7, 2020
6,294
I want to conserve as much battery as I can, so when it goes to sleep I am consuming no current.
Why? Just use a high value for the resistive divider (and you May need to slow down your A/d converter).
If you assume that a car battery will self-discharge in about 6 months, then that is equivalent to about 13mA for a 60Ah battery.
If your divider current is <1mA then it will make no difference.
Don’t forget how much current the other resistors in the circuit will consume!
 
Top