Driving proportional valve with pressure transducer feedback by PID

Hi.
In my new project I need to drive a proportional valve 24VDC with a pressure transducer feedback regulated by a PID algorithm.
The pressure must be maintened at a specific value (set point) given by user in a range between 0bar and 12bar. I think to use a proportional valve to drive the pressure and a pressure transducer to read pressure value. I think to use a Proportional-Integrative-Derivative (PID) algorithm.

I would to use this devices:

Ok. My questions:

  • I need to drive proportional valve via PWM with a range of frequencies between 600 and 900 Hz, how I can achieve it with Arduino Mega 2560?
  • I need to write a PID routine with a set point and a value to drive the PID routine...

Could someone help me to implement a PWM interrupt driven pin and a PID algorithm to drive it? I need to give a Set Point value to the PID routine and with a pressure transducer value drive accordingly the output pin to move the proportional valve to reach the set point pressure.

Thanks to all.

This kind of question generally gets a 'do it yourself' response, but I would ask -

Is using a separate valve and sensor possible for your application?
The valve has quite a slow response time, around 25ms, depending on your time constant you could vastly overshoot the target pressure before it reacts.

What happens if the valve stays fully open, will damage occur? This could happen by accident during development of the system.

There are probably alternatives which already exist, voltage controlled pressure regulators -
http://www.controlair.com/index.php/ip-ep-pi-transducers/t500-electropneumatic-transducer-ip-ep

Assuming it's a key part of the project -
Given the flow rate and the connected volume, what will be rate of change of pressure on the output?

(Driving PWM outputs at 5V is easy, but you would need a power MOSFET board to drive the 24V,1A to actuate the valve)

pressure is relative to flow

CommonRodent:
Is using a separate valve and sensor possible for your application?

Yes, it is possible. My links are only for demonstration purpose. I am searching for cheap proportional valve....

CommonRodent:
The valve has quite a slow response time, around 25ms, depending on your time constant you could vastly overshoot the target pressure before it reacts.

What happens if the valve stays fully open, will damage occur? This could happen by accident during development of the system.

If Reaction time is 25ms, it is really good for my project.
If the valve stays fully open there is no problem and will not damage anything.

CommonRodent:
There are probably alternatives which already exist, voltage controlled pressure regulators -
http://www.controlair.com/index.php/ip-ep-pi-transducers/t500-electropneumatic-transducer-ip-ep

Assuming it's a key part of the project -
Given the flow rate and the connected volume, what will be rate of change of pressure on the output?

(Driving PWM outputs at 5V is easy, but you would need a power MOSFET board to drive the 24V,1A to actuate the valve)

The output can change at a 0.1bar resolution.

I can drive the valve via a IRL540 Mosfet....

this is what I would to achieve:

(1) proportiona 24V valve
(2) pressure transducer

Greensprings:
pressure is relative to flow

depends on the medium. air will increase in volume as the square of the increase in pressure.
a change in pressure will cause an increase in flow if there is no control action.

if you have a hard time getting a stable pid loop, try a simple fuzzy control.

I used 3 ranges in a project.
if the reading was more than 50% away from the set point, move fast
if it was between 50 and 20% move slow
if it was withing 20% move very slow.

pretty simple to impliment in an Arduino.

The picture in your last post didn't load for me?

There is an Arduino library for PID which should make things easier
http://playground.arduino.cc/Code/PIDLibrary

(Though as dave-in-nj said it might be more than you need if it's just a case of approaching the target pressure without overshooting).

Your control loop will be roughly:
read pressure sensor
myPID.Compute();
update pwm setting

But you might need to change the PWM frequency. I don't have your board but this might have it
http://forum.arduino.cc/index.php?topic=72092.0
(One of the pins might be configured to 980Hz as a default, but that's slightly outside your range)

O, thanks.
PID library is really helpful and very good solution.
Can I use OSC1A to drive a specific output pin to generate my own PWM?