PID control for H-Bridge

Hello Community,

I have a question regarding a process control and I am searching for a suitable strategy.

Description:

I have a hydarlic system which I want to control. Sensor inputs are pressure and flow rate. Controlled part is a valve. To control the valve I can apply either positive or negative voltage to the motor of the valve. (positivce opens, negative closes) The circuit to perfom this is already in place. I have to pull one pin high to open and another one high to close it (H-Bridge circuit).

The needs about 15 seconds to reach full open position (from fully closed). At high pressure rates, the open/close timing needed is in the range of tenths of milliseconds to reach.

Desired output:

The “setpoint” of the system is the flowrate. I set the rate to a certain value and the valve should act accordingly (either open or close) to reach the setpoint within a certain range/hysterisis (+/- x).

Problem:

I’m now searchingfor different suitable strategies to solve this problem.

Bang-Bang controller --> Due to the time lag in the system (flow rate is not responding instantly I always over/undershoot)

PID controller --> I thought of a PID controller and correct tuning for the system. My problem here is that I do really know how to approach this. A PID controller gives an “analog” ouput which I could translate somehow to a very large PWM signal. But the system needs to set two different pins. If the actual flowrate is below the setpoint the valve has to open --> open_PIN HIGH) if the rate is above the close_Pin has to set HIGH.

The problem with the two Pins is solved already, as I translate OPEN (1) or CLOSE (0) to controll the H-Bridge already.

I would need some kind of a PID controller that would give me a ouput like

OPEN for x sec

CLOSE for x sec

if in a certain range do nothing

The time lag in the system and the large opening and closing times worry me.

Does anyone have a suitable strategy and perhaps some samples or links where to dive deeper?

Nils

The time lag is your biggest problem, near impossible to avoid overshooting. That's why 2 (bang bang) or 3 state regulators (open-stay-close) are used in most temperature control systems.

Better results are achievable with some look ahead, if you know how long it will take to open/close the valve and when the setpoint will be reached. A state regulator is the best solution, but it requires so much expertise that it's out of reach.

Eventually you can extrapolate the current state and adjust the valve before overshooting occurs.

The needs about 15 seconds to reach full open position (from fully closed). At high pressure rates, the open/close timing needed is in the range of tenths of milliseconds to reach.

Does the value operate in an intermediate position between open and closed? That is, can you partially open the valve and hold it at that position to maintain a flow rate? From the previous description it sounds as if the valve needs to be either open or closed.

Is the pressure a constant at the time you are trying to open the valve to achieve a flow rate? How does the pressure vary? Over what time period? What makes the pressure change?

How long is the flow rate to be maintained?

cattledog:
Does the value operate in an intermediate position between open and closed? That is, can you partially open the valve and hold it at that position to maintain a flow rate? From the previous description it sounds as if the valve needs to be either open or closed.

Is the pressure a constant at the time you are trying to open the valve to achieve a flow rate? How does the pressure vary? Over what time period? What makes the pressure change?

How long is the flow rate to be maintained?

The valve maintains its position when no voltage is applied.The pressure drops when valve is closed and rises when opened. Pressure changes are due to the fact that it is a kind of a mobile system and the pump is not that stable (especially with high pressure) - also its necessary to vary the flow rate quite often - so the setpoint changes quite a few times. The flow rate has to be stable over a long period of time (hours).

DrDiettrich:
The time lag is your biggest problem, near impossible to avoid overshooting. That's why 2 (bang bang) or 3 state regulators (open-stay-close) are used in most temperature control systems.

Better results are achievable with some look ahead, if you know how long it will take to open/close the valve and when the setpoint will be reached. A state regulator is the best solution, but it requires so much expertise that it's out of reach.

Eventually you can extrapolate the current state and adjust the valve before overshooting occurs.

A little overshoot is acceptable. But with only ON-OFF control based on the setpoint (incl. some hysteresis) i get serious oscillations. I have to get the hysteresis to wide that it does not make sense anymore.

So you mean to extrapolate the function over time and try to predict the change in opening or closing times? This was what I wanted to avoid. What exactly do you mean by "state regulator"?

The valve maintains its position when no voltage is applied.The pressure drops when valve is closed and rises when opened. Pressure changes are due to the fact that it is a kind of a mobile system and the pump is not that stable (especially with high pressure) - also its necessary to vary the flow rate quite often - so the setpoint changes quite a few times. The flow rate has to be stable over a long period of time (hours).

Please explain more about the physical system. Pressure rising with flow is unusual.

I'm unclear about your use of the terms on/off and the proportional opening if the valve to control the system. Do you have any feedback on valve position other than what percent of the 15 seconds between fully open and fully closed you have applied power to the valve? Is the relationship linear? If you are closed, and open the valve for 7.5 seconds, is it half open? If you then close it for 3.75 seconds, is it 25% open?

cattledog:
Please explain more about the physical system. Pressure rising with flow is unusual.

I'm unclear about your use of the terms on/off and the proportional opening if the valve to control the system. Do you have any feedback on valve position other than what percent of the 15 seconds between fully open and fully closed you have applied power to the valve? Is the relationship linear? If you are closed, and open the valve for 7.5 seconds, is it half open? If you then close it for 3.75 seconds, is it 25% open?

Basically what you are saying is correct. I do not have any feedback on the position from the valve itself. In principle its just a "dumb" motor controlling a piston in the valve itself and the relationship of flow and pressure is of course not linear. I measured the curve and it an exponential function flattening at the end.

I am using a proportional valve. The pressure and flow from tank/pump always remains the same (exept for fluctuations) and the valve has one inlet and two outlets. One into the system and one back to the tank. I am measuring the pressure and flowrate only after the valve.

nisse80:
A little overshoot is acceptable. But with only ON-OFF control based on the setpoint (incl. some hysteresis) i get serious oscillations.

That's why I mentioned 3-state regulators (ON-STAY-OFF).

What exactly do you mean by "state regulator"?

It's hard to find in English books, "adaptive control" comes close to it even if adaptation is not a requirement.

nisse80:
I would need some kind of a PID controller that would give me a ouput like

OPEN for x sec

CLOSE for x sec

if in a certain range do nothing

Why not treat the output of the PID calculation as TIME - positive is OPEN time and negative is CLOSE time

The simplest way to deal with the dead-band where nothing should happen is not to call the PID algorithm.

This link has a simple PID function.

...R

I would think that you want the PID output to tell you what percentage open the valve should be. At startup, close it all the way so you know where it is.

Then have your code keep track of the valve's status. If the PID tells you it should be different, calculate how long and in which direction to apply voltage to the valve and manage that with millis.

wildbill:
I would think that you want the PID output to tell you what percentage open the valve should be.

I have the impression that it is not a proportional valve and is either open or closed. I believe the OP was asked about this earlier and did not respond.

…R

Robin2:
I have the impression that it is not a proportional valve and is either open or closed. I believe the OP was asked about this earlier and did not respond.

From the first post I see a reference to fifteen seconds from fully closed to fully open, so you're probably right - it's not actually proportional, but I suspect that you can treat it as such if you know that it started closed.

Might need some calibration for fine tuning too.

In reply #6 the OP says that they are using a proportional valve with no feedback on valve position other than the time it has been opened or closed.

cattledog:
In reply #6 the OP says that they are using a proportional valve with no feedback on valve position other than the time it has been opened or closed.

OK, I missed that.

But I'm still not completely clear what the OP wants to control. Am I correct to think he has some means to measure the flow rate and he wants to be able to adjust the valve position to give the desired flow rate? In other words, for a particular flow rate there will be a particular percentage of openness for the valve. And the position of the valve cannot be determined except by measuring the flow rate. There also seems to be the complication that a very small movement of the valve can result in excess or inadequate flow. The total opening / closing time is said to be 15 seconds but the desired error needs to be "in the range of tenths of milliseconds" (Original Post) - that's an error of the order of 1 in 60,000.

I don't know if it would work but I can envisage a system that powers the valve for (say) 1 second if there is a large error in the flowrate and progressively reduces the powered time in a series of steps as the flowrate nears the desired level. Such a system would not need to know the position of the valve. However I can't imagine a motor system that could be powered for periods as short as 1 millisec.

...R

The valve actually seems to implement the "I" part of the PID, opening more and more while the error is positive and closing more and more while the error is negative. A regulator for that type of controlled system must be somewhat predictive, or else the system oscillates forever for no special reason.

The system will be more stable if the difference of the PID outputs, or the I part only, is forwarded to the valve, instead of the immediate output. That output then is mapped into Open (+100%), Stay (0) and Close (-100%). PWM may be usable, to some degree, but its undefined at which duty cycle the valve motor will actually start spinning, and how hot it will become while stalled.

Am I correct to think he has some means to measure the flow rate and he wants to be able to adjust the valve position to give the desired flow rate? In other words, for a particular flow rate there will be a particular percentage of openness for the valve.

Yes, this is how I understand it as well. There is some complicating issue of the inlet pressure to the pump having variations, and its not clear how fast they occur or persist, and how much the valve position needs to move to accommodate these fluctuations in order to maintain constant outlet flow.

What's not clear to me is what variation in outlet flow can be tolerated and how fast the flowrate needs to be brought to the desired value. If the flow can be slowly ramped up from the valve closed that is a good way to go.

It would also be possible to store a table of valve positions for flow rates, and open to some initial value before fine tuning the position.

I would hope to see some more data about how the flow rate varies over time with the valve at a fixed position and how the flow rate varies from that with different timed moves to open and close from that position.

DrDiettrich:
The valve actually seems to implement the “I” part of the PID, opening more and more while the error is positive and closing more and more while the error is negative.

Is that any different from (say) the throttle on a petrol (gas) engine?

…R

The motor of the valve makes the difference. Apply power and the valve will gradually open or close until power is removed or the end stop is reached.

DrDiettrich:
The motor of the valve makes the difference. Apply power and the valve will gradually open or close until power is removed or the end stop is reached.

Isn’t that what your foot does to the throttle pedal in a car?

…R

I've been thinking of this situation like stepper control. A short timed pulse to the motor is equivalent to a step, and it opens or closes the valve a given amount depending on the h-bridge. The valve maintains its position with no power applied to the motor The effect on flow rate may not be linear with the steps depending on the valve position.

The OP did talk about pulse lengths to the motor which are very short

At high pressure rates, the open/close timing needed is in the range of tenths of milliseconds to reach.

In my opinion, the characterization of the physical system needs to be fleshed out before a control system is devised.