Go Down

Topic: 4-20mA controlling (Read 2925 times) previous topic - next topic

Wosche

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

allanhurst

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

Wosche

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

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 .

hammy

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 .

ReverseEMF

#5
Jul 14, 2018, 12:18 am Last Edit: Jul 14, 2018, 12:21 am by ReverseEMF
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.
"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

allanhurst

This is textbook stuff.

Circuit enclosed.

Allan

ReverseEMF

#7
Jul 14, 2018, 07:56 am Last Edit: Jul 14, 2018, 09:18 am by ReverseEMF
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:

https://www.adafruit.com/product/935

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/
"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

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..

ReverseEMF

#9
Jul 14, 2018, 08:56 am Last Edit: Jul 14, 2018, 09:15 am by ReverseEMF
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 ;)
"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

Wawa

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

allanhurst

#11
Jul 14, 2018, 11:19 am Last Edit: Jul 14, 2018, 01:27 pm by allanhurst
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


Wawa

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..

ReverseEMF

#13
Jul 14, 2018, 04:52 pm Last Edit: Jul 14, 2018, 05:26 pm by ReverseEMF
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.
"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

ReverseEMF

#14
Jul 14, 2018, 05:06 pm Last Edit: Jul 14, 2018, 05:15 pm by ReverseEMF
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.
"It's a big galaxy, Mr. Scott"

Please DON'T Private Message to me, what should be part of the Public Conversation -- especially if it's to correct a mistake, or contradict a statement!  Let it ALL hang out!!

Go Up