4. PID control on TCLab

This notebook and the associated pidgui.py allows you to play with a very basic position form discrete PID using either a modelled version or the real Temperature control lab.

from tclab.gui import NotebookUI
from pidgui import PIDGUI
%matplotlib notebook
interface = NotebookUI(PIDGUI)
TCLab version 0.4.9dev
Simulated TCLab

5. Programmatic interaction

We can interact with the interface while it is running. The controller is in the interface. Note that you will have to start the controller and switch to auto to see the effect of these cells:

controller = interface.controller
controller.pid.eint = 0
[ ]:
controller.setpoint.value = 42

6. Advanced usage

Below we set up an experiment which will change the setpoint and increase the gain every 10 minutes.

[ ]:
import tornado

def stepgain():
    if controller.setpoint.value == 45:
        controller.setpoint.value = 40
        controller.setpoint.value = 45
    controller.gain.value *= 1.1
    if controller.gain.value > 100:

minute = 60*1000  # a minute in milliseconds
steptimer = tornado.ioloop.PeriodicCallback(stepgain, 10*minute)


You can stop the timer by calling .stop()

[ ]:

7. Accessing the historian

The interface contains a historian. You can see the sessions it has stored like this:

[ ]:

You can roll the historian back to a session by using load_session. Note you shouldn’t do this while the interface is connected.

[ ]:

8. More detailed analysis

We can analyse the results of the experiments we have made using Pandas:

[ ]:
import pandas
[ ]:
allresults = pandas.DataFrame.from_records(interface.historian.log, columns=interface.historian.columns, index='Time')