Cool plate logic |
The control system consists of a raspberry pi microcomputer (rpi), which handles the programming and communication, and a board supporting the electronic circuits for measuring temperatures, and for driving the solenoid valves and the heater.
The rpi runs its standard operating system (OS), raspbian, which is derived from the long established and widely used debian linux OS. In addition to the components which come with the standard operating system, the rpi has some extra programs, installed from the raspbian program repository. An apache2 web server is installed with the mod_python module to allow interpretation of the interactive web pages, which are written in the python language. A few other helper programs are also installed from the raspbian repository: mc is a text based file browser for navigating the rpi software at a low level. screen is a text based program which allows remote connection to the rpi, even connecting to programs started by someone else from a different computer. gnuplot is used to make the graph of the temperature which is displayed on the web page. The design aim is to keep as closely as possible to standard and widely used programs to minimise the maintenance burden. Raspbian, like all linux versions, is easy to keep up to date.
In addition to the screen and keyboard provided with the cool plate, it can also be reached through both ethernet and wireless connections to the local area network, and also to the internet, if the local administrator allows this.
The rpi is a low power device which cannot directly control current-hungry devices like solenoid valves, so separate drivers are required to take a low power signal from the rpi and convert it through solid state relays to robust power to the two solenoid valves. Drivers are also needed to start the cooling unit and to control the heater.
Separate circuits are needed to convert the temperature signal from the platinum resistance thermometers into a digital signal which the rpi can understand. All these services are collected onto a single circuit board, shown below.
The control box also has power supplies for these various devices. 6 V for the solenoids and heater driver, 5 V for the rpi and for the driver components. The wiring diagram is in a pdf file. This is the only part which has to be specially made for this apparatus. All other components just need to be connected, by wire or by tubing.
The control program is started automatically when power is applied to the rpi. The web server, and the local browser are also started automatically. The browser requires a password before displaying the control page, which shows a form for entering the conditions for the run.
Operating the cool plate is done by writing instructions to a single web page, which also displays the temperature history graphically and through log files. One can enter instructions at the cool plate, or remotely from another computer or from a mobile phone or a tablet. In normal use one needs no knowledge of what is going on behind the web page.
When the operating conditions, such as average temperature, cycle span, cycle length and type, and other variables, have been entered into the web page, the operator presses update. The instructions are despatched to the web server. Here, the form variables are first tested for validity, then written to a text file in another branch of the file system away from the web server area. The controlling program, which is always running and alert, reads this text file every minute and notices and acts upon changes to the operating instructions.
The desired temperature, only, can also be sent automatically to the server without human intervention, from an entirely separate data logger or computer, which may be controlling the experiment. For this to work, the cycle amplitude must be set to zero.
The rpi runs a single program, written in python. The complete program and website scripts are in a tar file (the standard bundling format for unix files).
The program has a sixty second cycle (adjustable within the script). It first writes out the data for the elapsed cycle: temperatures plus various diagnostic values. Then it measures the current temperatures.
These are measured by five small circuit boards which have the sole duty to measure platinum resistance temperature sensors and convert the value to a digital signal, which is fed to pins on the rpi. The transmission of the digital values is by the SPI protocol, a widely used method for connecting sensors to computers.
The program calculates the target temperature for the next minute. It then uses the target value, the past and the present measured values to calculate how many seconds of heating or cooling to apply to steer the temperature towards the target. For this, it uses a software calculation to predict the rate of change and thus avoid a sawtooth variation in temperature. This is called a PID controller (Proportional - Integral - Differential)
Particular pins on the rpi are raised to 3.3 volts to energise relays which operate the heater, the cooling valve and the bypass valve (described in the plumbing section).
All normal operations can be performed through the browser but sometimes one needs to dive a bit deeper into the rpi, if something does not work as you expect.
Sometimes, the program may shut down unexpectedly. The simplest way to recover from this is to restart the rpi. This can be done from the touch screen or remotely (but don't halt the rpi remotely: you cannot then start it again).
To get full control of the rpi you need to open up a terminal, that is the black square on the top menu line on the touch screen. This drops you into the command line universe of the linux operating system. The various commands are outside the scope of this instruction set, but you need to know the location of the various files that run the cool plate.
The web pages are at /var/www/coolplate/public_html/
The program files and log files are at /home/pi/coolplate-programs/
The web server configuration files are at /etc/apache2/
The only unusual detail is that the web server delivers the web pages through a module called mod_python. This interprets the web page as a python script and provides the user interaction with the forms on the page.
The web server is visible on the internet, if the IT manager allows it. Operation is the same as if you were at the cool plate touch screen.
There is however, no way of closing down the rpi remotely, through the browser. For this one has to gain access to the terminal on the rpi. This is done by connecting through ssh - a secure communication method between computers. The command is ssh pi@ipnumber where ipnumber is given by the network administrator. The password is the same as the web page password.
The main control program runs under a master program called 'screen'. This allows access from a remote computer, even a different one from which the current run was started. To get remote control of the running program, type screen -r after logging in. If this does not work screen -x probably will. Instructions for the screen program are on the internet.
Some experiments will require that the experiment itself alters the temperature, without a human operator being involved. For this the experiment control device, a datalogger or a microcomputer, requests a webpage whose URL includes a 'GET' request. The new temperature is checked for validity in the same way as the human defined temperature.