4-20mA controlling

Dear community,

I have a question to controlling a device with a 4-20mA current.

I have found the AD694 which need a 0-10V input and gives out a 4-20mA current

Would it be possible to connect an analog output of the Arduino to an MCP4725 for the 0-5V range, double it up with some OPVs to 0-10V and the connecting it to the AD694?

Or (and I'm pretty sure there is) is there a way better option to controll the 4-20mA with the Arduino (eventually Nano or Mega) ??

Best regards
Wosche

Just to be clear....

Do you want to make a device which takes some sort of measurement, and sinks 4-20mA from a supply provided by an external source?

Or the inverse of this?

ie a transmitter or receiver?

Allan

the Arduino is the transmitter, the other device is the receiver of the control current

You can take the output from the Arduino and switch a transistor connected to a 10v supply with series resistor .
The Arduino is PWM output so you then have a PWM 10v signal - if you drive a smoothing circuit with that then you should get a smooth 0-10v signal .

Just looked at the spec of that chip ... you can have a 0-2v fsd input , so you can use a potential divider from an Arduino o/p and a smoothing circuit .

hammy:
You can take the output from the Arduino and switch a transistor connected to a 10v supply with series resistor .
The Arduino is PWM output so you then have a PWM 10v signal - if you drive a smoothing circuit with that then you should get a smooth 0-10v signal .

But, consider that there is the issue of ripple vs responsiveness. The more you reduce ripple, the more sluggish it will be when changing voltage.

One way to increase this ratio is to use a higher PWM frequency. Another is to use a buffer. And yet another is to use an active filter.

This is textbook stuff.

Circuit enclosed.

Allan

420sink.pdf (19.4 KB)

allanhurst:
This is textbook stuff.

Circuit enclosed.

Allan

That's good for 0-20mA. But the OP requested 4-20mA. But, you could get away with that by not using the full DAC range [I'm including the PWM technique under that *DAC umbrella*]. But, if you want the full precision available:


The above is more concepuized-- basically two current sinks, one at a constant 4mA, and the other a Voltage to Current translator [0-5V to 0-16mA]. The combination creates a 4 to 20mA transmitter, with a linear voltage to current transfer. This one is shown with a simple PWM low-pass filter.


And, this one is a more practical diagram. The Op-Amps can be any common mode to ground, single supply device that can handle whatever voltage is in use, such as the LM324 or the LM358. I forgot to show the supply lines on the op-amps. Tie V- to ground, and V+ to 30V or whatever voltage is the VHigh supply you choose.

The transistors can be 2N3904, or one with a higher max CE voltage, like: MPS06

Typically, a 4-20mA transmitter has a fairly large voltage range going as high as 36V, with 12 to 30V typical. Basically, this voltage needs to be high enough to allow 20mA to flow in the loop--a level that is determined by the total expected maximum resistance in the current loop. BUT, check to see if the device you intend to drive has a max voltage rating, and, at least, comply with that.

For greater precision and probably better response, I suggest using a serial DAC, like the following:

The same page has links to Arduino sample code.

The 10k + 10k voltage divider that follows the DAC is there to reduce the top voltage so there is a greater voltage span in the current loop. Also, it keeps the input voltage within the input range.

And, you will need to incorporate some variable resistors in there, to calibrate the thing to exactly 4mA at 0V in and 20mA at 2.5V in.

Also wise to use stable resistors [e.g. 1% metal film]. And quality trim pots. And, maybe some sort of protection circuitry on the 4-20mA output.

And, if this will be driving some sort of expensive or hard to replace device, then do this at your own risk!

Or, purchase something like this: https://www.ebay.com/itm/Arduino-4-20mA-Current-Loop-Transmitter-XTR116U-I2C-Interface-industry-standard/173326373205?hash=item285b0e9155%3Ag%3AL4IAAOSwwcdbALKV&_sacat=0&_nkw=arduino+shield+4-20ma+transmitter&_from=R40&rt=nc&_trksid=m570.l1313

But, good luck getting it to work.

Then there's this: https://ncd.io/interfacing-isolated-4-20ma-current-loop-transmitter-arduino/

Why use two opamps and two drive transistors.
A third resistor between 5volt and the +input of the opamp can also add that 4mA idle current.

An LM324 is not a R2R opamp, but R2R is not needed in Allan's diagram (100ohm emitter R).
Leo..

Wawa:
Why use two opamps and two drive transistors.
A third resistor between 5volt and the +input of the opamp can also add that 4mA idle current.

An LM324 is not a R2R opamp, but R2R is not needed in Allan's diagram (100ohm emitter R).
Leo..

Probably. Analog is not my strong suit-- but I don't see any other valid offerings, so I stepped in :wink:

Allan's circuit.
Change R1 to 37.5k, and add 150k between 5volt and opamp +input.
Leo..

Or just drive it with 1-5v to get 4-20mA.

ie use map() to get numbers between 51 and 255 for the analogWrite value.
That'll give you a resolution of about 0.5% as against 0.4% using the full range. A bit worse, but simple.
If this isn't good enough you'll have to use a suitable external DAC.

And ( my mistake) the NPN shown should be eg a BC337 etc, NOT a BC327 which is PNP.

Allan

ps In any case the PWM resolution error is swamped by others :

unless you spend out for super accurate resistors it'll need calibrating.

With typical 1% ones you can get up to 3% error.

And if driven from the arduino's +5 that'll have an error of a couple of percent as well - much worse if using USB power. That's the arduino error - not my circuit, which doesn't care.

Leo's mod DOES make it sensitive to the +5 error, as do ReverseEMF's suggestions.

The opamp's errors are much smaller.

So I recommend calibration . eg make the 100 ohm 75R with a 47R adjustable preset in series.

I haven't bothered with temperature coefficients here - that's another ballgame! How accurate do you need to be?

Allan

allanhurst:
Leo's mod DOES make it sensitive to the +5 error, as do ReverseEMF's suggestions.

Are you saying that 4mA offset with a fixed resistor is different from 4mA generated from PWM.
Both using the same Arduino VCC.
Please explain.
Leo..

Wawa:
Why use two opamps and two drive transistors.
A third resistor between 5volt and the +input of the opamp can also add that 4mA idle current.

An LM324 is not a R2R opamp, but R2R is not needed in Allan's diagram (100ohm emitter R).

OK, I played around with this, using 1 OpAmp and resistors as you suggested...
Have you tried the math on that?!? Horrendous--unless I'm missing something. And calibration is a nightmare, because adjusting one side, moves the other side. In other words, adjust it to 4mA when the input is at 0V, then change the input to 5V and adjust for 20mA, and the current goes to 5mA when the input is at 0V, etc. I even tried anticipatory overshoot, and it was still difficult! I suppose if I finished the math. I reached this, and gave up:


I would call that impractical!

In fact, one of my first jobs [back in the late 80's] was at the Jensen Filtration Plant in Sylmar, CA. And most of the sensors were 4-20mA. Occasionally lightening would knock one or more of them out, and recalibrating them after repairing them was a b***h, for this very reason!

My two OpAmp circuit can be easily calibrated, because there is no interaction when adjusting the extremes.

Wawa:
Are you saying that 4mA offset with a fixed resistor is different from 4mA generated from PWM.
Both using the same Arduino VCC.
Please explain.

My circuit is vulnerable to tolerance variations in the Arduino 5V regulator (in other words, each Arduino will have a slightly different "5V" actual value. e.g. one might be 5.04V, another 4.98V, etc). Also, like allenhurst said, resistor tolerance is also a source of error. That's why I suggested calibration.

The Arduino regulator is fairly stable if driven by the Raw Power input, but if more precision is needed, then use the external DAC, and run it with a precision regulator--one that can be adjusted to exactly 5.00...V [limited by error modes in the DAC] and a regulator that will hold that voltage over a temperature range expected in "the field".

Allenhurst described how to add calibration trimmers. But, I wouldn't do that on the emitter resistor -- it will heat up, slightly, which may skew the resistance, and thus, the output current. Also, thermal expansion and contraction could nudge the wiper on the trimmer, knocking it out of calibration.

Instead, I would place calibration trimmers on the 10k resistors that go to ground: 9k + a 2k trimmer, or something like that.

Are you saying that 4mA offset with a fixed resistor is different from 4mA generated from PWM.
Both using the same Arduino VCC.
Please explain.
Leo..

No - just saying that the simple opamp circuit does not contribute to this error.

edit - because of the high PSRR of the opamp /edit

And we still don't know what error is tolerable in the OP's application - any suggestions ,Wosche?

Allan

So sorry to the late response.

First of all, thanks to you all for the discussion and the tips :slight_smile: Hoping to be able to contribute the same to others in the forum :slight_smile:

I don't supply the Arduino via USB, just because i would have to adjust the output voltage to minimize the error it would make.

The idea with the simple circuit and adjusting my output to 1-5V seems to be the easiest way of getting what I want.
As far as I have seen the error would be up to 3% right? I have the opportunity to geht the restistors with quite an accurat value, although I think i would try to calibrate it

Hi Wosche..

yeah -that's the way I'd go. Simple and probably good enough. Cal for better accuracy.

If you decide to calibrate you don't need to buy more accurate resistors - the cal process deals with this.

ReverseEMF:

Allenhurst described how to add calibration trimmers. But, I wouldn't do that on the emitter resistor -- it will heat up, slightly, which may skew the resistance, and thus, the output current. Also, thermal expansion and contraction could nudge the wiper on the trimmer, knocking it out of calibration.

Maybe. Even at 20mA, the resistor only dissipates 40mW total and the pot at 25 ohms setting 10mW - not much. But adjusting the input divider is also perfectly viable. There's a hundred ways to skin this cat.

Allan

If I do the 4-20mA conversion, I will share it here.
It would be quite a helpful thread, because I didn't find anything similar helpful here in the forum :slight_smile:

Thank to all :slight_smile:

You're not the first to have problems here - but it's not that hard.

The other end - the 'receiver' is a bit more complex, but not too bad.

This stuff has been around since the 70's( or before?) and is a standard throughout many industries.

Allan