Page 1 of 3

ADC measure negative voltage??

Posted: Mon Jun 24, 2019 6:51 pm
by starter111
Hi, I'm trying to use pyboard measure negative voltage. Is it a way to do so? I can add circuit if needed it.
please help..

Re: ADC measure negative voltage??

Posted: Mon Jun 24, 2019 8:05 pm
by starter111
never mind, looks like just need add two resistors for voltage divider.

Re: ADC measure negative voltage??

Posted: Tue Jun 25, 2019 12:17 am
by jimmo
A voltage divider can only be used to scale a voltage down. i.e. you cannot change its polarity.

Negative voltages (i.e. below your microcontroller's ground) could damage the microcontroller.

Can you describe what you're doing in more detail and we can give you some hints.

Re: ADC measure negative voltage??

Posted: Tue Jun 25, 2019 6:42 am
by Roberthh
Depending on the range of the negative voltage and it's impedance, a voltage divider may work, just between Vdd-ADC_Input-Sensing_Input instead of GND-ADC_Input-Sensing_Input. Don't forget to add a protective Diode to the input, so it cuts off negative voltages.

Re: ADC measure negative voltage??

Posted: Tue Jun 25, 2019 3:10 pm
by chrismas9
I have used the method suggested by @roberthh. Here's how it works. Say you want to measure down to -12V.

Make a 5:1 voltage divider, eg 10k and 40k. Connect 10k between Aref (3V3) and ADC input. Connect 40k from ADC input to negative voltage.

When Vin = 0V ADCin = 3.3 - (3.3 + 0)/5 = 2.44V.

When Vin = -12V ADCin = 3.3 - (3.3 + 12)/5 = 0.24V.

Re: ADC measure negative voltage??

Posted: Tue Jun 25, 2019 8:36 pm
by starter111
I have two 100k resistors.
r1.pin1 connect to 6v.
r1.pin2 connecto to r2.pin1 - adc read at this point.
r2.pin2 connect to somewhere close to -3v(voltage going to measure).

so negative voltage = r1.pin2 v - (6v - r1.pin2 v)

Re: ADC measure negative voltage??

Posted: Wed Jun 26, 2019 12:18 am
by jimmo
starter111 wrote:
Tue Jun 25, 2019 8:36 pm
so negative voltage = r1.pin2 v - (6v - r1.pin2 v)
Intuitively, with two 100k resistors, your ADC pin will be at the midpoint (i.e. the mean) between 6V and the voltage you're measuring.

So when the voltage is -3V, then you have 9V across the divider and so 4.5V across each resistor. So now your ADC is at 4.5V below 6V.

But yeah, don't forget the clamping diodes if you think that the input can go below -6V (or above 4V).

This is all assuming your negative voltage is referenced to the same ground etc.

Re: ADC measure negative voltage??

Posted: Wed Jun 26, 2019 12:27 am
by chrismas9
I think there is a typo in your formula. With 100k resistors you will need a small cap on the ADC input as switched cap ADCs will draw transient current spikes from the inputs.

You don't say what MCU you are using but some STM32 ADC pins are completely intolerant of voltages outside supply and GND so use a Schottky diode pair like BAT54S to clamp to Vss and CDs.

Re: ADC measure negative voltage??

Posted: Wed Jun 26, 2019 6:06 pm
by starter111
thanks for advice, is good idea to add diodes.
currently works well, is very accurate, just wondering is it any bandgap reference pin on pyboard?

Re: ADC measure negative voltage??

Posted: Wed Jun 26, 2019 6:54 pm
by Roberthh
The A3V3 can be used as 3.3 V reference.