How to use audrino to generate 4 - 20 mA using additional 12V Dc supply

Hi Everyone,

I am a student and as part of my studies I have to work with Festo VPPE valves.

I have figured out that it needs analogue input set-point values to vary the pressure output.

Namely, (0..10V or 4 ... 20mA) will correspond to (0...2 bar ).

So i need to be able to vary the voltage or current to instruct the valve to maintain pressure at a specific value. I have read many post regarding 4-20mA output but didn't get a good idea, Just understood it requires mosfets and transistors.

I have an Audrino Mega 2560.

Didn't you say 0-10v too ?

use a transistor switch connected to 10v and an RC smooothing network to get a steady 0-10v signal from a PWM output.

Better use an OpAmp circuit for 0-10V.
PWM output --> RC filter --> 2x gain OpAmp (powered by the 12V source) will give a much cleaner signal (less ripple) with low output impedance.
See this StackExchange answer for circuit diagram.