0
\$\begingroup\$

I have this small robotics hobby project. That robot is powered from multiple sources, main power line is 12 V, either a lead-acid battery or a wall-wart 12 V power supply.

I wanted to measure the voltage of the input power using ADC of one of the MCUs I have inside (PIC18F), but it is a 5 V MCU and on top of that I am using the internal voltage reference for ADC so that it's more accurate, which is 4 V, so I need to divide the input voltage into something lower than 4 V.

For that I create a trivial voltage divider from 2 resistors, 10 kΩ and 4.7 kΩ resistor, which seemed to work. The problem I was facing was that the value returned by the ADC was getting higher when the load on the robot increased and the input voltage decreased.

I was originally thinking the problem was with my MCU programming, but then I connected a multimeter to that same pin and saw that indeed the voltage divider output voltage is increasing as the input voltage decreases - basically when the input was about 12 V the output of divider was around 3.8 V, and when the system was under load (I was moving some servos) and the input dropped to 11 V, thr output of voltage divider got over 4 V (it was connected using the wall wart, will test with battery later). Why is this? How is it even possible?

\$\endgroup\$
3
  • 3
    \$\begingroup\$ A diagram of how your system is connected would be helpful in diagnosing the problem you are experiencing. \$\endgroup\$
    – vir
    Aug 1, 2022 at 20:58
  • \$\begingroup\$ @vir I can try to make some, but it's huge... there are 4 different MCUs and raspberry with many sensors, servos and motors, I can try to simplify it, but it will probably take me a couple of days to draw it. \$\endgroup\$
    – Petr
    Aug 1, 2022 at 20:59
  • 2
    \$\begingroup\$ My gut feeling is you have some sort of ground bounce problem where the ground reference voltage of your MCU is rising because you are using a common return connection to your main power input. The increased current of your servos could therefore create a non-trivial change in the potential between your MCU's ground and the power supply's return line. A high level block diagram and picture of how everything is connected would go a long way towards confirming this or suggesting some other issue. \$\endgroup\$
    – vir
    Aug 1, 2022 at 21:04

1 Answer 1

3
\$\begingroup\$

You say "connected to the pin" (emphasis added). Two pins are required to measure voltage. If there is a difference between the ground of the divider and the ground of the ADC then you can get that kind of thing happening. See the dual schematic below. When the load is removed, the voltage across the battery and the voltage across the load both increase, but the measured voltage drops.

The 0.1 ohm series resistance represents battery internal resistance and the 0.5 ohm resistances represent wiring resistances.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.