I am currently working on a project for my company with a major portion of it weighing samples using load cells. The hardware side of things is currently figured out, but the amplifier that the load cells are connected to outputs current, not voltage. The current is small, between 4 -20 mA from 0 to 35Kg.
I have been doing research on ways to measure current through the Arduino, and I understand in principle using a shunt resistor to measure, but what I am most confused on specifically is how to connect the resistor to the Arduino so it will actually measure the voltage. Do I connect one end of the resistor to the arduino ground, and then the other end to an analog pin, in parallel? Additionally, will using a shunt resistor be reliable enough, or should I just tell my company that we need to go and get a model that outputs voltage instead for consistency.
Currently it doesn't need to be much more accurate then 100 grams to the Kg as I am only prototyping right now. Just needs to at least show that it is measuring weight. I am just using an UNO R3 right now.
I have personally used this MAX471 module for measuring current and it seemed fairly accurate. Try it out. It also measures voltage well but only when itβs not connected to battery. For battery power, I recommend something like this MAX17048 from Adafruit, I have also used this and it works ok.
I'm not looking for help with the load cells, I have those working and can verify that they do with a multimeter, I am specifically looking for help on connecting a shunt resistor to the arduino and about if that would be accurate enough at an amperage that small
A 4-20 mA current loop is a standard for a lot of industrial sensors. The simple way to convert it to a voltage is to put a resistor in series and measure the voltage across the resistor. There will be an offset due to the lowest current being 4ma. You can either use an op amp to subtract the offset or handle it in software.
If you search on 4-20 ma current loop there is a lot of information.
Holy cow, this is literally exactly what I needed thank you so much.
Been banging my head against a wall for the past day because I could not for the life of me find this
Cheers!
The supply voltage of the Arduino is supposed to be 5V, but if supplied by USB something like 4.5V is also possible. This affects the accuracy.
The inputs of the ATmega328P are provided with protection diodes capable of handling up to 40mA, more than the output of your transmitter will deliver. Not all boards offer this level of protection.
Warning - if you're using more than 5V for the sensor(you didn't give us a link, so we don't know), then you must always consider what will happen if the resistor fails, or is removed from the circuit without first de-energizing the source. Because if you apply more than about 5.5V to the Arduino input, you can be sure it will be destructive, and the damage may not be limited to the single input thus abused, but rather all ADC inputs, or possibly complete Arduino failure, will result.
This can, and should, be easily avoided. The Uno has an internal 1.1V reference voltage, and it would be best to use that to measure the current from the sensor.
This is completely wrong and completely irrelevant. The current from the sensor will not be flowing through the Arduino pins. That current will flow through a resistor and the Arduino pin will measure the voltage drop across that resistor. If current that exceeded 40mA was to flow through the pin, those protection diodes would not save the Arduino from damage. That's not what they are for.
@fynnnord if you use a 50 ohm resistor, the voltage will be between 0.25V and 1.00V which the Arduino can measure against its internal 1.1V reference voltage, giving readings between around 230 and 930. You can then use this value and the map() function to calculate the sensor reading.
I agree with the first bullet point.
I would gave that tutorial page three stars out of five.
It shows the principle, but puts the pin in danger and doesn't use the Uno to it's full potential.
There are plenty of old threads here showing a 51 Ohm (not 250) sense resistor with the use of 1.1volt Aref and additional parts to protect the pin. Try a search by typing 4-20mA in the search box on top of this page.
Leo..
Jim, I think this is a common misunderstanding, confusing the maximum input/ output current capability with the capability of the protection diodes. As you are suggesting these are 2 different things and, so far as I know, the diodes can handle far less current than the output transistors.
The datasheet of the ATmega328 specifically mentions the protection diodes and the Electrical Characteristics doesn't differentiate between current sourced and current injected (unlike other chips such as ATmega4809).
If the resistor fails to short circuit there will be no input current. If the resistor fails to open circuit all current delivered by the transmitter will go into the input, but it will not exceed what the transmitter is willing to output (usually limited to about 25mA in error condition).
This is not general, in this case we're talking about a transmitter, and that behaves as a current source (not a voltage source).
If you mean that the absolute maximum current sourced and the absolute maximum current sinked are both 40mA when in OUTPUT mode, also true.
But you seem to be implying that the protection diodes will somehow prevent more than 40mA from flowing into/out of a pin. I repeat: that's not what they are for. They will not prevent damage in that situation.
The pins, when in INPUT mode, have an impedance of many megaohms. What voltage would be required to force 20 or 25mA through even one megaohm? What is the absolute maximum voltage that the pins can be exposed to?
This has been beaten to death a couple of years ago.
ATmega had at some stage published a mains voltage zero-crossing detector circuit with mains hot phase connected directed to a pin via a high value resistor, which limited current to 1mA. They took it off the internet...
For many years after that, 1mA was considered the limit, which is a false assumption.
A pin should never be exposed to VCC+0.3volt or GND-0.3volt.
External protection parts should be added when that could happen.
Leo..
This adds some safety. The diodes won't conduct below ~100mA sensor current.
It should be used with 1.1volt Aref selected in setup().
That, and the 51 Ohm resistor makes it independent on USB supply variations.
If one tries to raise the voltage on a pin, current starts flowing through the protection diode when it reaches VCC+0.6V. The voltage will not rise further, the current increases. The diode will not limit the current to any value, that's the job of the circuit around it.
The circuit in post #18 will provide an extra layer of safety, useful in case of long cables between transmitter and board that may pick up interference.
The max injected current of 1mA is valid for the ATmega4809 (Nano Every), confusion is caused by Arduino by naming many different boards Nano.
The only one who is confused is you. Your misunderstanding of the datasheet and how a simple digital I/O works suggests you know very little about electronics. I suggest you spend some time learning the basics yourself before you try to help others.