TCLab Overview

The tclab package provides a set of Python tools for interfacing with the BYU Temperature Control Laboratory. The Temperature Control Laboratory consists of two heaters and two temperature sensors mounted on an Arduino microcontroller board. Together, the tclab package and the Temperature Control Laboratory provide a low-cost experimental platform for implementing algorithms commonly used for process control.

image0

TCLab Architecture

The tclab package is intended to be used as a teaching tool. The package provides high-level access to sensors, heaters, a pseudo-realtime clock. The package includes the following Python classes and functions:

  • TCLab() providing access to the Temperature Control Laboratory hardware.
  • TCLabModel() providing access to a simulation of the Temperature Control Laboratory hardware.
  • clock for synchronizing with a real time clock.
  • Historian for data logging.
  • Plotter for realtime plotting.

image0

Using these Python tools, students can create Jupyter notebooks and python codes covering a wide range of topics in process control.

  • tclab.py: A Python package providing high-level access to sensors, heaters, a pseudo-realtime clock. The package includes TCLab() providing access to the device, clock for synchronizing with a real time clock, Historian for data logging, and Plotter for realtime plotting.
  • TCLab-sketch.ino: Firmware for the intrisically safe operation of the Arduino board and shield. The sketch is available at https://github.com/jckantor/TCLab-sketch.
  • Arduino: Hardware platform for the Temperature Control Laboratory. TCLab is compatiable with Arduino Uno, Arduino Leonardo, and compatible clones.

Getting Started

Installation

Install using

pip install tclab

To upgrade an existing installation, use the command

pip install tclab --upgrade

The development version contains new features, but may be less stable. To install the development version use the command

pip install --upgrade https://github.com/jckantor/TCLab/archive/development.zip

Hardware Setup

  1. Plug a compatible Arduino device (UNO, Leonardo, NHduino) with the lab attached into your computer via the USB connection. Plug the DC power adapter into the wall.
  2. (optional) Install Arduino Drivers.

If you are using Windows 10, the Arduino board should connect without additional drivers required.

Mac OS X users may need to install a serial driver. For Arduino clones using the CH340G, CH34G or CH34X chipset, a suitable driver can be found here or here.

  1. (optional) Install Arduino Firmware;

TCLab requires the one-time installation of custom firmware on an Arduino device. If it hasn’t been pre-installed, the necessary firmware and instructions are available from the TCLab-Sketch repository.

Checking that everything works

Execute the following code

import tclab
with tclab.TCLab() as lab:
    print(lab.T1)

If everything has worked, you should see the following output message

Connecting to TCLab
TCLab Firmware Version 1.2.1 on NHduino connected to port XXXX
21.54
TCLab disconnected successfully.

The number returned is the temperature of sensor T1 in °C.

Next Steps

The notebook directory provides examples on how to use the TCLab module. The latest documentation is available at Read the Docs.

Course Web Sites

More information, instructional videos, and Jupyter notebook examples are available at the following course websites.