Simple On-Off Control for First Orders and Overdamped Systems
Bang-Bang Control: an easy to program and calibrate first order plant control when output of the system is on-off actuator.
What is this for?
The objective of this document is to present an easy to program and calibrate first order plant control when output of the system is on-off actuator. This algorithm is based on Bang-Bang Control which uses hysteresis to turn on and off the output of the control with an enhancement of a first order filter in an inner feedback loop to increase modulation of the output.
The type of outputs that this control may drive are:
- Solenoid Valves.
- Motorized Valves with 2 positions (Open/Close).
1. Solid State Relays (To drive heating resistors).
2. Electromechanical Contactors.
This solution has been tested in physical thermal heating and heating/cooling systems described in the tools and prerequisites section (see below) as the test equipment, and level control systems (Tested in industrial system not shown here) where we have inlet and outlet flow.
Is this useful for me?
The bang-bang principle of operation is the on/off control with hysteresis, but we have added a feedback inner loop at the on/off output through a first order filter.
The ultimate effect of the Feedback First Order filter in the Bang-Bang Control is to compensate for the dead time it takes between from the actuator that affects the measured variable and the sensor to report actual measurement.
With the feedback filter, the oscillation at the control output will begin earlier than if it only had the hysteresis comparator hence limiting the amount of heat deliver to the tank helping to avoid overshoot as the heated liquid arrives to the sensor.
This algorithm can replace a Proportional-Integral control loop that needs to be connected to a time proportional output, it is simpler to tune and has less parameters to setup.
Note: We suggest using this algorithm for first order systems and only critically damped and overdamped (ζ≥1) second order systems. Undamped system may produce undesirable oscillations that may have unexpected behavior.
How can I make it work?
Previous knowledge:
- Enhanced Bang-Bang Algorithm theory of operation.
- Definition of a First Order and Second Order Critically Damped or Overdamped System.
(Full document available here)
The block diagram for the enhanced Bang-Bang control algorithm is shown in Figure 1:
The bang-bang principle of operation is the on/off control with hysteresis, as the diagram shows the system will turn on when the input [e2] is greater than H but, it will hold on until [e2] is less than L.
Normally this is all the bang-bang functionality, but we have added a feedback inner loop at the on/off output through a first order filter. This filter is implemented mathematically in the algorithm.
This first order filter (FOF) will receive the status of the bang-bang (BB) (hysteresis) output block that is a 1 (one) or 0 (cero) depending if the output is on or off. The result will be a capacitance charge or discharge depending on the state of the Bang-Bang block output. The tendence of the FOF output will be K when the BB output is on and will tend to cero when the output is off.
The output of the FOF is subtracted of the error [e] producing a reduced [e2] that will tend to K, this means that when the error (e=SP-PV) is greater for enough time, e2 will tend to e-Kr, therefore e2 will be greater than H turning the output of the BB to on.
The final control element will stay open until the plant reaches the difference stated by e2 ≤ L the output of the BB will turn off even when the plant has not yet reached the Setpoint, but then the feedback filter will begin a discharge provoking an increase on e2. The discharge will continue until e2 reaches H that will turn again the output of BB.
The process will continue to cycle between on/off until the PV reaches SP.
Tunning the Bang-Bang
Tunning method is quite intuitive. But is best to begin with small gain in the feedback filter and few units of error to turn on the control and few units to turn off the control. It can begin centered over cero. For example, start with [H = 0.5% of the control variable] and [L=- 0.5% of the control variable]. Make K=0 to see how the system reacts to a pure bang-bang.
The sample time should be equal to the periodic function call for the Bang-Bang function. This parameter is important because it will determine the system timing for the following steps.
Check the overshoot after the system stabilizes, make [K] equal to overshoot and [Tao] equal to the dead time (t0) to estimate this time (does not have to be precise) measure the time between the output of the actuator activates and when you can see a perceivable change of 0.5% in the control variable.
This will set up the Bang-Bang for the first pass tunning.
By observing the system capacity, you may reduce the gap between [H] and [L] to reduce magnitude of the fluctuations around the set point [SP].
You can also reduce or increase the on/off period by modifying [Tao] on the control. This will enhance the precision of the system output but will create and increase of on/off cycles in the actuator.
Be aware that if the actuator has a mechanical operation such as a relay, contactor or solenoid valve, the life of the actuator will be inverse of the number of on/off cycles, so you will need to make a trade off among life of the actuator and precision of the control.
Cooling Bang-Bang (Actuator to decrease the control variable)
The algorithm to decrease the control variable such as cooling in a heated tank or pressure release valve in a pressure tank is very similar to the heating diagram but with some changes as shown in figure 2:
The difference in the algorithm is that the decrease output is multiplied by -1 before feeding the input of the inner loop filter. The control different parameters, now the hysteresis turns on the decrease actuator when the e2 is less than de SP at DecON point and will turn off the decrease actuator when the e2 is greater than DecOFF point.
Heating and cooling Bang-Bang
The last case for Bang-Bang is when you have both actuators for the same system, this is the case of application such as chrome plating or galvanizing where the systems need to be at a certain temperature to begin the process but once the process is in operation, the process generates more heat due to the electro plating current and hence needs to be cooled.
In this case we need to use the Bang-Bang in dual mode as shown in figure 3:
As you can see in figure 8, we have 2 hysteresis, one to drive the increase actuator and one to drive the decrease actuator. The key to tune this option is to make sure that the [DecON] parameter is always less than the [IncOn] and is preferable that the off point of both parameters does not cross each other. Is preferable that both hysteresis are set up as mutually exclusive.
Tools & prerequisites
Software:
- Studio 5000 Logix Designer v35.
- FactoryTalk View ME v12.00.00.
Hardware:
- ControlLogix Logix (1756-L83) FW v35.
- CompactLogix I/O Adapter (5069-AEN2TR).
- CompactLogix Universal Analog Input Card (5069-IY4).
- CompactLogix 16 24VDC output card (5069-OB16F).
- PanelView Plus 7 Performance 700 (2711P-T7C22A9P).
Test System Components:
- 1 Pc 8 liters aquarium.
- 1 pc RTD PT100 Temperature Sensor.
- 1 pc Solid State Relay 24 VDC input coil / 125 VAC output.
- 1 pc 400 watts heating resistor.
Files:
- BB.acd Logix Designer Addon Instruction
Inputs & Outputs for the testing system.
The input outputs used are:
- 1 PT100 RTD temperature sensor connected to Remote Compact I/O input in slot 3 input 0 (5069-IY4). Controller tag: Compact_Ethernet_Adapter:3:I.Ch00.Data.
- 2 DC output connected to 24 DC output card in Remote Compact I/O in slot 2 output 0 & 1. Compact_Ethernet_Adapter:2:O.Pt00.Data & Compact_Ethernet_Adapter:2:O.Pt01.Data.
Bang-Bang Add On Instruction (AOI).
The Bang-Bang Add On Instruction contains the instruction parameters, input variables and output variables to make the control work as well as the logic. The parameters that are input and output are shown in the faceplate made for Panelview Plus 7.
AOI Structure
The AOI instruction has a defined data type to name each control system by its unique name. In the case of this example the name of the system is “Acuarium” that has the {aoi_Bang_Bang} data type.
Enable/Disable Parameters:
Parameter List and description.
[BB_is_ON] Boolean input variable to turn the control to ON or OFF.
[Has_inc_element] Boolean input to indicate if control has variable increase actuator.
[Has_dec_element] Boolean input to indicate if control has variable decrease actuator.
Operation parameters:
[PV] Process variable: This is a real floating-point parameter. You should assign the scaled variable of the input card to this variable.
[SP] Set Point: This is a real floating-point parameter. This variable will be set in the HMI or any input device that sets the reference for the control.
Calibration parameters:
[Inc_On] Real floating-point parameter. This is part of the hysteresis of the Bang-Bang that if the input error to the hysteresis greater than this value, the output to the increase the control variable is turned on.
[Inc_Off] Real floating-point parameter. This is part of the hysteresis of the Bang-Bang that if the input error to the hysteresis is less than this value, the output to the increase the control variable is turned off.
[Dec_On] Real floating-point parameter. This is part of the hysteresis of the Bang-Bang that if the input error to the hysteresis is less than this value, the output to the decrease the control variable is turned on.
[Dec_Off] Real floating-point parameter. This is part of the hysteresis of the Bang-Bang that if the input error to the hysteresis is greater than this value, the output to the decrease the control variable is turned off.
[tsample] Real floating-point parameter. This parameter should be equal to the time defined for the scan time of the periodic task for the Bang-Bang.
[Tao] Real floating-point parameter. This is the time constant in seconds for the first order filter at the inner loop feedback.
[K] Real floating-point parameter. This is the gain that the output of the first order system will tend after long period of time (normally 7 times Tao). If K = 3, then after 7 times Tao, the filter output will be near 3.
Monitoring Parameters
[e] Real floating-point variable. This indicates the difference between the setpoint and the process variable ([e] = [SP] – [PV]).
[e2] Real floating-point variable. Is the difference between the error [e] and the output of the first order filter [FB_Filter_Out].
[FB_Filter_In] Real floating-point variable. Is the input to the feedback filter which is the result of adding [INC_OUT] – [DEC_OUT] output parameters. These parameters are the actual outputs to actuator elements. Because [INC_OUT] and [DEC_OUT] parameters are Boolean, to add these parameters is required to use integer variables before assigning to the Filter input.
[FB_Filter_Out] Real floating-point variable. Is the output of the feedback filter which is the result of the digitalization of the transfer function of a first order system. For simplification purposes, the first order differential equation is transformed to digital sampling with Euler method.
The filter equation is as follows:
Output Parameters
[INC_OUT] Boolean Output Parameter. This is the output that must be connected to the output card to drive the Increase control variable actuator.
[DEC_OUT] Boolean Output Parameter. This is the output that must be connected to the output card to drive the decrease control variable actuator.
AOI internal variables
The Add On Instruction has other internal variables required to execute the instruction such as conversion from Boolean to Integer. We will not describe each of these variables in this document as the AOI instruction is open for reviewing and editing.
Panelview plus 7 screens
Panelview 7 machine edition screen is provided as face plate for the Bang-Bang Control.
The face plate is provided as a sample for a system and is included in the documentation package.
Previous Knowledge
Definition of a First Order and Second Order Critically Damped or Overdamped System. You can find the complete document here.
Downloads
Please note: You will need to agree to the Terms & Conditions for each download.
Need Help?
If you need help with an application or have feedback from the Innovation Center, please contact us.
Installation Guide
To implement the Add On Instruction check the following steps.
Studio 5000 AOI
Step 1:
Extract files from BB.ZIP into your working directory
Step 2:
Open file BB.acd into Studio 5000
Step 3:
Open the project where you want to use the Bang-Bang (it is assumed that the I/O mapping of your project is already done).
Step 4:
Highlight Select the aoi_Bang_Bang instruction under Assets menu in the controller organizer section of the Logix Designer.
Step 5:
Right click the mouse and select Copy as shown if Figure.
Step 6:
Go to the program you want to use the Bang-Bang and under Assets, highlight select the folder Add-On Instructions.
Step 7:
Verify that your target program has the new pasted AOI and under data type you should also have a new structure under Add-On-Defined.
Step 8:
Create a periodic task where you want to use the Bang-Bang Control or copy and paste the sample task from the BB.acd program. If you choose to copy the periodic task it must be done in 2 steps:
a. Select the Bang_Bang (10ms) Task, right click the mouse button and select copy.
b. Go to your target program and under Task folder right click select paste. The periodic task will be created in the target program.
c. From the BB.acd program under Bang_Bang (10ms) task right click select the BB_Logic routine and select copy.
d. In the target program select Bang_Bang (10ms) and right click to paste the logic.
Step 9:
Under Controller Tags define a new variable “Acuarium” (because this is the name of the system in the BB_Logic routine.
Step 10:
In the BB_Logic routine in the program named {IOAssignments_n_Scaling}, change the I/O Analog Input Address to match your project. Also change the Digital output to the Control Actuators to match your project.
Step 11:
Your Bang-Bang should be ready to work in your target program.
View Studio ME
To use the template for PanelView Plus 7 Performance, you will need to recover the project from the .mer file into the Studio 5000 View ME.
Step 12:
From the zip file unzip the file named PV7P_BB.mer (Remember this file is in version 12 for ViewME).
Step 13:
Use Factory Talk ViewME Application Manager from the tools menu within the FactoryTalk ViewME application.
Step 14:
Select “Restore runtime application.”
Step 15:
Select the file BB.mer file.
Step 16:
Select Open application and the application should be restored.
You can also find many videos on how to restore a .mer application to recover