CS333 Lab P1-1:
Process Control

Goals of this lab:

Introduction:

The purpose of a process control application is to monitor and influence the progress of chemical or physical processes, usually in an industrial setting. For example, process control programs are used in chemical plants, oil refineries, nuclear reactors, and other situations where complex processes must be managed. The process is managed through a feedback loop that starts with sensors that monitor conditions (such as temperature) in the ongoing process. On the basis of readings from the sensors, a control program determines new settings for actuators that control devices (such as burners and valves) that affect the ongoing process, thus causing the readings to change at the sensors, and so on. In practice, there are usually human operators, and the process control programs are used to assist them. In very critical applications, such as a nuclear reactor, timing can be an important safety consideration. In such applications, it is necessary to satisfy real-time constraints in the software.

When the sensors and actuators are attached to processors on a network, process control becomes a distributed application. Playground does not have real-time support for process control applications, but we can still explore the distributed process control paradigm in an application where timing is not quite so critical. In this lab, you will construct a distributed application to simulate, monitor and control a syrup factory. (Note: This syrup factory example is discussed in one of the research papers Playground. You will benefit most from this assignment if you do it on your own. Please do not look at that paper while you do this assignment.)

Directions:

Read over the entire assignment before starting. Then, follow the instructions. Note that the modules can be constructed in any order. You may want to write the FACTORY module and then construct your user-interface before proceeding with the CONTROL module.

  1. Look at some example modules: In Lab 1, you constructed some simple distributed applications by creating logical connections among several provided modules (counter, consumer, square, etc.). Go back to Step 3 of Lab T-1, where you can reread a description of each module and explore text links to view the C++ code associated with each module. You will notice that Playground modules look essentially like ordinary C++ programs, except that some of the variables are published for external use.

  2. Write the FACTORY module: With the help of the Plagyround Manual and the examples from Lab 1, create a module called 'FACTORY' that simulates the process of concentrating maple syrup by boiling it. In abstract terms, the factory has a pipe with a valve that allows Maple sap to flow into a vat that is heated by a burner. As the temperature increases, water is evaporated out of the sap and the concentration increases.

    Your module should have three presentation items as output: the temperature of the liquid, the volume of the liquid, and the concentration of the liquid. These are initially 25C (room temperature), 0 liters, and 1.0 respectively. In addition, you will have two input presentation items: the height of the burner flame, in the range 0 (off) to 40.0 (full blast), and the status of the valve, in the range 0 to 20.0 liters per second. (Use PGreal variables for all of your published variables in this assignment.)

    Your module will simulate, in a loop, small increments of simulated time. Once each second, it will adjust the temperature, volume, and concentration according to the current conditions. (See the counter module from Lab T-1 for an example of how to write a loop that performs a computation once each second.)

    If the flame is on, the temperature will go up some amount in proportion to the height of the flame and in inverse proportion to the volume. If the flame is off and the liquid is above room temperature, then the liquid will cool slightly, depending on volume and current temperature. The volume will change depending on how much sap is coming into the vat through the valve and on how much water is evaporating due to the temperature of the liquid. The vat holds up to 150 liters of liquid before it overflows. Evaporation begins when the temperature reaches 90 degrees C. The concentration can be computed as the total liquid added to the vat divided by the current volume. The simulation should not stop until the concentration reaches at least 40.0 and the liquid has cooled to room temperature. It's up to you to decide how accurate the physics of your simulation will be. For example, you may want evaporation to be more rapid at lower concentrations.

    HINTS: First write separate procedures to compute the new values of temperature, volume and concentration, given the old values and the current conditions of the burner and valve. Then put these into a loop whose termination condition is based on the concentration and the temperature. You may want to use EUPHORIA to test your module. Also, modules like the consumer and constant modules from Lab 1 may come in handy.

  3. Compile the FACTORY module: To compile a Playground module into an executable, put your .cc and .hh files into a directory that you will use only for that module. Then copy /home/cec/class/cs333/makefiles/Makefile into that directory and modify it as described in the header comments.

  4. Write the CONTROL module: Write another Playground module that is the process control program. It should have the same five presentation items as the FACTORY module, except that the inputs and outputs are switched. That is, the CONTROL module should determine new values for the valve and the burner on the basis of the current temperature, volume, and concentration. The CONTROL module should have two additional input values, the setpoints for the temperature and the volume. The control module should try to keep the temperature and volume within 10 percent of these setpoints. The target concentration should be 40.0. You certainly don't want the liquid to overflow the tank or boil dry and burn! Compile your CONTROL module as you did for the FACTORY module.

  5. Draw a user-interface: Use EUPHORIA to construct a user-interface to display the status of the syrup factory and to adjust the temperature and volume setpoints. You should draw the vat, the liquid in the vat, the burner, the pipe, a thermometer, and a bar to indicate the concentration. Publish the appropriate attributes so they can be connected to other modules.

  6. Configure and debug your distributed application: Once the modules are ready, you can connect them together in the connection manager and test your application thoroughly. As much as possible, try to test each module in isolation first.

To receive credit for this lab, you should:

  1. Clean up and print out your code. (Don't turn it in, but save it for your code/design review.)

  2. Turn in a Project Evaluation Form near the beginning of class on the day you want to do your demonstration and code/design review. You should be prepared to demonstrate your working application, explain your design and code, and answer questions.