Skip to main content
Engineering LibreTexts

5.2: Logical control programs- IF... THEN… WHILE…

  • Page ID
    22389
  • Authors: Stephanie Fraley, Michael Oom, Benjamin Terrien, John Zalewski
    Stewards: Ross Bredeweg, Jessica Morga, Ryan Sekol, Ryan Wong

    2.1 Introduction

    A logical control program is a set of conditional statements describing the response of a controller to different inputs. A controller is a computer used to automate industrial processes. Process engineers use control logic to tell the controller in a process how to react to all inputs from sensors with an appropriate response to maintain normal functioning of the process. Control logic (sometimes called process logic) is based on simple logic principles governed by statements such as IF X, THEN Y, ELSE Z yet can be used to describe a wide range of complex relationships in a process. Although different controllers and processes use different programming languages, the concepts of control logic apply and the conditions expressed in a logical control program can be adapted to any language.

    The concepts behind logical control programs are not only found in chemical processes; in fact, control logic is used in everyday life. For example, a person may regulate his/her own body temperature and comfort level using the following conditional logic statements: IF the temperature is slightly too warm, THEN turn on a fan; IF the temperature is way too warm, THEN turn on the air conditioning; IF the temperature is slightly too cold, THEN put on a sweatshirt; IF the temperature is way too cold, THEN turn on the fireplace. The person takes an input from the environment (temperature) and if it meets a certain prescribed condition, she executes an action to keep herself comfortable. Similarly, chemical processes evaluate input values from the process against set values to determine the necessary actions to keep the process running smoothly and safely (aforementioned example illustrated below).

    ogicalPrograms Introduction HumanTempControl.JPG

    The following sections elaborate on the construction of conditional logic statements and give examples of developing logical control programs for chemical processes.

    2.2 Logic Controls

    Logical controls (IF, THEN, ELSE, and WHILE) compare a value from a sensor to a set standard for the value to evaluate the variable as True/False in order to dictate an appropriate response for the physical system. The control program for a chemical process contains many statements describing the responses of valves, pumps, and other equipment to sensors such as flow and temperature sensors. The responses described by the system can be discrete, such as an on/off switch, or can be continuous, such as opening a valve between 0 and 100%. The goal of a control program is to maintain the values monitored by the sensors at an acceptable level for process operation considering factors like product quality, safety, and physical limitations of the equipment. In addition to describing the normal activity of the process, a control program also describes how the process will initialize at the start of each day and how the controller will respond to an emergency outside of the normal operating conditions of the system. Unlike a linear computer program, logic programs are continuously monitoring and responding without a specific order. Before constructing logical control programs, it is important to understand the conditional statements, such as IF-THEN and WHIlE statements, that govern process logic.

    The following logic controls found below are written in pseudocode. Pseudocode is a compact and informal way of writing computer program algorithms. It is intended for human reading instead of machine reading, and does not require stringent syntax for people to understand. Pseudocode is typically used for planning computer program development and to outline a program before actual coding occurs.

    2.2.1 IF-THEN statements

    IF-THEN statements compare a value from a sensor to a set value and describe what should happen if the relationship holds. The IF-THEN statement takes the form IF X, THEN Y where X and Y can be single variables or combinations of variables. For example, consider the following statements 1 and 2. In statement 1, both X and Y are single variables whereas in statement 2, X is a combination of two variables. The ability in conditional logic to combine different conditions makes it more flexible than incidence graphs, which can only describe monotonic relationships between two variables (See incidence graphs). A monotonic relationship is one where if X is increasing, Y is always decreasing or if X is increasing, Y is always increasing. For complex processes, it is important to be able to express non-monotonic relationships.

    1. IF T>200 C, THEN open V1
    2. IF T> 200 C and P> 200 psi, THEN open V1.

    Where T is Temperature, P is pressure, and V represents a valve.

    In statement 1, if the temperature happens to be above 200 C, valve 1 will be opened.
    In statement 2, if the temperature is above 200 C and the pressure is above 200 psi, then the valve will be opened.

    Otherwise, no action will be taken on valve 1

    If the conditions in the IF statement are met, the THEN statement is executed, and depending on the command, the physical system is acted upon. Otherwise, no action is taken in response to the sensor input. In order to describe an alternate action if the IF condition does not hold true, ELSE statements are necessary.

    2.2.2 ELSE statements

    The simple form of an IF-THEN-ELSE statement is IF X, THEN Y, ELSE Z where again X, Y, and Z can be single variables or combinations of variables (as explained in the IF-THEN section above). The variable(s) in the ELSE statement are executed if the conditions in the IF statement are not true. This statement works similar to the IF-THEN statements, in that the statements are processed in order. The ELSE statement is referred to last, and is a condition that is often specified to keep the program running. An example is the following:

    IF P>200 psi, THEN close V1
    ELSE open V4

    In this statement, if the pressure happens to be 200psi or less, the THEN statement will be skipped and the ELSE statement will be executed, opening valve 4.

    Sometimes, if X, Y or Z represent many variables and several AND or OR statements are used, a WHILE statement may be employed.

    2.2.3 CASE statements

    CASE statement is an alternative syntax that can be cleaner than many IF..THEN and ELSE statements. The example shown in the table below shows its importance.

    CASE

    IF..THEN and ELSE

    T>Tset+2:

    v2=v2+0.1

    T>Tset+1:

    v2=v2+0.05

    T<Tset-1:

    v2=v2-0.05

    T<Tset-2:

    v2=v2-0.1

    IF T>Tset+1:

    IF T>Tset+2:

    v2=v2+0.1

    ELSE:

    v2=v2+0.05

    ELSE IF T<Tset-1:

    IF T<Tset-2:

    v2=v2-0.1

    ELSE:

    v2=v2-0.05

    Thus CASE statements make the code easier to read for debugging.

    2.2.4 WHILE statements

    The WHILE condition is used to compare a variable to a range of values. The WHILE statement is used in place of a statement of the form (IF A>B AND IF A<C). WHILE statements simplify the control program by eliminating several IF-AND statements. It is often useful when modeling systems that must operate within a certain range of temperatures or pressures. Using a WHILE statement can allow you to incorporate an alarm or a shut down signal should the process reach unstable conditions, such as the limits of the range that the WHILE statement operates under. A simple example illustrating the use of the WHILE statement is shown below.

    Example:
    A tank that is initially empty needs to be filled with 1000 gallons of water 500 seconds after the process has been started-up. The water flow rate is exactly 1 gallon/second if V1 is completely open and V1 controls the flow of water into the tank.

    Using a IF...THEN statement the program could be written as follows:
    IF t > 500 and t < 1501 THEN set V1 to open
    ELSE set V1 to close.

    The WHILE statement used to describe this relationship is as follows:

    WHILE 500 < t < 1501 set V1 to open
    ELSE set V1 to close.

    It may not seem like much of a change between the two forms of the code. However, this is a very simple model. If modeling a process with multiple variables you could need many IF...THEN statements to write the code when a single WHILE condition could replace it.

    Example:
    V1 controls reactants entering a reactor that can only run safely if the temperature is under 500K.

    The WHILE can be used to control the process as follows:
    WHILE T < 500 set V1 to open
    ELSE set V1 to close. ALARM.

    This example shows how a WHILE condition can be used as a safety measure to prevent a process from becoming unstable or unsafe.

    In addition to lists of IF-THEN-ELSE-WHILE statements, control logic can be alternately represented by truth tables and state transition diagrams. Truth tables show all the possible states of a model governed by conditional statements and state transition diagrams represent truth tables graphically. Oftentimes, these are used in conjunction with booleans, variables that can only have two values, TRUE OR FALSE. A Boolean model or Boolean function follows the format of IF-THEN statements described here. A description of Boolean models, truth tables, and state transition diagrams is given here.

    2.2.5 GO TO statements

    The GO TO statement helps to break out of current run to go to a different configuration. It can be an important operator in logical programming because a lot of common functions are accessed using GO TO. However, many programmers feel that GO TO statements should not be used in programming since it adds an extra and often unnecessary level of complex that can make the code unreadable and hard to analyze. Even though the GO TO operator has its downsides, it is still an important operator since it can make help to simplify basic functions. It can simplify code by allowing for a function, such as a fail safe, be referenced multiple times with out having to rewrite the function every time it is called. The GO TO operator is also important because even advanced languages that do not have a GO TO function often have a different operator that functions in a similar manner but with limitations. For example, the C, C++ and java languages each have functions break and continue which are similar to the GO TO operator. Break is a function that allows the program to exit a loop before it reaches completion, while the continue function returns control to the loop without executing the code after the continue command. A function is a part of code within a larger program, which performs a specific task and is relatively independent of the remaining code. Some examples of functions are as follows:

    FUNCTION INITIALIZE: It runs at the beginning of a process to make sure all the valves and motor are in correct position. The operation of this function could be to close all valves, reset counters and timers, turn of motors and turn off heaters.

    FUNCTION PROGRAM: It is the main run of the process.

    FUNCTION FAIL SAFE: It runs only when an emergency situation arises. The operation of this function could be to open or close valves to stop the system, quench reactions via cooling, dilution, mixing or other method.

    FUNCTION SHUTDOWN: It is run at the end of the process in order to shutdown.

    FUNCTION IDLE: It is run to power down process.

    All the functions mentioned above except FUNCTION IDLE are used in all chemical processes.

    2.2.6 ALARM statements

    The ALARM statement is used to caution the operators in case a problem arises in the process. Alarms may not be sufficient danger to shut down the process, but requires outside attention. Some example when ALARM statements are used in the process are as follows:

    • If the storage tank of a reactant is low, then ALARM.
    • If the pressure of a reactor is low, then ALARM.
    • If no flow is detected even when the valve is open, then ALARM.
    • If the temperature of the reactor is low even after heating, then ALARM.
    • If redundant sensors disagree, then ALARM.

    In conclusion ALARM functions are very important in order to run a process safely.

    2.3 Control Language in Industry

    As stated before, these commands are all in pseudocode, and not specific to any programming language. Once the general structure of the controller is determined, the pseudocode can be coded into a specific programming language. Although there are many proprietary languages in industry, some popular ones are:

    • Visual Basic
    • C++
    • Database programming (ex. Structured Query Language/SQL)
    • Pascal
    • Fortran

    Pascal and Fortran are older languages that many newer languages are based on, but they are still used with some controllers, especially in older plants. Any experience with different computer languages is a definite plus in industry, and some chemical engineers make the transition into advanced controls designing, writing, and implementing code to make sure a plant keeps running smoothly.

    2.4 Logical Functions in Microsoft Excel

    Microsoft Excel has basic logical tools to help in constructing simple logical statements and if needed more complex logical systems. A list of the functions is shown below.

    TRUE().............................................Returns the logical value, TRUE.

    FALSE()...........................................Returns the logical value, FALSE.

    AND(logical_expression_A,B,C).........Returns TRUE if all the expressions are true.

    OR(logical_expression_A,B,C)...........Returns TRUE if one of the expressions are true.

    NOT(logical_expression)....................Returns the opposite of the expected logical value. If the expression is TRUE, it will return FALSE

    IFERROR(value,value_if_error)............Returns the value unless there is an error in which it will return the value_if_error.

    IF(logical_expression,value_if_true,value_if_false)..............Checks the validity of the expression and returns TRUE or FALSE likewise.

    The IF() function will be most useful in logical programing. It is essentially an IF THEN or IF ELSE function returning one of two values based on the logical expression it is testing. Excel also allows logical functions within functions. This allows for logical expressions involving more than one IF statement within itself for example. Use of these tools will be practical in quickly setting up control programs and other systems in Microsoft Excel.

    2.5 Constructing a Logical Control Program

    Understanding the conditional statements used in control logic is the first step in constructing a logical control program. The second step is developing a thorough understanding of the process to be controlled. Knowledge of the equipment, piping, and instrumentation (contained on a P&ID diagram), operating conditions, chemical compounds used, and safety concerns is necessary. Particularly it is important to know the measured and controlled variables. For example, the pressure limits of a tank must be known in order to develop a control plan to ensure safety; ignoring this constraint could lead to explosion and injury. Once the necessary controls are known, one can develop a plan using the logical statements described previously. The third step is constructing a logical control program is understanding that there is not always a right answer, meaning there are many different ways to ensure the same desired outcome.

    Worked out Examples 1, 2, and 3 demonstrate the construction of simple logical control programs. The more complex the situation, the longer the logical control plan becomes yet the process is still the same. An example of a more complex logical control program is given here.This example is from the 2005 ChE 466 class at the University of Michigan and describes an entire chemical process from the delivery of raw materials to the output of the final product.

    2.6 Determining Fail Safe Conditions

    Fail safe is the practice of designing a system to default to safe conditions if anything or everything goes wrong. The goals of fail safe conditions are to:

    • Protect plant personal
    • Protect the local community around the plant
    • Protect the environment
    • Protect plant equipment

    In order to establish safe conditions, fail safe programs must specify the desired positions of all valves and status of all motors and controlled equipment. For example, in an exothermic reactor, fail safe conditions would specify opening all cooling water valves, closing all feed valves, shutting off feed pump motors, turning on agitator motor, and open all vent valves.

    Control programs frequently define fail safe conditions at the beginning of the program. These conditions are then activated using a GO TO command when process conditions exceed the maximum or fall below the minimum allowable values.

    All processes must be evaluated for conditions that could cause hazards and fail safe procedure must be designed counteract the effects.

    2.7 Worked Out Example 1: Reboiler

    Disclaimer: This is a fictional example of an isolated unit operation, neglecting possible outcomes on the rest of the plant.

    Reboilers are used in industry to cool down process streams by creating steam from water. This chemical process involves a phase change from liquid (water) to gas (steam) and it is important to monitor flowrates, temperatures, and pressures. Below is a diagram of a reboiler. The controlled variables are F1, F2, and F3; these are controlled by manipulating the corresponding valves. The measured variables are P1, T1, and T2. Considering the operating conditions and constraints given below, write a logical control program for the reboiler.

    ontrol Logic EX1.JPG

    The operating constraints are as follows:

    • T1 must not exceed 350 ˚C
    • T2 must be between 100 and 200 ˚C
    • P1 cannot exceed 150 psi

    The normal operating conditions for the controlled variables are as follows:

    • F1 is 20 gal/min
    • F2 is 10 gal/min
    • F3 is closed

    Solution
    The first step is understanding the system to be controlled. Looking at the diagram, one can see that F1 controls the flow rate of the service water, F2 controls the flow rate of the process stream, and F3 controls the vent to the atmosphere. T1 is the temperature of the process stream entering the reboiler and T2 is the temperature of the process stream exiting the reboiler. P1 is the pressure inside the reboiler.
    Below is a possible control program to ensure the operating constraints are met; there may be other solutions to achieve the same objective:

    IF T2 > 200 ˚C, THEN F1 = 30 gal/min

    IF T2< 100 ˚C, THEN F1 = 10 gal/min

    IF P1 > 150 psi, THEN open F3

    IF T1 > 350 ˚C, THEN F2 = 2 gal/min

    In order to control the exit temperature of the process stream, one can increase or decrease the service water from the normal flow rate. Opening the vent to the atmosphere reduces the pressure if it reaches an unsafe value. If the entering temperature is too high for the process stream, reducing the entering flow rate will ensure the exit temperature is not too high for the remainder of the process. Note: reducing the process stream may negatively impact the rest of the plant.

    2.8 Worked out Example 2: Thermostat

    Chemical engineers are increasingly involved in biological applications. In many biological processes, temperature control can be very critical to the process. Take, for example, a simulated cell on a computer chip. Let's say that it is imperative for the chip to remain at 97oF ± 1oF, very similar to the temperature of the human body. Some of the reactions and processes on the chip will not function at temperatures outside this range and can become irreversibly damaged unless the power supply to the chip is turned off. The power is turned on and off by a switch S1. There are flows of cool water with an automatic valve V1 and warm water with an automatic valve V2 for cooling and heating purposes. The chip is attached to a thermostat to sense and control the temperature, T. Write out a controlled logic scheme to maintain the chip temperature and to prevent damage.

    Hint: Heat or cool the chip before reaching the limits (about half a degree)

    Solution

    To control the temperature, the chip must be heated or cooled depending on the environment

    IF (T<96.5) THEN V2 is open

    ELSE V2 is closed

    IF (T>97.5) THEN V1 is open

    ELSE V1 is closed

    The control is executed before the temperature limit is reached to allow for lag time in the heating or cooling water flow.

    Also, to ensure that the chip is not damaged, the power needs to be shut off if the temperature goes above 98oF or below 96oF

    WHILE (96<T<98) THEN S1 is on

    ELSE S1 is off

    2.9 Worked out Example 3: Chemical Reactor

    There is an exothermic chemical reaction occurring in a CSTR (Continuous Stirred Tank Reactor) that involves two reactants being fed at a 1:1 ratio. All valves are set to be 50% open normally. Write a control program that keeps the level in the CSTR vessel less than 8 meters (the tank is 10 meters tall) and the reactor temperature below 450 degrees Celsius.

    xample3.jpg

    Solution

    While L1 > 8 set V3 to 100% open and close V1 and V2

    Else set V1 and V2 and V3 to 50% open

    If T2 > 450 THEN set V5 and V4 to 100% open

    Else set V5 and V4 to 50% open

    This solution gives an example of using AND statements to control multiple valves with just one condition.

    2.10 Worked out Example 4: Programming and Alarms

    There is a process that is run by the P&ID shown below.

    xample4.jpg

    Based on this process and the steps listed below, write out a detailed control program for the process. Use comments (denoted with #) if necessary to explain the logic behind the steps.

    1. Measure Qw units of water into a tank
    2. Add Qc units of dried chickpeas
    3. Let dried chickpeas soak for 20 hours without mixing
    4. Drain off soaking water to waste (assume the filter in the tank will not allow whole chickpeas through the pump) 5) Add Qw units of fresh water to the tank.
    5. Heat the tank to Tcook and maintain the pressure at 4 atm. Note that your tank is rated to withstand pressures between 0.5 and 6 atm, while outside of that range the tank may implode or explode.
    6. Cook chickpeas for 20 minutes.
    7. After cooking, turn off heat and allow the system to return to ambient temperature (Tamb) and ambient pressure. Beware of a strong vacuum forming in the tank as the water vapor condenses!
    8. Drain cooking water to drain.
    9. Pump in Qs units of the tahini spice mix
    10. Blend the mixture for 10 minutes to produce a smooth hummus paste.
    11. Pump out product to packaging.
    12. Fill tank with clean water and agitate to clean the reactor.
    13. Pump wash water to drain.

    Solution

    FUNCTION INITIALIZE

    Turn off M1, M2, M3, M4
    Close V1, V2, V3, V5, V6, V7, SV1
    Set all timers to zero
    Set all totalizers to zero

    FUNCTION FAILSAFE

    Turn off M1, M2, M3, M4
    Close V1, V2, V3, V5, V7, SV1
    Open V6

    FUNCTION PROGRAM

    #Step 1 – Measure Qw unites of water into a tank

    Turn on M1
    Open V1
    WHILE FC1tot < Qw:

    Adjust V1 to FC1set

    IF LC1 < LC1min:

    ALARM

    Close V1

    Turn off M1

    #FC1tot is the total amount of fluid that has gone through the flow meter

    #FC1set is the set point (amount the valve is open) for V1 that FC1 has already programmed into it

    #LC1min is the minimum acceptable level of fluid in S001

    #Step 2 – Add Qc units of dried chickpeas

    Open SV1
    WHILE FC4 < Qc:

    Adjust SV1 to FC4set

    IF LC4 < LC4min:

    ALARM

    Close SV1

    #FC4set is the set point for SV1 that FC4 has already programmed into it

    #LC4min is the minimum acceptable level of fluid in S003. LC4 is not on the P&ID, however, it makes sense to have one on it so the level on the tank can be properly monitored

    #Step 3 – Let dried chickpeas soak for 20 hours without mixing

    WAIT 20 hours

    #Step 4 – Drain off soaking water to waste

    Open V7
    Turn on M3
    WHILE FC3tot < Qw:

    Adjust V7 to FC3set2

    Turn off M3

    Close V7

    #FC3tot is the total amount of fluid that has gone through the flow meter

    #FC3set2 is the set point for V7 that FC3 has already programmed into it

    #Step 5 – Add Qw units of fresh water to the tank

    Clear FC1tot
    Turn on M1
    Open V1
    WHILE FC1tot < Qw:

    Adjust V1 to FC1set

    IF LC1 < LC1min:

    ALARM

    Close V1

    Turn off M1

    #Step 6 – Heat the tank to Tcook and maintain the pressure at 4 atm.

    WHILE TC1 < Tcook:

    Adjust v5 to Tcook

    IF OR (PC1 < 0.5, PC1 > 6):

    GO TO FAILSAFE

    IF PC1 < PC1set:

    Close V6

    ELSE:

    Adjust V6 to PC1set

    IF LC3 > LC3max:

    GO TO FAILSAFE

    #PC1set is the setting that V6 must be set to for the tank to have 4 atm of pressure in it

    #LC3max is the maximum level that the contents of the tank are allowed to get to. Anything higher indicates a problem with one of the flow meters.

    #Step 7 – Cook chickpeas for 20 minutes#

    WAIT 20 minutes

    #Step 8 –After cooking, turn off heat and allow the system to return to ambient temperature and pressure

    IF PC1 > PC1amb:

    Adjust V6 to PC1set2

    IF OR (PC1 < 0.5, PC1 > 6):

    GO TO FAILSAFE

    WHILE TC1 > Tamb:

    Close V5

    #PC1amb is the ambient pressure of 1 atm that the system needs to get to

    #PC1set2 is the second setting on PC1 which effects how open V6 is

    #Step 9 – Drain cooking water to drain

    Clear FC3tot
    Open V7
    Turn on M3
    WHILE FC3tot < Qw:

    Adjust V7 to FC3set

    Turn off M3

    Close V7

    #Step 10 – Pump in Qs units of the Tahini spice mix

    Clear FC2tot
    Turn on M2
    Open V2
    WHILE FC2tot < Qs:

    Adjust V2 to FC2set

    IF LC2 < LC2min:

    ALARM

    Close V2

    Turn off M2

    #FC2tot is the total amount of fluid that has gone through the flow meter

    #FC2set is the set point for V2 that FC2 has already programmed into it

    #Step 11 – Blend the mixture for 10 minutes to produce a smooth hummus paste

    Turn on M4
    WAIT 10 minutes
    Turn off M4

    #Step 12 – Pump out product to packaging

    Open V3
    Turn on M3
    WHILE LC3 > 0:

    Adjust V3 to FC3set

    Turn off M3

    Close V3

    #FC3set is the set point for V3 that FC3 has already programmed into it

    #Step 13 – Fill tank with clean water and agitate to clean the reactor

    Turn on M1
    Open V1
    WHILE LC3 < LC3max:

    Adjust V1 to FC1set

    IF LC1 < LC1min:

    ALARM

    Close V1
    Turn off M3
    Turn on M4
    WAIT 10 minutes

    Turn off M4

    #Step 14 – Pump was water to drain

    Open V7
    Turn on M3
    WHILE LC3 > 0:

    Adjust V7 to FC3set2

    Turn off M3

    Close V7

    2.11 Worked Out Example 5: Another Chemical Reactor (taken from Prof. Barkel's 9/29/09 lecture)

    PEx5.jpg

    WRITING THE CONTROL PROGRAM

    Nomenclature:
    xA = input amount of A
    yB = input amount of B

    Readings:
    LL = low level
    LH = high level
    Lmax = maximum high level
    Lmax = maximum low level

    Things to note:
    Be sure to use If, Then statements.
    Lines in italics are comments used to organize the program.

    CONTROL PROGRAM

    Equal means within +/- 0.05 % of the value being held equal.

    Initialize This is used to set all control devices to the position you want them in.
    1. Turn off all valves
    2. Shut off all motors

    Fail Safe This is used to shut down the process in case something goes wrong and must be terminated immediately.
    1. Turn off all valves except V5, V7, V9, V6
    2. Shut off all motors except M2

    Universal Statements
    If T1>Tmax, then go Fail Safe.

    1. Initialize
    2. Open V6, V9, V1. [so that systems doesn't build up pressure]
    3. If L1>LL, then turn on M1. [fill with A]
    4. If L2>=Lag, turn on M2. [start stirrer]
    5. If F1>=xA, turn off V1, shut off M1. [stop flow of A]
    6. Open V5, V7. [allow for cooling]
    7. If P1>=PL, then open V2. [fill with B]
    8. If L4>=L4min, open V8, turn on M4. [release product AB]
    9. If L2<Lag, then shut off M2. [so motor doesn't run dry]
    10. If L4<L4L, close V8. [stop outflow of product AB]
    11. If T1><TH, then open V5. [cool reactor temperature]
    12. If T2><TH, then open V5. [cool upper product stream]
    13. If T1<<TL, then close V5. [stop cooling of reactor]
    14. If F2>=<yB, then turn off V2. [stop flow of B]
    15. Close V8, M4, leave V6, V9 open. [shut down process but allow it to vent]
    16. Pump out BAB.

    2.12 Worked Out Example 6

    ontrol Logic Example.jpg

    A + B --> AB

    The reaction is exothermic
    A, B, AB are all liquids
    It goes to 100% completion
    XA = total amount of A used
    YB = total amount of B used

    B is added slowly into a full charge of A
    The temperature is maintained at TR
    Upon completion of the reaction, the AB is cooled to TP
    ZC, an amount of solvent C is added to the AB to make the final product

    Using only the equipment and instrumentation shown, write the control logic for this BATCH reaction. Use If, Then logic.

    Use of subscripts:
    Ag for agitator
    L for low-bottom of control range
    H for high-top of control range
    Min for minimum - lowest level allowed
    Max for maximum - highest level allowed
    tot for totalizer

    Process Control Logic

    • Equal means within +/- 0.05% of the value being held equal.

    1) Initialize

    Shut all valves
    Turn off all motors
    Set all FCtot = 0

    2) Fail safe

    Shut off V1, V2, V3, V4
    Open V5
    Turn off M1, M2, M3
    Turn off M4, Open V4
    Turn on M5 if LC4>Lag, else turn off M5

    3) If T1>Tmax, then go Fail Safe
    4) If L2>L2min, then turn on M2, open V2
    5) If L2<L2min, then turn off M2, shut off V2
    6) If FC2tot = XA, then turn off M2, shut off V2
    7) If L4>Lag, then turn on M5
    8) If L1>L1max, then go Fail Safe
    9) If L1>L1min, then turn on M1, open V1
    10) If L1<L1min,then turn off M1, shut off V1
    11) If FC1tot = YB, then turn off M1, shut off V1
    12) If T1>T1H, then open V5
    13) If T1<T1L, then close V5
    14) If L4>L4H, then close V1, turn off M1
    15) If T1>TP, then open V5
    16) If T1=TP, then close V5
    17) If L3>L3min, then turn on M3, open V3
    18) If L3<L3min, then turn off M3, shut off V3
    19) If FC3tot = ZC, then turn off M3, shut off V3
    20) If LC4<Lag, then turn off M5
    21) Open V4
    22) Turn on M4
    23) If L4<L4min, then turn off M4, shut off V4

    2.13 Sage's Corner

    Narrated Presentation of Example 1

    video.google.com/googleplayer...88046317469856

    Narrated Presentation of Example 2

    video.google.com/googleplayer...31730278014126

    Media:LogicalControlsProgram9122007.ppt

    Media:ProcessLogicN.ppt

    2.14 References

    • Savitch, Walter. "Problem Solving with C++ The Object of Programing". Boston: Pearson Education, Inc. 2005.
    • Stanford Encyclopedia of Philosophy
    • Woolf, Peter. "Possible Useful Notes", Notes for Boolean Logic, September 22, 2005.
    • Woolf, Peter. "Project 1 Sample Solution", October 6, 2005.
    • Woolf, Peter. "Useful Definitions", Terms Review, October 11, 2005.