Manipulating 0-5V Pressure Regulator via PWM

Hey! I'm working on a project involving this pressure regulator and a MEGA 2560. I'm fairly new to both electronics and Arduino and am looking for some advice regarding PWM. Correct me if I'm wrong but I believe that it is possible to control the regulator by giving it a reference voltage in the range of 0-5. I used a simple test sketch similar to the arduino blinking LED tutorial just to see the results and nothing happened. Basically, I have a couple questions I can't seem to find clear answers for. How can I change the value that the analogueWrite function outputs? Will I need to purchase some sort of DAC or MOSFET to amplify my output? Because I'm reading that my Arduino is only capable of 3.3V out.

Thanks!

EDIT: I should clarify that the reason I want to output a voltage in a range is due to the fact that the amount of pressure can be controlled by the value passed to the regulator.

Well... That datasheet is confusing!

I'm pretty sure it doesn't use PWM.

From what I can tell, there is an analog output (on some models?). If you are getting 0-5V you can read that on an Arduino analog input, scaled 0-1023, which you can then scale to pressure.

Then, you can switch the valve on/off from an Arduino digital output. I didn't see the 5V current requirement, but since it's "electronic" it probably just needs a low-current 5V signal so you shouldn't need a MOSFET or anything.

So, you can test those two functions separately. See if you can read "something" proportional to pressure with analogRead(), and see if you can turn the valve on & off with digital(Write).

Then, it's a matter of converting the analog reading to pressure (the map() function should work), and writing an if-statement (or two) to open/close the valve when you are above or below the target pressure.

After you get it basically working... A control system like this usually has some hysteresis to keep the thing from switching on & off several times per minute (or several times per second). For example, If you want to pressurize a tank to 100 PSI, you'd turn the compressor (or valve) on at 99 PSI, then leave it on unit you get to 101 PSI. Then you wouldn't turn it on again until the pressure drops back to 99.

Assuming you have the regulator version that will control pressure with a 0 to 5 Vdc input:

You need to use the analog output command. Note: even though the command is "analogoutput" it does not generate a real analog output. It generates a Pulse wave of about 500 Hz. This output is ON (high) an amount of time proportional to the analog output value.

for example, for a 4V output the PWM will be high 80% of the time. And because in this case "high" = 5V, the AVERAGE output voltage is 0.8 * 5 = 4V

From the regulator data sheet, they note the power to the valve must not have any ripple voltage, so I will assume the control input has a similar sensitivity. So the output pulses must be averaged by some circuitry.

Because we don't know how much ripple the valve will accept on the signal I would suggest a 5k resistor to a 10 µF cap. Might be a little slow but will get you started. These values are not critical so use what you have.

Also we don't know the input impedance of the valve signal so we may find the 5K is too large but is a place to start.

Be aware the Arduino outputs do not go to 5V but some value slightly lower. For this reason you may not be able to reach the max pressure of the valve.

The link you posted refers to several different parts, what is the exact full part number of your regulator?

Apologies for the late response, I will not have access to the lab/my school's equipment until next Monday. The specific model of pressure regulator we are using is the SMC ITV2050-312L4. Unfortunately, I have been unable to find any specific or other documentation at all for this series of regulators. I am not trying to control the pressure of a sealed environment, so I am not interested in the regulator's output, my current goal is simply to operate it at different intervals. Your explanation of PWM is extremely helpful, JohnRob, in understanding how to control the output voltage of the board.

Thank you all for the help so far.