Voltage divider readings not very correct

hi,

got the voltage divider (25V) from goodluckbuy and got some issues with it.
when hooking up the 3.3V from the Panda II board, the readings on pin A1 are correct.
setLiniarScale is set to 1023 and the 3.3V produces a value of 1022.99.

when connecting the voltage divider, the voltage is off quiet a bit.
i have noticed that the voltage at the voltage divider is only 4.55V, when connecting Panda II to the USB port as well as when using a 7.6V battery pack.
R2 to ground has a value of 7.4KOhm and R1 to VCC has a value of 29.7KOhm
when using the formula that i found
AnlogReading * (R1+R2)/R2 * 4.55/1023
then i get
729 * 5.013 * 0.0044 = 16.08V
problem is that the supplied voltage to the voltage divider is 12.0V

what am i doing wrong?

need to add, that i have read “Noob needs voltage divider help analog input”, but did not help.

i am averaging the readings of 3 values, read with a delay of 10ms.

The voltage between R1 and R2 junction and ground should be:

V = Vcc * R2/(R1 + R2)

Input impedance of your analog input is parallel to one of your divider resistors

thanks for the quick replies.

@ andre.m
well, they only supply the hardware.
cannot imagine anything going wrong with two resistors.

@ Mike
V = Vcc * R2/(R1 + R2)
That would be a constant though.
VCC in my case is 4.55V, not 5V

@ RobvanSchelven
sorry, but i have no idea what you mean.
i have the power supply on one side of the voltage divider and the Panda II on the other.

[quote]V = Vcc * R2/(R1 + R2)
That would be a constant though.
VCC in my case is 4.55V, not 5V[/quote]

I don’t know what I said VCC. :slight_smile:

Replace Vcc with the voltage you are measuring, which normally would be greater than 3.3V, the maximum for the ADC.

The point I was really trying to make was your formula for a voltage divider was not correct.

This program is very useful for what you are trying to do.

@ 366Cobra - As an example, If you measure the voltage as show in the image it would read 2.5Volt when a 5 volt source is used. This is true if the input resistor of the voltmeter is infinite high… If the input resistance of the voltmeter is ‘low’ for example also 10Kohm it would influence the reading. Since 10Kohm of the meter is now in parallel with R_2 and would result in 5K… The divider is now 10K : 5K instead of 10K : 10K… Input resistance of AD inputs on most micro-controllers is not infinite high. You should consult the data- sheet of the micro-controller and check its input resistance.

1 Like

Yup, to help lower your resistor values. Instead of 10k-10k you can aceive the same thing with 1k-1k which will provide more output drive current for your input.
But don;t take this to an extreme, you would not want to do 1Ohm - 1Ohm :wink:

@ Mike,
sorry mate, but no matter how i use the values in your formula, i never end up getting 12V, not even close.
we know the following values:

  • R1 to VCC = 29.7KOhm
  • R2 to ground = 7.4KOhm
  • VCC at sensor = 4.55V
  • reading of pin A1 = 729 (setLiniarScale = 1023)
    can you please lay out the formula with those values, having 12V as the result?

wow, more details while writing new reply.

@ RobvanSchelven
no, there was nothing connected to it.
I took readings during a run, but the values shown here are the ones from the voltage divider with only the power supply connected and it being set to 12.0V
no extra leads, meters or anything

I am confused!

with 4.55 as the voltage being measured, you will never have 12v.

@ 366Cobra - you wrote 4.55 volt… could it be a typing mistake and needs to be 3.55 volt? that sound more logical… if your MCU is power by 5 volt and the AD resolution is (5/1024) = 0.004882813V / bit * 729 = 3.55 volt

Guys, lets also be really careful here.

Panda has a MAXIMUM input on an ADC of 3.3v. Bad things will happen if you end up with 5v or 4.55v or anything higher than 3v3 on an analog in pin. (edit: it’s the ADC multiplexer that gets damaged, not the ADC itself, but net result: Bad.)

When you figure out your voltage divider, make sure you max out at 3v3.

If this is the device in question, 刘清清|西南交大刘清清|江西新余刘清清|华信通闹事员工刘清清|刘清清人品|刘清清简历 then you should not connect more than 16.5v to it. They claim it’s a “5x” device, really it’s delivering 1/5 of the input voltage.

I would first up test this with just a regulated voltage source. Measure the input, then measure the output. If it’s not giving you 1/5 then time to DIY and make your own voltage divider. If it is, then (obeying the 16.5v), try reading the value in the Fez.

It would probably help if you can explain what the “sensor” is you talk about and what it’s meant to do and how it’s meant to be powered. If for instance it takes 12v input and outputs something in the range of 0-5v, then using this voltage divider will scale that down to 0-1v, which means your 10-bit ADC will not give you a very good resolution within that scale (~322 divisions per 1v). If you then power it by 5v only (say) then it’s outputs might get scaled down to 5/12th’s, so it’s maximum value might now read at 2.08v, and if you then scaled that down (which you really wouldn’t need to) would be .41v, or ~133 units when measured in a 10-bit ADC.

ok, guess i have not explained it too well.
just realized i called the supply voltage for the voltage divider VCC, where i should have just called it +

the panda II is being supplied with the power of the USB port. have also used an additional 9V power supply.

I have a voltage divider, which i have also called a sensor, is supplied with power ‘internally’ from the panda, which measures 4.55V.
so the three pins are connected to ground, 4.55V (5V pin from panda) and analog pin A1.
even connecting the 9V power supply to the panda, still only supplies 4.66V to the voltage divider.
the voltage which i would like to monitor ‘externally’ is 12.0V from a variable power supply. it is connected to the screw type connectors.
later on, the ‘external’ voltage will range between 7V and 14.8V

Panda has a MAXIMUM input on an ADC of 3.3v
good to know, thanks!!

I would first up test this with just a regulated voltage source
yep, that is why i got a power supp;y with exactly 12.0V connected to it.

(5/1024) = 0.004882813V / bit * 729 = 3.55 volt
so you do divide by 5V?
the problem i got is to relate the 3.55V to the voltage input or the to be measured voltage of 12.0V.
the reading is around 71% of its maximum (5/1024), so in theory what i would like to read the value off, should also be 71% of the 25V of the voltage divider, but it should be less than 50% (12V from a max of 25V).

hope this cleared things up.

I am still confused. Could you please draw a diagram of how you are connecting everything.

hope this helps

@ 366Cobra - What are you trying to achieve? Why do you have the 5 volt connected to the sensor?

@ Brett
correct, that is the voltage divider i am using

Why do you have the 5 volt connected to the sensor?
i did not know about the ADC not being able to handle more than 3.3V.

have re-run the test and now i get the following:
external source still 12.0V
voltage from panda to voltage divider is now using 3.3V pin and meter reading is 3.31V
reading from pin A1 is 735

i am amazed that the A1 reading is not much different than before, but because of the lower voltage the calc now works.

doing the maths:
735*(29700+7400)/7400*3.3/1023 = 11.886V

all right, that is accurate enough for me.
i guess the difference is because of the accuracy of the resistors used.

thanks all!!