current measurement over time

Thread Starter

abc14

Joined Oct 15, 2017
117
I have a RC servo towerPro sg90 connected to Arduino, to measure the current I have put 1 ohm shunt resistor between servo GND and power ground.
Then I did a analogRead on the resistor, when servo sweep between 0 -180. I am getting following values out of my analogRead.


So in total I have 180 readings from 0 -180 sweep, and I have 15ms delay the loop, all in all its takes 2700ms or 2.7 secs to complete the sweep.
Values from analogRead ranging from 20 - all the way upto 250, since servo is controlling a small flap.

Now I have two questions here..


1. Is this analogRead is my voltage, or do I have to convert it into voltage, like analogread *(3.3/1023).. Then its simply voltage/R is my current.

2. Total current, will it be sums of all the 180 values calculated in the step 1.


I am going to copypaste the raw serial output as well... The serial monitor is running at 9600 buad rate, if its useful to know.




1582198567862.png
 

Attachments

Alec_t

Joined Sep 17, 2013
10,918
do I have to convert it into voltage, like analogread *(3.3/1023)
Yes, assuming your Arduino's A/D converter is a 10-bit one.
By 'total current' I suspect you mean total charge, which is the integral of current*time.
 
Last edited:

Thread Starter

abc14

Joined Oct 15, 2017
117
Yes, assuming your Arduino's A/D converter is a 10-bit one.
By 'total current' I suspect you mean total charge, which is the integral of current*time.
yes total charge, goal here is to estimate how long the battery is going to last, as an input to my model how much charge/current is consumed by servo for each opening operation.

So from this data I can conclude the peak current draw is 770mA ?
 

Alec_t

Joined Sep 17, 2013
10,918
Looks like it. But current will also be affected by the load the servo is trying to shift, so may be much higher in practice.
 

Thread Starter

abc14

Joined Oct 15, 2017
117
Looks like it. But current will also be affected by the load the servo is trying to shift, so may be much higher in practice.
Yes, beside since I didn't have actual 1 ohm resistor, hence i put 10x10ohms resistor in parallel to make 1 ohm resistor, the power rating of individual resistor is 1/4 Watts. Not sure how power rating effects the current calculation
 

Reloadron

Joined Jan 15, 2015
5,140
Among the problems you might have is you are using the Arduino 10 bit ADC and really looking at low level signals. I have no idea how much you do this sort of stuff but I tried a ADS1115 16 Bit 16 Byte 4 Channel I2C IIC Analog-to-Digital Converter along with an Arduino Uno and got really good results. Really slick as you can use I2C to connect. Here is an Arduino example. Among the nice features is programmable Gain so while the default is +/-6.144 volts and dividing 6.144 volts by 32767 yields a scale factor of 0.1875 mV per bit. Roughly 26 times the Arduino native 10 bit. In another PGA setting, you can establish a full scale of +/- 2.048 volts. That provides us a resolution of 0.0635 mV. Some other nice features are programmable address. Like anything on Amazon you need to shop carefully. I got two for under $4.00 each. I send the data to a 4 x 20 LCD. Something else nice is it is a 4 channel unit ADC single ended input yopu can also use it in a differential mode and have 2 differential channels. Very useful when doing shunt measurements.

Using 10 1/4 watt resistors in parallel assuming all are exactly 10 Ohms you would have yourself a 2.5 watt 1.0 Ohm resistor which is 10 * 0.250 watt. Your voltage drop across the shunt is also subtracted from the load. So for example starting with 5 volts to a load and I place a 1 Ohm shunt in my line and my Vshunt is 1,000 my load is only seeing 4.0 volts.

Ron
 

Reloadron

Joined Jan 15, 2015
5,140

nsaspook

Joined Aug 27, 2009
6,949
I should have mentioned that. I also should have included the data sheet so here is the data sheet. You will find it worded:
Analog input voltage AIN0, AIN1, AIN2, AIN3 GND – 0.3 VDD + 0.3 V Under Absolute Maximum Ratings.

Ron
If there's only VDD and GND that's usually a good indicator of unipolar pseudo-differential.

An example of a device (SPI interface) that can do this: The ADS1220 can be used to measure various types of input signal configurations: single-ended, pseudodifferential, and fully-differential signals (which can be either unipolar or bipolar).

http://www.ti.com/lit/ds/symlink/ads1220.pdf
 

Reloadron

Joined Jan 15, 2015
5,140
If there's only VDD and GND that's usually a good indicator of unipolar pseudo-differential.

An example of a device (SPI interface) that can do this: The ADS1220 can be used to measure various types of input signal configurations: single-ended, pseudodifferential, and fully-differential signals (which can be either unipolar or bipolar).

http://www.ti.com/lit/ds/symlink/ads1220.pdf
Pretty cool chip which I never knew existed. Then too, unlike 7 ~ 8 years ago I no longer have a need to really stay on top of the new stuff and actually before I retired I had new engineers right out of school and what was nice was those guys were all over the newest, latest and greatest like white on rice. Hanging out here and still messing with a few circuits at least keeps my mind somewhat functional. :) Thanks for sharing that.

Ron
 

Thread Starter

abc14

Joined Oct 15, 2017
117
If there's only VDD and GND that's usually a good indicator of unipolar pseudo-differential.

An example of a device (SPI interface) that can do this: The ADS1220 can be used to measure various types of input signal configurations: single-ended, pseudodifferential, and fully-differential signals (which can be either unipolar or bipolar).

http://www.ti.com/lit/ds/symlink/ads1220.pdf
Hence ADS1220 is needed to measure negative voltage across the shunt ?
 

Thread Starter

abc14

Joined Oct 15, 2017
117
Among the problems you might have is you are using the Arduino 10 bit ADC and really looking at low level signals. I have no idea how much you do this sort of stuff but I tried a ADS1115 16 Bit 16 Byte 4 Channel I2C IIC Analog-to-Digital Converter along with an Arduino Uno and got really good results. Really slick as you can use I2C to connect. Here is an Arduino example. Among the nice features is programmable Gain so while the default is +/-6.144 volts and dividing 6.144 volts by 32767 yields a scale factor of 0.1875 mV per bit. Roughly 26 times the Arduino native 10 bit. In another PGA setting, you can establish a full scale of +/- 2.048 volts. That provides us a resolution of 0.0635 mV. Some other nice features are programmable address. Like anything on Amazon you need to shop carefully. I got two for under $4.00 each. I send the data to a 4 x 20 LCD. Something else nice is it is a 4 channel unit ADC single ended input yopu can also use it in a differential mode and have 2 differential channels. Very useful when doing shunt measurements.

Using 10 1/4 watt resistors in parallel assuming all are exactly 10 Ohms you would have yourself a 2.5 watt 1.0 Ohm resistor which is 10 * 0.250 watt. Your voltage drop across the shunt is also subtracted from the load. So for example starting with 5 volts to a load and I place a 1 Ohm shunt in my line and my Vshunt is 1,000 my load is only seeing 4.0 volts.

Ron

Hence in my case the voltage drop across shunt is around 775mV and my starting voltage is 4.7V meaning my load is only seeing 4V ?
 

TeeKay6

Joined Apr 20, 2019
572
If there's only VDD and GND that's usually a good indicator of unipolar pseudo-differential.

An example of a device (SPI interface) that can do this: The ADS1220 can be used to measure various types of input signal configurations: single-ended, pseudodifferential, and fully-differential signals (which can be either unipolar or bipolar).

http://www.ti.com/lit/ds/symlink/ads1220.pdf
@nsaspook
I don't see what distinction you are making. The ADS1220 too can only measure between the power supply rails (Vdd to Vss, +/-0.3V). The ADS1220 allows the analog ground to be more negative than the power ground, but it's still a ground and measurements essentially cannot go more negative than that ground. What am I missing?
 

nsaspook

Joined Aug 27, 2009
6,949
@nsaspook
I don't see what distinction you are making. The ADS1220 too can only measure between the power supply rails (Vdd to Vss, +/-0.3V). The ADS1220 allows the analog ground to be more negative than the power ground, but it's still a ground and measurements essentially cannot go more negative than that ground. What am I missing?
You're missing this.

Figure_3_ADS1220.png

The ADS1220 has additional power pins on the analog section. AVSS and AVDD that require symmetrical supplies (i.e. +/- 2.5V) for bipolar operation.


Note that AVSS is -2.5 IRT DGND and that analog inputs can be -0.1 of AVSS in bipolar mode.

IMG_20150902_232256.jpgIMG_20150903_211137.jpg

This was a prototype ADS1220 device for the RPi powered by two 9 volt batteries.
1KokB.gif
2.5V Zeners provide the analog bipolar voltages and a 3.3V LDO regulator provides the digital section voltage.
 
Last edited:

Reloadron

Joined Jan 15, 2015
5,140
Hence in my case the voltage drop across shunt is around 775mV and my starting voltage is 4.7V meaning my load is only seeing 4V ?
That's about it, that's what I'm telling you. This why shunt resistances are kept very low. Take a look at this common everyday 50 amp shunt.

50 Amp Shunt.png

That shunt, across the voltage sense terminals is exactly 0.001 Ohm. The idea is we don't want our shunt dropping a high voltage because whatever we drop across the shunt never makes it to the load. So yes, in your case if you start with 4.7 volts and drop about 0.7 volts your load is seeing 4.0 volts. Years ago people went through great efforts to amplify current shunt outputs but today's A/D converters with a PGA (Programmable Gain Amplifier), make life much easier. They give us the ability to come off a mV source sensor and be able to read them less the need for all sorts of external amplification.

Before I forget see the post above. While that chip requires a +/- power input it can go negative. Another nice feature is it is a 24 bit ADC and like what I mentioned allows programmable gain. There is also good reason to use a differential input. That allows us to get an accurate voltage pickoff from our shunt. That's important. Just using "common" is not a good idea or practice.


Ron
 

TeeKay6

Joined Apr 20, 2019
572
You're missing this.

View attachment 199683

The ADS1220 has additional power pins on the analog section. AVSS and AVDD that require symmetrical supplies (i.e. +/- 2.5V) for bipolar operation.


Note that AVSS is -2.5 IRT DGND and that analog inputs can be -0.1 of AVSS in bipolar mode.

View attachment 199685View attachment 199686

This was a prototype ADS1220 device for the RPi powered by two 9 volt batteries.
View attachment 199688
2.5V Zeners provide the analog bipolar voltages and a 3.3V LDO regulator provides the digital section voltage.
I did not miss what you cite; that was in fact what I did cite. However, I did indeed misread your comment "An example of a device (SPI interface) that can do this..." I apologize for my error in reading. The ADS1220 is indeed a versatile ADC. You also said "If there's only VDD and GND that's usually a good indicator of unipolar pseudo-differential." Yet, T.I. (and other mfrs) sells several unipolar ADC's (using only Vdd & Gnd) that offer fully differential conversions. There is no strict need for bipolar operation in order to support fully differential measurements, although bipolar operation such as that of the ADS1220 certainly eases fully differential measurements of signals having a common-mode voltage that can be negative with respect to ground.
 
Last edited:

Thread Starter

abc14

Joined Oct 15, 2017
117
Interesting readings, stuck a scope across my shunt resistor, I am not seeing similar values of voltage drop across shunt as compared to my Arduino ADC ?


1582551090987.png
 

Reloadron

Joined Jan 15, 2015
5,140
OK and what coupling for your CH1 vertical input are you using? Since the trace looks to be right on the baseline my guess is you are AC coupling the input, should that be the case all you will see is any AC noise riding on the DC level from the shunt and not the DC shunt voltage.

Ron
 
Top