Main Site Documentation

Measuring current


#1

I have the ACS712 module to measure current.

If I execute the Read_DC_Current() method with nothing attached I get .33866 as a value. Shouldn’t this be zero for zero current? Does this indicate a faulty chip?

John


#2

Check this thread

https://www.ghielectronics.com/community/forum/topic?id=11110


#3

I’ve read that thread, and a few that it links to but I’m still not sure what to do.

I want to hook this up to a pressure transducer that outputs a current proportional to the pressure it is measuring, which I need to convert into PSI. I’m not sure where to start if I can’t get a zero reading when there is no current.


#4

Hi there,

You don’t need this device to read current from 4-20mA sensors. I am assuming you mean time type of sensor?

All you need is an ADC input and all of the modules from GHI appear to have them. Which processor module are you using?

Simply connect a 0.1% 100 ohm resistor (use the higher precision 0.1% to get accuracy) between the ADC input and ground.

Connect the + connection of the sensor to +12 or +24V and the - of the sensor to the ADC input. You will now get a 0.4 to 2.0 volt reading for the 4-20mA output of the sensor.

0.4V being 0 PSI and 2.0 volts being the max PSI of your sensor.

Far more accurate than the ACS712 will give you as they tend to be high current so your resolution will be so bad with this.

By the way, what is the PSI range of your sensor?


#5

Dave,

I gave up on measuring current and purchased a transducer that outputs voltage, but I still have the same problem.

I tried to measure voltage using a breakout module, but it is giving me a reading even when nothing is connected.

For instance, the following code:

Gadgeteer.Interfaces.AnalogInput ai = breakout.SetupAnalogInput(GT.Socket.Pin.Five);
for (int i = 1; i < 10; i++)
{
Debug.Print("voltage " + GetVoltage(ai));
Thread.Sleep(1000);
}

produced the following output:

voltage 0.17419354838709677
voltage 0.19999999999999998
voltage 0.16451612903225804
voltage 0.17419354838709677
voltage 0.16451612903225804
voltage 0.14193548387096774
voltage 0.17741935483870966
voltage 0.16774193548387098

Shouldn’t the voltage be zero if nothing is connected?


#6

(Note I am an electronics n00b):

I wonder if a pull down resister would help settle that.


#7

@ jhoge123 - Can you sent some more information about the sensor you use? A link to a datasheet or brand/model?


#8

Unless you have the pin explicitly wired to GND or 3v3, there’s no reason it will read “exactly” a known value. This is called a “floating” input, and ADC’s by their nature will show some level of voltage - you’ll never get pure noise-less signal.

The best way to “check” the value is to quickly jumper the pin to GND and see the value returned; that should show a 0 reading. Then jumper it to 3v3, and you should see a full-scale value returned.


#9

A pull down resistor will do exactly that - pull it down to GND. For an analog signal, this is a baaaad thing to do since you will then no longer be able to interpret the value as just the sensor’s output.

In digital terms, a pull-down or pull-up will essentially allow you to be able to guarantee the state of the pin when the sensor/device is not driving a signal. When that sensor/device drives the signal state to the “other” state, it will over-power that default state and will show as the real state.


#10

Thanks for the clarification. I was thinking the effect would be the same regardless of signal type.


#11

The effect is, sort of - you pull up or down the signal to the vcc or gnd when there’s nothing being driven there. But the consequence is that it can change the voltage you read, when the whole reason you’re using the ADC is to read a value from an analog signal, that by definition is not at the high or low point like a digital signal is. Are you reading a zero because the signal from the sensor is reporting 0 or it’s not powered up?


#12

Well in this case he’s getting 0.14 to 0.19 when nothing is attached. So I was thinking that the pull down would help to make a “trustable” zero reading.

I’ve been bumping into quasi-similar issues with my Arduino Mini and reading battery voltage on an analog pin. With the batt only powering the Micro the voltage readings fluctuated similarly. I was thinking to try a small cap, as it might help to smooth out the readings in my case.


#13

a cap and a resistor will have very different effects on this.

The reason this reads like that is because nothing is connected and the signal is amplified to then be read by the ADC. Connect the actual sensor and it’ll read rock-solid* You should not worry about the state where an analog input floats

  • where rock solid means somewhere within the tolerances of all the parts involved. Over-sample and average is one way to get stability to the signal that nearly everyone will implement.

#14

With a 4-20mA sensor and the load resistor acting a bit like a pull down, you can use this to detect a non connected sensor.

I have a system with 14 pressure sensors connected to a number of 16 bit ADC’s and any reading below 0.3 volts is considered a non-connected sensor (0 psi is 0.4 volts) and displayed as such.

With a voltage sensor it is a little harder to check for this as 0V could be no pressure.

An issue with an ADC input and sensor output no reading as it should is often a miss-match in the loads. You need to check the load of the sensor and what the load of the ADC input is.

If you can go back to a 4-20mA sensor, I would suggest you do this. It will save you a lot of headache as it will work. Just make sure your resistor is 0.1% or better accuracy.