Arduino Forum

Using Arduino => General Electronics => Topic started by: Vulpecula on Jun 18, 2019, 12:10 pm

Title: Voltage divider question
Post by: Vulpecula on Jun 18, 2019, 12:10 pm
Hey there!

I have a voltage divider which is supposed to function as a crude input protection for an ADC (differential reading). I am familiar in calculating basic voltage dividers and this basically is just that, but somehow I am stuck now.

(https://abload.de/img/dividerlukjy.jpg)

The ADC will see 0.24 volt since that is the differential voltage between the points A and B. But I am struggling to find the right equation to calculate the actual input voltage. Maybe someone is able to point me into the right direction.  :)

Thanks, V.



Edit: I've been juggling with the formula a bit and it seems like I got my solution. So the voltage drop across R2 is supposed to be: UR2 = Uin * R2/(R1+R2+R3). Rearranging that formula will give me the input voltage.


I tried to verify that in practice and built a quick test-setup on a breadboard.


The equation gives me 5.003V, opposing to 5.01V which I've fed into the circuit. But I guess that's okay since I have to take some measurement error into account.
Title: Re: Voltage divider question
Post by: Wawa on Jun 18, 2019, 12:46 pm
Output voltage is 1/21 of input voltage (21:1 ratio).
Your formula UR2 = Uin * R2/(R1+R2+R3) seems right.

Are you sure you can use that diagram?
Most A/Ds must have BOTH inputs voltages within their own VCC-GND.
Or even less than that (common mode range).
I don't see any reference to the A/D's ground (or VCC).
Leo..
Title: Re: Voltage divider question
Post by: Idahowalker on Jun 18, 2019, 12:57 pm
The op may find this info to be useful https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage (https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage), which was found by entering the words "arduino uno read volts" into my favorite internet search engine.

Also, this may be useful http://www.ohmslawcalculator.com/voltage-divider-calculator (http://www.ohmslawcalculator.com/voltage-divider-calculator)
Title: Re: Voltage divider question
Post by: Vulpecula on Jun 18, 2019, 01:05 pm
Are you sure you can use that diagram?
Most A/Ds must have BOTH inputs voltages within their own VCC-GND.
Or even less than that (common mode range).
I don't see any reference to the A/D's ground (or VCC).
Yes, I am sure. I'm using an ADS1115 which has its upper and lower limits at VCC+0.3V and GND-0.3V. I'll be using the differential measurement to pick up the voltage coming from a hall sensor for current measurement. The hall sensor will output +/- 5V (according to the current flow). I do not expect to see that much (more like +/- 2V) but still I need to protect my inputs (voltage spikes, current).

Title: Re: Voltage divider question
Post by: Vulpecula on Jun 18, 2019, 01:13 pm
The op may find this info to be useful https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage (https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage), which was found by entering the words "arduino uno read volts" into my favorite internet search engine.
Thank you for your incredibly helpful link. Unfortunately the ADC of the Arduino is not suitable for what I want to do.



Also, this may be useful http://www.ohmslawcalculator.com/voltage-divider-calculator
Also, this was even more useful:
https://www.electronicshub.org/potential-difference-in-resistor-networks/ (https://www.electronicshub.org/potential-difference-in-resistor-networks/)
Title: Re: Voltage divider question
Post by: Idahowalker on Jun 18, 2019, 01:46 pm
sampling with A0 first and then A1 can be used for a differential measurement?
Title: Re: Voltage divider question
Post by: Wawa on Jun 18, 2019, 01:52 pm
Yes, I am sure. I'm using an ADS1115 which has its upper and lower limits at VCC+0.3V and GND-0.3V.
Also sure, can't do that if you don't refer the inputs to some voltage.

Imagine the bottom part of the 1k resistor 'floating' on about -0.5volt.
Then the top part of the resistor is about -0.25volt.
Both inputs are outside the measuring range (GND-VCC), and the A/D will return zero.
As said, both inputs MUST be kept within VCC/GND of the A/D.
So what are you measuring.
Leo..
Title: Re: Voltage divider question
Post by: TomGeorge on Jun 18, 2019, 02:21 pm
Hi,
Why do you need to read differential voltage from a Hall Effect device?

Can you post a circuit diagram of your project so we can see how you aim to measure the current detected by the Hall Effect Device.
Can you tell us your application?

Part numbers would be helpful too.

Differential input circuitry will not protect your analog inputs as it is all referenced to gnd.

Your Hall Effect device will provide the isolation protection from the measured current.

Tom... :)
Title: Re: Voltage divider question
Post by: Vulpecula on Jun 18, 2019, 05:22 pm
Also sure, can't do that if you don't refer the inputs to some voltage.

Imagine the bottom part of the 1k resistor 'floating' on about -0.5volt.
Then the top part of the resistor is about -0.25volt.
Both inputs are outside the measuring range (GND-VCC), and the A/D will return zero.
As said, both inputs MUST be kept within VCC/GND of the A/D.
That should be the case if the measured device had a common ground shared with the measuring device which is not the case. As far as I understand it, the ADC references differential, meaning A0 against A1 (and not against GND).


@TomGeorge: I am using a hall sensor to measure the current going into electric motors (see attached PFD for more info).

The Schematic of the circuit:

(https://abload.de/img/diffczj5d.jpg)

Please note that the GND of the hall sensor is not the same GND as the one of the ADS1115.
Title: Re: Voltage divider question
Post by: Idahowalker on Jun 18, 2019, 05:25 pm
So the ground to the 24Volts cannot be tied to the Arduino ground?
Title: Re: Voltage divider question
Post by: jremington on Jun 18, 2019, 05:57 pm
Quote
As far as I understand it, the ADC references differential, meaning A0 against A1 (and not against GND).
No, that is not how the ADS1115 works. The inputs are referenced to the ADC ground and internal VREF, and the difference between them is constructed.

Both of the the input voltages must be positive with respect to the ADC ground and within the allowed range, which depends on how the gain section is configured. Furthermore the difference between the two is also limited, to +/- 4.096/(PGA gain) V.

Please explain the real purpose of this circuit. "crude input protection" does not make sense.
Title: Re: Voltage divider question
Post by: Idahowalker on Jun 18, 2019, 06:45 pm
There are a host of schematics (https://i.pinimg.com/originals/63/8c/27/638c27d04cd11f8693d1049b33f22e23.png) where the chip is grounded to the same ground connection as the other device grounds.
Title: Re: Voltage divider question
Post by: Vulpecula on Jun 18, 2019, 08:22 pm
Please explain the real purpose of this circuit. "crude input protection" does not make sense.
So I need to measure a heck of a current. Therefore I have a hall sensor which gives me an output referenced to its own ground (as seen in the PDF earlier). The potential on that output pin will range from -5V to +5V according to the current (-300A min, +300A max).

Testing this with different voltage sources with different polarities gives me the correct values. So if there is something wrong with this circuit, can you tell me what?
Title: Re: Voltage divider question
Post by: Smajdalf on Jun 18, 2019, 08:53 pm
No, that is not how the ADS1115 works. The inputs are referenced to the ADC ground and internal VREF, and the difference between them is constructed.
I think this is NOT how ADS1115 works. AFAIK the ADS charges its internal sampling cap to the measured voltage difference, than it disconnect it from input pins and than measures voltage in the cap. I am quite sure it does not measure both voltages in single-ended mode and subtract them later. It makes no sense. I don't see any problem in measuring a floating voltage that does not share common ground with the system containing the ADS1115.

EDIT: this was stupid, see later post
Title: Re: Voltage divider question
Post by: jremington on Jun 18, 2019, 09:28 pm
Quote
I don't see any problem in measuring a floating voltage that does not share common ground with the system containing the ADS1115.
You may not but the manufacturer certainly does. That is why there are limitations on input voltages.

The ADS1115 is an absolute ADC, with its own internal reference.
Title: Re: Voltage divider question
Post by: Smajdalf on Jun 18, 2019, 09:39 pm
You may not but the manufacturer certainly does. That is why there are limitations on input voltages.
Sure, but when the measured circuit is floating with respect to ADS's ground the protection diodes will "drag" it to the suitable range. It is the same as measuring part of the circuit with a DMM.

The ADS1115 is an absolute ADC, with its own internal reference.
Yes. And compares voltage in the sampling cap to this reference. Internal vs external reference has nothing to do with differential vs single-ended conversion.

EDIT: that part is stupid - it is a sigma-delta ADC, not SAR as Arduino has. I don't know how differential sigma-delta ADCs work and it is well possible they subtract the results.
Title: Re: Voltage divider question
Post by: jremington on Jun 18, 2019, 09:45 pm
Quote
The potential on that output pin will range from -5V to +5V according to the current (-300A min, +300A max).
That is a 10V swing, which cannot be measured by the ADS1115 anyway.

Use a different sensor, with single ended 0-5V output, and all these unfortunate misunderstandings and problems go away.
Title: Re: Voltage divider question
Post by: Vulpecula on Jun 18, 2019, 11:51 pm
That is a 10V swing, which cannot be measured by the ADS1115 anyway.
In that case I might just shift the signal up and do a single ended measurement. Shouldn't that do the job? Of course, I will need a common ground in that case and use a voltage divider to split up the 0 -10 volt range.
Title: Re: Voltage divider question
Post by: jremington on Jun 19, 2019, 12:12 am
That is what I was thinking, too. The usual way is to use a summing amp converter (https://masteringelectronicsdesign.com/bipolar-to-unipolar-converter-examples/) (see Fig. 4).

Please post a link to the data sheet for the sensor.
Title: Re: Voltage divider question
Post by: Vulpecula on Jun 19, 2019, 12:31 am
Link to the hall sensor datasheet: http://www.hallsensors.de/CYHCS-WLY-300A.pdf (http://www.hallsensors.de/CYHCS-WLY-300A.pdf)

A summing amplifier will actually require a -Vcc rail, right? I'll have look into that. Don't know how I'll handle that.
Title: Re: Voltage divider question
Post by: Wawa on Jun 19, 2019, 01:53 am
Sensor must have an internal DC/DC converter, otherwise a single supply and a bipolar output doesn't make sense.
I agree with using an opamp/converter (jremington, post#18) in front of the A/D.
Could be hard to keep zero current drift at bay with an absolute A/D (ADS1115).

Maybe easier to just use Arduino's ratiometric A/D.
10k resistor between sensor output and analogue input, and 10k resistor between analogue input and 5volt.
That will give a 0-current value of about 512, with a deviation from that for positive and negative currents.

Next time buy a current sensor with unipolar output, like 4-20mA.
Leo..
Title: Re: Voltage divider question
Post by: jremington on Jun 19, 2019, 02:01 am
Quote
A summing amplifier will actually require a -Vcc rail, right?
Yes, bipolar power supply with center ground. +/- 15V modules are common and readily available, but for testing, two 9V batteries in series with center tap as ground will work for a while.
Title: Re: Voltage divider question
Post by: Wawa on Jun 19, 2019, 02:16 am
What are you actually measuring.
AC current?, DC current uni-polar? or bi-polar?
Leo..
Title: Re: Voltage divider question
Post by: Vulpecula on Jun 19, 2019, 03:32 am
Maybe easier to just use Arduino's ratiometric A/D. 10k resistor between sensor output and analogue input, and 10k resistor between analogue input and 5volt. That will give a 0-current value of about 512, with a deviation from that for positive and negative currents.

Next time buy a current sensor with unipolar output, like 4-20mA.
That is the sensor I got at hand. I considered to buy a proper one but I got this one basically for free so I'm giving it a shot.

And yes... I guess I could try to use the Arduinos own ADC. I'll lose a lot of my resolution but I'll have a look at it.

I am measuring DC bi-polar.
Title: Re: Voltage divider question
Post by: Wawa on Jun 19, 2019, 05:27 am
And yes... I guess I could try to use the Arduinos own ADC. I'll lose a lot of my resolution but I'll have a look at it.
A trade-off between resolution and a drifting zero point.
Again, depends on what you're measuring (which you didn't say yet).
Zero current drift is irrelevant with A/C, because the code takes care of that.
But it could be a pain when measuring DC.

You could get a resolution (steps) of 1Amp with this sensor and Arduino's 10-bit A/D.
Maybe 0.5A with good smoothing code.
Leo..
Title: Re: Voltage divider question
Post by: Southpark on Jun 19, 2019, 05:31 am
Hey there!

I have a voltage divider which is supposed to function as a crude input protection for an ADC (differential reading). I am familiar in calculating basic voltage dividers and this basically is just that, but somehow I am stuck now.

(https://abload.de/img/dividerlukjy.jpg)

The ADC will see 0.24 volt since that is the differential voltage between the points A and B. But I am struggling to find the right equation to calculate the actual input voltage.
The diagram symbols with the arrows marked with 2.38V and 2.62V don't appear to clearly indicate what voltages they are representing.
Title: Re: Voltage divider question
Post by: Smajdalf on Jun 19, 2019, 06:47 am
Oh god, OP has -5V to 5V output (it is not the same as 0V to 10V!) and ADC able to measure -5V to 5V differential voltage. It looks like a perfect match! Why do you suggest to use summing amplifier or similar crap? If you don't trust ADS1115's ESD clamp diodes to keep the input within its rails (do you have a reason for this distrust?) you can always add external clamping diodes.
And of course adding voltage divider from #8 will reduce the input from -5/5V to about 1/20. I am not sure if it is needed but if the input swing is reduced this way it may be connected to ADS's Vcc/2 by simple voltage divider.
The above is true only if the supplies of the two devices are truly independent ofc.
Title: Re: Voltage divider question
Post by: Vulpecula on Jun 19, 2019, 09:51 pm
Okay, the topic of this thread and the title don't really match anymore but anyways... My intention was to measure the current flow through DC motors using the hall sensor I have at hand. The motors can turn in either direction - so does the current flow accordingly. Brief overview:

(https://abload.de/img/motorleads1xjcw.jpg)



Now... What if I pick up the current somewhere else instead of inside the motor loop? For instance on the common ground line which is connected to the systems batteries? Okay, that would not resemble the sole motor current but I could live with that. A little something like this:


(https://abload.de/img/gndleada1kkz.jpg)


In that case, the hall sensor will only output in a range of 0V to +5V since the current will only flow into one direction. This means I could skip the differential reading and go for the single ended measurement with a proper protection on the input:

(https://abload.de/img/singleidjzp.jpg)

(Don't mind the voltage divider, I'll have to change the values to come closer to the measured range. Also: The GND in this picture is the same potential as the GND of the hall sensor.)
Title: Re: Voltage divider question
Post by: Wawa on Jun 19, 2019, 11:22 pm
Measuring supply current single-ended with the ADS1115 could work.
Don't overthink protection. The internal clamping diodes of the ADS are rated for 10mA max.
No need for external ones.
I would only use a single 10k resistor between sensor output and ADS input.
And a smoothing cap from ADS input to ground if the motor is PWM-ed.
The PGA gain setting can be used as current range select.
Could ofcourse also use the sensor in the + power wire.
Leo..