Go Down

Topic: arduino 5V digital pwm to 4 - 20mA Output ? (Read 5777 times) previous topic - next topic

e-rusty

Wish to make a small interface to convert 0-5V digital PWM out of arduino to a 4-20mA current output...
Thinking about to use a small R-C- Filter and than connecting to an Voltage-to-Current Converter like XTR110 (Texas Instruments).
Do You think its possible to use the arduino out >> RC Filter >>XTR110 in >> 4-20mA current output ? What could be the right values for the RC-Filter parts? I´m not an electronics Pro... is there a big mistake within this concept?   :-?
Thanks

peter247

Have a look at adjustable voltage regulators.
Some you can set the Current or voltage using Variable resistor.
http://peter224722.blogspot.com

e-rusty

up to now I found some information for 0-10V DC out, perhaps its a similar way how to get 0-5V DC and then feed it to XTR110  ;)

"saw a previous diagram on here using a BC183 to get a 10V output which was smoothed with a RC. This circuit had the Arduino PWM port connected to the Base of the BC183 with a 4k7 resistor in in series. The emitter was connected to Gnd and the Collector connected to a 12v+ supply with a 1k Resister in series. A 680 resistor and 1 uf capacitor in series was used to smooth the output from the collector....any "small signal NPN" transistor should do with a gain of around the 100 to 300 mark. The 2N2222 has a high current rating and so a small gain but the BC547 should work fine."

found another way to get 0-5V output (example for a motor controller) here:
"you may not need an op-amp to buffer the analog voltage after low pass filtering.To create a low pass filter wire a resistor from the Arduino PWM output pin to the positive side of a electrolytic capacitor. Wire the the negative lead of the capacitor to ground. Run a wire from the junction of the resistor/cap to your analog input terminal of your motor controller. Also run a ground wire from the Arduino gnd pin to a ground terminal on your controller. Set your motor controller to accept a 0-5vdc analog command signal. As to the values to use for the resistor and cap, it would help if you had a scope to see how much ripple remains after the filter. I've had pretty good luck using a 5k ohm resistor and a 10mfd cap.
You can kind of measure the effectiveness of the low pass filter with just a DVM meter. First verify you get 0 vdc with the PWM command at 0 counts and 5vdc with the PWM command at 255 counts. While still at 255 counts, switch the meter to read AC volts and the resulting AC voltage reading is a reflection of the amount of ripple voltage."

Do You think a low pass filter like that would be a solution to feed the signal in a xtr110 or would the remaining ripple disturb the xtr110?

hoping to get about 20mA out with 255 pwm counts and adjust 0mA with  0 counts... :)

Thanks

Grumpy_Mike

I am not sure what you want to do with this, sorry if you already know but....
This is a current loop control. So what you do is to set what current you want to supply and the controller will adjust the output voltage until that much current flows through the load. Of course it can only up the voltage to as high as the input supply will permit, in this case the limit is 40V.

You can supply the voltage reference from the PWM output which will give you a variable constant current source, like you have found out. Any ripple on the input voltage caused by lack of smoothing of the PWM output will result in a corresponding current ripple in the load. The filter characteristics will control the amount of ripple you have and the speed with which you can change the current. It's a trade off the faster you want to change it the more ripple you have to put up with or the more sections you have to put in the smoothing (low pass) filter.

So far so good. However what are you trying to drive with this? If it is an LED then it is the wrong way of going about the job.

e-rusty

Thank You for posting! Sorry, I didn´t explane:  4-20mA signals is an regularly found standard in industrial automation, for regulation... So a lot of industrial parts like found in ebay could be regulated with 4-20mA signal ;)  I would like to feed the signal to a pneumatic regulator, something like that: http://www.end.de/uploads/tx_datasheets/kat-pg01.pdf (don´t know that company, its a very similar part) So it remains a small problem to transform the 5V PWM out from arduino into a 4-20mA "DC out" signal...
would like to do this with some easy parts, without using DACs... Perhaps someone has tried circuit ideas from above and can give some hints for good parts / values / or a small schematic...  I´m shure it´s possible  ::)
thanks

Grumpy_Mike

Ok that's fine it sounds like you know what you are doing and it is the right way to go about it.

As I said before the only problem is the design of the smoothing filter. Most I have seen are just a simple RC filter but to get a small amount of ripple with a fast response you need to go for a higher order filter, say sixth order. This makes the filter more complex and at that stage you are better going for an external D/A instead.

Mike Rice

I was an industrial tech in my previous life and am quite familiar with current loop signals and pneumatic actuators. You can do this with just an Arduino, 1 transistor, 2 resistors and a cap.

The response of those actuators is so slow that you could run it without filtering (I once did just that in a pinch). But the flapper valve would wear out pretty quick that way, so filtering is wise.

The Arduino pwm is 490 hz if I remember correctly (double check that before you start soldering), so an rc filter with a 20 mSec time constant would work nicely... if you know the time constant of your valve you could use that instead.

You will probably need more than 5 volts to push 20 mA through the flapper coil + feedback resistor. Check the DC resistance of the coil to verify. Lets assume you will be using 12 volts.

Connect the positive supply to the positive terminal of the valve. Connect the other terminal to the collector of a suitable NPN transistor. Connect a 250 ohm 1/4 watt feedback resistor from the transistor emitter to ground. Connect the output of the rc filter to the transistor base, and connect the emitter of the transistor to an analog input pin of the Arduino, through a 680 ohm resistor. (The 680 ohm resistor will limit the current into the Arduino in case something fails).

Now the voltage across the feedback resistor will range from 1 volt at 4 mA, up to 5 volts at 20 mA.

Now go grab the PID library from the Playground.

RuggedCircuits

Won't this run into trouble at 5V (20mA) as that implies the base will have to be higher? I guess you could always lower the 250ohm resistor value.

I think 1k and 22uF would be a good starting point for the RC network.

Mike Rice


e-rusty

Tank You!  for the postings! trying to get the text information into schematics, I will upload  and hope someone will find my mistakes  ::)
Which would be the best solution for transforming arduino 5v digital pwm to analog 0-5V output or directly to 4-20mA output? Is there a better filtering circuit out there?
Thanks!
---

---

----

-----

----

Grumpy_Mike

Schematic 1 - Won't work you have a transistor as a switch after the filter so you will never get any output but 0 or 12V

Schematic 2 - Yes simple RC filter

Schematic 3 - No. op amp has no feedback so you get either -5 or +5 from this.

Schematic 4 - Looks like the data sheet application circuit, I should go with that.

Schematic 5 - You are putting the arduino in the current monitoring loop so you have software regularly being updated to do to keep it controlled. There is a potential to get more than 5V to the analogue input pin so put a diode between the input pin and the +5v to catch that chance.

Go Up