Flow PID and Level P-Only controls working together

TheWaterboy

Lifetime Supporting Member + Moderator
Join Date
May 2006
Location
-27.9679796,153.419016
Posts
1,905
Hello all !

I need to control flow to a setpoint, but often the level in the tank creeps up because there is just a little more going in than coming out.
In those instances, flow needs to be increased a bit to bring the level back down and Flow becomes a secondary concern and I'd like to make those adjustments as short as practical while preventing the need for a clean up crew.
I have one PID controlling flow and it does a fair job. I realize these might be meaningless without context but P=0.00005, I=0.00009 and D = 0.001

I also have a P-only control (P = 20) providing a value from -10 to +10 that gets added to the first PID output. That value then drives the pump VFD. This works to a point but does not go far enough.

In the case today the tank is a little high and this drives the output from 10 till about 7 which increases the pump speed (by that much in percent) then at about the 7% value the adjustment stops doing much good, likely due to a pump affinity issue I don't grasp just yet.

Same effect was true when the tank was a little low. A large amount off, like a foot and and it adjusts better but les than that either way leaves the level high or low of the mark. and I just cant get the P only to drive the offset to zero.

The tank is huge, how can I get the P-only PID to stay near max till it gets the level right on target then slope to zero and stay there till the next tank level upset? A higher peak with less duration (or Q perhaps)

I can simply add the required value in discrete logic, but I thought the P only control was more interesting to see if I can make it work.

Any suggestions or maybe even proven sample code of a better idea I can review?
.
 
I realize these might be meaningless without context but P=0.00005, I=0.00009 and D = 0.001


Meaningless? Maybe not.

I am going to go out on a limb and suggest, based on those numbers, that there's summat amiss with that PID's configuration. Specifically, what is its configured update time, and how is it being executed (i.e. is the update time correct)?

Also, there is no mention of the form used, but if it's so-called "velocity" form then perhaps, with so many zeros after the decimal points, there is a resolution problem e.g. it tries to calculate

CV[n] = CV[n-1] + 1e-6


when CV[n-1] is around 50.0, and in effect does

CV[n] = CV[n-1] + 0.0e0




instead.

I could be way off base, so take this with a dump truck of salt.


Cf.

>>> import numpy
>>> fifty=numpy.float32(50)
>>> micro=numpy.float32(1e-6)
>>> fifty,micro,(fifty+micro)-50
(50.0, 1e-06, 0.0)



 
Last edited:
d'Oh! Wait a minute.

You are adding an offset to the CV output of a PID, and that sum (CV + PID-external offset) is controlling a VFD to control it's PV, which PV is the flow. The PID seeks to minimize the error between the PV (measured flow) and the SP (setpoint flow).

Meanwhile, hat PID has a non-zero integral gain, which accumulates its own PID-internal offset term to CV output, as long as the error (PV-SP) is non=zero.

Does anyone see the problem? And how to fix it?

Cf. here ;).

@PeterN, @TomJ: I am getting worse, not better.


QHcFAi843Kb7OU0GE4b81w.png
 
Last edited:
Dr.Bit

I'm ashamed to post this code, its a mess of attempts and side calculations. That's why I was hoping for a sample I can clean up around.

It was previously step logic which gives the folks that adjust the following process fits. so smoothing it out is far better for them.

I get what you are saying about the resolution of decimal places - but these numbers are from the PID that works pretty well.

Both are on a continuous task
Flow PID (working one)
Independent, SP-PV, Error, Loop time 2.0

Level Adjustment PID
I've been poking so the PID values are **** numbers that do not work.
Dependent, SP-PV,Error Loop time 2.0

The goal of this is to just nudge the Flow Control output up or down until the level returns to setpoint. I don't want a big sudden change really, but I need an effective one. I had hoped BIAS was that option but it adjusts to that.

When I am making the addition to the flows CV, I inhibit it and move the value into the hold value so the transition back to PID is bumpless, but the flow PID is not in play at that time. I'm dumb but not that dumb... well maybe... we'll see.
.
 
Hi, your control requirement is still a bit unclear to me, let me know if this is the requirements:

You are actuating the pump down stream of a tank. You want to control the flow rate through that pump and also the tank level.
And you have three goals:
Priority1: Level does not exceed High Level Setpoint
Priority2: Level does not go below Low Level Setpoint
Priority3: Flow is at Flow SP

I might implement this as three PIDs, a minimum function and a maximum function.

MIN(LowLevelPid.OP, MAX(FlowPID.OP, HighLevelPID.OP))

So all PIDs' OPs would track the actual OP.
If you want to keep proportional only, then you would not need to track for the level controllers.
Tracking is important though for integral windup.
 
Instead of applying the correction based on the level error to the PV output, have you tried applying it to the setpoint? Only apply the correction when the level gets outside of an acceptable range.
Edit: Oops, I saw that Australian made the same suggestion.
 
Last edited:
As that Aussie bugger with the confusing flag and Steve Bailey have suggested, using the level to adjust the flow setpoint is the way to go.

I use this on all my tank controls where flow in our out needs to follow the input or output of another process.

I just use an SCP block where min and max Raw values are the tank min and max acceptable level values. Raw input is the tank level.

The SCP block scaled min and max are the acceptable min and max flow ranges for the flow control setpoint.

Make sure to clamp between min and max, the SCP block doesn't (at least in the SLCs and Micrologix I've normally used).

May also be worth adding some protection against fast cycling if the level signal goes faulty. I.e. Rate of Change too high, disable flow setpoint changes and raise an alarm or shut down.

I once had to explain (to a pretty smart process engineer) why i could not just use the water in flow setpoint as the water out flow setpoint. If they're the same then it should just balance, right?!

Flowmeter measurement error, PID over and undershoot, and any unmeasured additions or withdrawals will result in accumulated error one way or another. The discharge needs to be decoupled from the inlet so they essentially work independently.
 
AustralIan is on the right track but one must be careful on how the integrator for each PID is handled. I would try a simple proportional band for the level control and add


@TheWaterBoy, numbers for gains don't mean much without units.


Why not a simple PI for controlling the level and a I gain that gets added on to the flow I gain.
CV(n)=CV(n-1)+Ki_flow*flow_error(n)*dt-Kp_flow*(flow(n)-flow(n-1))+Ki_level*level_error(n)
Notice that the Kp_flow only depends on changes in the flow. Not the flow error because the flow set point factors out.
I am assuming that the level doesn't change that fast so it doesn't need a level proportional gain. This method avoids mins and maxs of AustralIan's method. It also avoids integrator windup. The trick is getting the right values for Ki_level and Ki_flow.

Tom would approve of this. It is almost like adding a floating control of on the level to the PI flow control.
@drbitboy, don't feel bad,you are still good for pulling teeth.
 
Instead of applying the correction based on the level error to the PV output, have you tried applying it to the setpoint? Only apply the correction when the level gets outside of an acceptable range.
Edit: Oops, I saw that Australian made the same suggestion.


Make that three of us saying the same thing; this is the only solution that will control the level.

Bottom line, your ultimate controlled value can be EITHER flow OR level, but not both.

And since if you ultimately control flow the tank will EITHER overflow requiring cleanup OR run dry and stop flow to the downstream process, the ultimate control has to be level. You can fiddle around with how the flowrate setpoint value is updated e.g. to add a filter, but the overall control will be level control.
 
Last edited:
Bottom line, your ultimate controlled value can be EITHER flow OR level, but not both.
Yes!!!! I get the same questions about being able to control position or force. It is one or the other IF YOU NEED TO CONTROL THEM PERFECTLY.
This is where one makes compromises.
This is why there are techniques such a LQC or linear quadratic control. In LQC one makes a cost function which is usually as simple as C0*Level_error^2+C1*Flow_error^2 and the gains are chosen to minimize this function. The math for this is easy but chosing the right cost function weights for C0 and C1 is takes experience. I can do the math. It it probably easier for TheWaterBoy to determine the gains by trial and error.





And since if you ultimately control flow the tank will EITHER overflow requiring cleanup OR run dry and stop flow to the downstream process, the ultimate control has to be level. You can fiddle around with how the flowrate setpoint value is updated e.g. to add a filter, but the overall control will be level control.
Changing the flow rate set point is not the answer.


There was a thread a long time ago where Pandiani and I worked on a problem by a student from Mauritius where he had to control both temperature and flow rate of water.


I solved the problem two ways. One used LQC and the other just using PI controllers and using one to modify the output of the others. The result were not the same but both were good enough.
 
Changing the flow rate set point is not the answer.


Can you explain this? The flowrate must change as it is the only control element, so why would whatever control scheme is used not cascade to the flowrate control loop?

I realize another approach would eliminate the flowrate control loop and send its output to the VFD speed reference directly, but that only changes the relative gain in engineering units, not the overall approach i.e. controlling flowrate to optimize behavior of combined level and flowrate.
 
Is this in AB studio? If so and you are using PID, you have to execute the PID instruction at a timed interval the same value that you are setting update time to. This can either be done by placing a timer.dn in front of the instruction (and setting the timer up to self resetting at whatever interval you are wanting to execute), or by placing the PID instructions in a periodic task executed at the desired rate. If you have the PID in a continuous task executing every scan then the I and D values will not calculate correctly and you end up having to put in gains with non-sensical values.
 
The tank is huge, how can I get the P-only PID to stay near max till it gets the level right on target then slope to zero and stay there till the next tank level upset? A higher peak with less duration (or Q perhaps)


Can you sketch what the desired trends of a few items would look like for a disturbance in inlet flowrate?

  1. [Target Outlet Flowrate]
    1. i.e. flat line; this is what you want to ideally send to the downstream process, when not controlling level
  2. [Inlet Flowrate] e.g.
    1. a step change disturbance from being equal to [Target Outlet Flowrate] (item 1 above) for X minutes/hours,
    2. or a constant offset from target outlet flowrate
  3. [Target Level]
  4. [Trigger Level(s)] at which to abandon controlling [Outlet Flowrate] (item 5 below) value at [Target Outlet Flowrate] (item 1 above) for a time, to start controlling level to bring it back to the [Target Level] (item 3 above)
  5. [Outlet Flowrate] (or VFD speed)
    1. I.e. the value directly or indirectly controlled to meet all other control criteria
PID's single control criterion is to minimize error between some value (PV) and a setpoint (PV) for that value. Since there are multiple criteria here, one PID will not do the job, although multiple PIDs could be part of the solution.


I still think you should post the code, at least the two PIDs and any connecting code that changes their state (e.g. manual flow control while driving measured level back to level setpoint).
 

Similar Topics

Hello, I take part in commissioning of process station with lobe pump. Speed of the pump is controlled by PowerFlex 525. A customer requirement...
Replies
7
Views
5,451
Hi, I am new to PID control, wondering if anyone can help me with this. We have a flow meter goes into VHSC point io card as input, analog output...
Replies
2
Views
2,064
I have a PID loop I would like to produce a mathematical model for. I may not have paid enough attention in the Control Systems lectures a few...
Replies
1
Views
2,112
Quick question. I have a PID controller that has the following parameters Process: Flowrate (L/s) Setpoint: FlowrateSP (L/s) Output: ValvePIDOut...
Replies
2
Views
2,450
Hi guys, Need some help. Goal: Closed loop flow control of valve positioner to a flow value. Parts: I've got a K series Rotork valve with...
Replies
8
Views
4,216
Back
Top Bottom