# PID Control on Micro with PWM

I am trying to use a micro to control a pump and I intend to use a PID controller for this. Here is what I have
1. I have a target set point pressure (units PSI, bar or mmHg)
2. From the micro, I drive the pump with a pwm (duty cycle , units %) 3. The micro reads an AD voltage signal which is proportional to the pressure (units Volts)
INPUT ---+--Err->-(SYSTEM)-----+--------OUTPUT | | | | | | ---------------------------------
So my input is 1 (units pressure), which is somehow translated to 2. (units % duty cycle), the output is a pressure which is read as a voltage.
My confusion is how I resolve all these different units?
I am sure this is commonplace - how is it done?
Thanks!! Liam
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Liam wrote:

Use units in the equations you write. The units of your pressure transducer reading is [PSI (or bar or mmHg)/volt]. Presumably, your input, also a pressure (else, subtraction wouldn't be legitimate) uses the same unit.
What translated 1 to 2? If there's a scaling gain somewhere, that has to be non-dimensional.
Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

I think I can convert the volts to a corresponding pressure. I can then calculate the Error = (Input - Output) ; the units will be pressure units (PSI or equiv).
From this error value, how do I know at what duty cycle I have to drive the system? I have a pressure but I need a % duty cycle for the PWM?
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Liam wrote:

...

What does the PWM output do? Control the speed of a pump? Pressure some function of speed? Matlab notwithstanding, the world is made out of things, not numbers.
Jerry
--
Engineering is the art of making what you want from things you can get.
�����������������������������������������������������������������������
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
On Fri, 14 Mar 2008 01:35:57 -0700, Liam wrote:

Just knowing the error value doesn't mean that you do know how to drive the pump. If the immediate value of the error were enough information then you'd just need proportional control, or perhaps some nonlinear but memoryless mapping between error and duty cycle.
At any rate, for the purposes of keeping your dimensions straight your controller gain would need to be in (duty cycle)/(psi). In the real world your controller gains are going to be buried deeper -- in an analog system they'd be volts/volt for proportional, volts/volt-second for integral, and volts/(volts/second) for derivative. This would be preceded by a sensor with a gain whose dimensions are in volts/PSI, followed by a driver with a gain in duty cycle/volt, then probably a filter, then a pump whose gain involves PSI in the numerator and volts in the denominator, and probably some interesting time dependencies.
I'm with Peter -- write the differential equations. If you have trouble, check back here & someone will probably help.
--
Tim Wescott
Control systems and communications consulting
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>

Jerry is just trying to get you to think about the problem. I am more blunt and direct.
This is easy stuff. I see only one problem. The input and the feed back is pressure. The gain of the controller is %Control Output per pressure unit. Easy so far. Here is the problem. Does the pump pressure integrate? A fixed displacement pump pumping fluid in a fixed space without any leakage will integrate the pressure. Otherwise the pressure will bleed off a some rate. Usually it is proportional to the square root of the pressure drop across the orifice or valve. The pump gain is pressure rate per % control output. If the object you are pumping the fluid into doesn't leak it will integrate the rate of change in pressure. If the object leaks the pressure rate will have a negative term that is proportional to the square root of the pressure drop across the valve or orifice. You haven't told us about what happens to the fluid. Don't you think it is important that we know if the pressure will decay or not?
In any case the (system) will have a steady state pressure/control output if the system leaks or integrated (pressure/control output) if it doesn't leak. Note, most things leak at least a little.
Now heed Jerry's advice and write the ( differential ) equations. I provided a lot of good information ( hints ).

All the time. If we told you the answer would you understand? How can you when you don't understand the problem? It is best if you struggle though this at least until you understand the problem. You didn't pick an easy one to start with.
Peter Nachtwey