Electronic – calculate battery voltage using pic ADC

adcferritepic

I need to calculate battery voltage using my PIC's ADC. My battery voltage is 24V and ADC has a 12 bit resolution, the PIC operating voltage is 3.3V.

I am using the PIC's internal Vref+ and Vref- as reference voltages, ferrite bead (model 1206 ) I don't know the correct value. Why is the ferrite bead used?

How can I calculate the battery voltage using this circuit please help me with the calculation clearly?

enter image description here

Best Answer

I will write this answer a little more elaborately, as you do not seem to have very much knowledge about electronics.

First of all, your circuit does not look like a voltage measuring circuit, but more like a supplying circuit. (May be for your PIC microcontroller?)

The zener-diode Z2 limits the voltage on the right side to a maximum of 3.3V. (It does so by just becoming conductive at that voltage.)

Due to this, there is a voltage drop of 24V-3.3V=20.7V over R2, leading to a total current of 20.7mA. From this, 1.5mA will flow through R13, the rest of 19.2mA will flow through Z2.

If you connect something consuming let's say 15mA at 3.3V to the right side, Z2 will only consume 4.2mA. The total current through R2 will still be 1.5mA+15mA+4.2mA=20.7mA, so the voltage drop is still 20.7V and the remaining voltage on the right still is 3.3V.

However, if you connect something consuming more that 19.2mA, the overall current through R2 exceeds 20.7mA and so does the voltage drop. The Voltage on the right breaks down, below 3.3V.

So, this circuit allows to supply a 3.3V device consuming not more than 19.2mA on the right side. But be aware that there will always be a current of 20.7mA, even if no device is connected. This will slowly drain the battery. Also, due to the high voltage drop, over 86% of the battery's power is wasted as heat! That's not very efficient.

C1 and C9 (and their values) are quite typical blocking capacitors used e.g. near micro controllers. The power consumption of a microcontroller can change very quickly, while the wires also have an inductance. This means the circuit can not fulfill the fast changing power demands, leading to an unstable supply voltage for the microcontroller. As result, the microcontroller may not work fine. That capacitors act as buffer and can provide some current until the rest of the circuit provides the full current. (If you want, it's like a pantry)


Comming to the ferrite:
A first remark: 1206 is just the physical size, not the model, nor any electrical parameter
Ferrites block high frequencies and allow low frequencies (and DC) to pass. This also means they can filter sudden spikes of current by smoothing them a little. Let's say you have that microcontroller with its fast changing current consumption and some other circuit very sensitive to a smooth supply voltage. The current consumption of the microcontroller would cause voltage drops, which would be noticed by the other circuit. That ferrite would reduce this effect by smoothing the current flowing to the microcontroller. However, that would cause bigger voltage drops on the microcontroller side, but therefore, you have the capacitors.


Finally, you asked how to measure a battery voltage by ADC. In general, an ADC accepts a certain input voltage range. For the PIC, it is defined by \$V_{REF-}\$ and \$V_{REF-}\$ . In most cases, \$V_{REF-}\$ is 0V and \$V_{REF-}\$ can be chosen between the supply voltage (3.3V in your case) or an internal reference (see datasheet, I guess 1.25V). But it's also often possible to feed your own, external reference voltage to the ADC.

For precise measurement, use the internal reference, as it is independent from the supply voltage and very stable.

The ADC converts a voltage within that range to a number, i.e. \$n=0\$ for \$V_{ADC\_in}=V_{REF-}\$ and \$n=2^{12} - 1= 4095\$ (12-bit ADC) for \$V_{ADC\_in}=V_{REF+}\$. So, the conversion is

$$V_{ADC\_in}=(V_{REF+}-V_{REF-})\cdot\frac{n}{2^{12}-1}+V_{REF-}$$

Now, your battery voltage exceeds the range of the ADC, so you want to divide it down until it's in range. Do it so that the expected voltage to be measured will be a little below the upper ADC limit. For example, to measure your 24V using the internal 1.25V reference, use a 19kOhm and a 1kOhm resistor to divide the 24V down to 1/20, which is 1.2V. Of course, you will have to multiply \$V_{ADC\_in}\$ by 20 to get the actual voltage.