2 PID loops for one control variable

rta53

Lifetime Supporting Member
Join Date
Feb 2003
Location
North Carolina
Posts
619
I have a need to control the speed of a pump using two different control scenarios. The hardware is an AB CompactLogix with Studio5000 V30.

Normally the pump is controlled based on the discharge pressure as the control variable with a single set point. However, when a carbon filter is backwashing, they want me to control the pump based on flow as the control variable, with two different set points, one for backwash and one for rinse. I'm guessing I will need to use two PID instructions and enable the appropriate one as needed. What would be the cleanest way to do this?
 
I have a need to control the speed of a pump using two different control scenarios. The hardware is an AB CompactLogix with Studio5000 V30.

Normally the pump is controlled based on the discharge pressure as the control variable with a single set point. However, when a carbon filter is backwashing, they want me to control the pump based on flow as the control variable, with two different set points, one for backwash and one for rinse. I'm guessing I will need to use two PID instructions and enable the appropriate one as needed. What would be the cleanest way to do this?

To be honest I think you have answered your own question - "I'm guessing I will need to use two PID instructions and enable the appropriate one as needed".

The only issue you will have is that both PIDs cannot control the same output, as one will be at zero (disabled), while the other will be controlling, so use your "enable" bits to move the respective output from separate holding registers.
 
To be honest I think you have answered your own question - "I'm guessing I will need to use two PID instructions and enable the appropriate one as needed".

The only issue you will have is that both PIDs cannot control the same output, as one will be at zero (disabled), while the other will be controlling, so use your "enable" bits to move the respective output from separate holding registers.

Would you not be able to use the same analog output as long as only one PID is enabled at a time?
 
Would you not be able to use the same analog output as long as only one PID is enabled at a time?

Sure, but don't specify the output in both loops. You need intermediary tags which you copy to the output depending on which loop is operating.
 
Another suggestion: Use an int to select which loop is active, NOT two booleans.

Why?

Because sure as anything, next year when you (or the next guy) have to modify the code, you will make an error which will result in both booleans being true at the same time.

If you use an integer, then it can only be one or the other (or the third if you need to add another mode) and you never accidently get both loops active at the same time.
 
Another suggestion: Use an int to select which loop is active, NOT two booleans.

Why?

Because sure as anything, next year when you (or the next guy) have to modify the code, you will make an error which will result in both booleans being true at the same time.

If you use an integer, then it can only be one or the other (or the third if you need to add another mode) and you never accidently get both loops active at the same time.

Use a DINT - more efficient.

Logix5000 are 32-bit machines, so using any other data-type results in conversion to DINT for processing, and conversion back again for storing the result.

It may seem odd to use a DINT when you only want the values 0 & 1 (or 1 & 2), but it really is most efficient to do this.
 
Another suggestion: Use an int to select which loop is active, NOT two booleans.

Why?

Because sure as anything, next year when you (or the next guy) have to modify the code, you will make an error which will result in both booleans being true at the same time.

If you use an integer, then it can only be one or the other (or the third if you need to add another mode) and you never accidently get both loops active at the same time.


You only need one...

--| |--

--|/|--

The problem is the trasnsistion between the two PID's. You will need some logic to smooth out the output from PID to the other.
You don't want the output to jump from say 0 to 100 % or something inbetween.


Maybe controlling the PIDs auto/manual modes. Then have the manual PID's setpoint track its process. Then after the transistion to auto slowly change its setpoint to whatever is required. (just thinking out loud)
 
Last edited:
Actually, you only need one PI (or maybe PID) for the pump. You need two surces of setpoints for that PI loop - either a fixed flow setpoint or the output from a cascaded pressure control loop.

Pumps produce flow. The piping system creates resistance to flow that creates the pressure the pump has to overcome to move that flow through the system. When you modulate the pump, either by throttling the discharge or varying pump speed, you are essentially changing pump flow and the interaction between the flow and the system restriction.

So, I recommend you have a pump flow control loop. It will have three different setpoints:
1) The required flow during backwash
2) The required flow during rinse
3) The output from a separate PI (or PID) loop that uses pressure as the process variable and flow rate as the manipulated variable. This loop will be locked out during filter backwash and rinse cycles.
 
Actually, you only need one PI (or maybe PID) for the pump. You need two surces of setpoints for that PI loop - either a fixed flow setpoint or the output from a cascaded pressure control loop.

Pumps produce flow. The piping system creates resistance to flow that creates the pressure the pump has to overcome to move that flow through the system. When you modulate the pump, either by throttling the discharge or varying pump speed, you are essentially changing pump flow and the interaction between the flow and the system restriction.

So, I recommend you have a pump flow control loop. It will have three different setpoints:
1) The required flow during backwash
2) The required flow during rinse
3) The output from a separate PI (or PID) loop that uses pressure as the process variable and flow rate as the manipulated variable. This loop will be locked out during filter backwash and rinse cycles.

Of course you could do it with just one control loop, but then you'd have a plethora of data moves, setpoints, P, I, & D terms etc., and that will make the system hard to maintain, because you'd have to edit the relevant sources of that data, not the values set in the PID instruction tag. And if you were loop tuning, those data moves would have to be continuous, or they wouldn't get into the PID tag.

I just think it's easier, tidier, and clearer to an onlooker, to have two independent loops that can be tuned separately.
 
On a totally side note. I laughed when I noticed the avatar I've been using all these years.(Became a member in 2003) My hair was still brown back then so that avatar seemed appropriate. No longer...I have practically no brown left, although I do still have a good bit of hair.
 
In the case you mentioned in the OP, I would probably have 3 PID loop instructions, each with their own PID tags, Process, Backwash, and Rinse, enabling them as required at the relevant stages. Each loop could then be tuned independently, to cater for any different flow characteristics.

I don't see transitions between modes being an issue, surely there would be some "dead-time" between Process and Backwash, and between Backwash and Rinse, so each loop would be firing up in isolation.
 
In the case you mentioned in the OP, I would probably have 3 PID loop instructions, each with their own PID tags, Process, Backwash, and Rinse, enabling them as required at the relevant stages. Each loop could then be tuned independently, to cater for any different flow characteristics.

I don't see transitions between modes being an issue, surely there would be some "dead-time" between Process and Backwash, and between Backwash and Rinse, so each loop would be firing up in isolation.

Sounds like the best solution! I think this will do exactly what I need. Thanks!
 
Pumps produce flow. The piping system creates resistance to flow that creates the pressure the pump has to overcome to move that flow through the system. When you modulate the pump, either by throttling the discharge or varying pump speed, you are essentially changing pump flow and the interaction between the flow and the system restriction.

By the sounds of it, OP is programming some type of filtration system. So the membranes will have an impact on pressure in the line, and it's probably ideal to run at an optimum pressure specific to the membrane during production rather than flow through the membrane. As the membranes get clogged up flow will be reduced and pressure will increase, so it's better maintain a constant pressure than flow.

When backwashing it all changes, flow is required to get things cleaned out.

In a previous life I worked on filtration systems, and typically it goes something like this:

1 - Pressure PID in control
2 - Pressure PID in manual (maintain fixed output, bump less transfer to flow PID)
3 - Flow PID in control
4 - Reverse to go back (don't forget the bumpless transfer.

The issue is ensuring the output to the pump doesn't suddenly drop or spike as you transition from one control loop to the other (on a running system). You need logic in place to perform a bumpless transfer between the PID loops, which usually means some intermediary storage tags as Daba mentioned and logic to keep track of it all.
 

Similar Topics

Hello Everyone, I am a novice PLC programmer, this is going to be my first PLC program. I am using a Controllogix processor. I will be using...
Replies
1
Views
7,159
Hi All, I am a new member to this site but have been reading posts on this site for years. I now have to ask a few questions for the PID...
Replies
20
Views
17,041
Hey All, I am working on the programming to maintain level and pressure in a 80 gallon surge tank. This tank feeds fillers that fill either 2.5...
Replies
2
Views
1,525
Hi guys! It seems to me that PID loops with feed forward are underutilized. Maybe it's just me but I think almost every loop would work better...
Replies
6
Views
2,674
Hi, I am new to Eaton ELC Soft. I have a background with Allan Bradley plcs but this seems to be set as if from 1950. It seems to be powerful...
Replies
0
Views
1,963
Back
Top Bottom