Team:UPF Barcelona/Software


This section describes, on the one hand, the computer program that will control the administration of levothyroxine (related to Hormonic T3 biosensor) and, on the other hand, the software behind our turbidostat (related to the proof of concept).


When it comes to closing the hormonal feedback loop that is altered by hypothyroidism, it is clear that robust control over hormone secretion must be exerted. In order to do so, physiological aspects such as circadian rhythms are considered, together with delayed metabolic responses.

So as to validate the capacity of this control system to regulate hormonal levels, it was essential to design a Proof of Concept, which involved a Turbidostat capable of maintaining culture-growth conditions along time. However, this tool aims to facilitate extended reproducible in-vitro measurements to all iGEMers and is intended to be further developed and embed into several other measurement systems such as fluorescence quantification mechanisms. For that purpose, the designed code includes several tips on how they can be used and edited, and is accessible to the whole iGEM community.

All in all, the use of an intuitive software that incorporates a user-friendly interface was developed: a software that showed the ability to keep a constant Optical Density (OD) and temperature. Furthermore, in order to meet the specifications that each of these regulations required, an exhaustive research of control systems and their characteristics was carried out.

Related to the controlled administration of levothyroxine

Let's start with the software module that will control the administration of levothyroxine!

PID controller

How can we determine and regulate a correct dosification depending on the measured hormonal level at each time step? The majority of control systems (90%) make use of Proportional-Integral-Derivative (PID) controllers [2]: regulation mechanisms that aim to maintain a system at a steady state by the use of feedback loops. The main advantages of this control tool are its great static performance and elimination of the steady state error [2], which ensure no deviations from the setpoint when the hormonal-level tracking procedure reaches equilibrium (see Fig. 2). Therefore, these features are crucial for hormonal imbalance correction, since we can guarantee a correct levothyroxine administration that does not exceed its narrow effective range.

This control mechanism is intended to continuously compute an error e(t) as the difference between the desired hormonal level r(t) and the measured one y(t) , in order to later apply a correction action u(t) that compensates for that deviation: a levothyroxine injection that will be metabolized into T3 hormone (see Figure 1).

Figure 1: General schematic showing the application of the PID controller in Hormonic.

The previously mentioned correction action will compensate for the error depending on proportional, integrative and derivative constants, which can be tuned so that the tracking of the hormonal level is optimal. For the system’s response to be considered appropriate (see Fig. 2), the overshoot should be minimal (as to not cause hyperthyroidism to the patient), the rise-time should be large enough (as to not exceed the maximum levothyroxine injection rate), the settling-time should be the shortest possible; and the steady-state error should be null (as to ensure an accurate hormonal-level tracking). Therefore, each of the PID’s parameters should be tuned according to their effect on the system’s response (see Fig. 3).

Figure 2: Graph showing the PID response.

Figure 3: Table of the PID controller constants.

Modeling the system response

In order to perform the parameter optimization procedure, the system response should be modeled. This could show how the system would act in relation to a given input, or in other words, how the body would react to a given levothyroxine injection. However, the dynamics that play a role in the metabolization of levothyroxine into T3 are still unclear.

Physiology related considerations

Apart from the system’s characterization, several considerations must be taken into account when implementing this control:

Circadian Rhythms

The reference value to which the measurements are compared is usually set at a fixed value. However, hormones tend to follow a circadian rhythm and, although it has not been yet characterized, experts such as the head of the thyroid department within the Spanish Endocrinology and Nutrition Association, Dc. Carles Zafon, have reasons to believe that thyroid hormones follow a temporal pattern of their own. Indeed, once again, this could be identified by the use of Hormonic, by monitoring the levels of T3 hormone of a healthy individual along time. The characterized temporal pattern could then be set as the reference value of the PID, so that the target value of the controller is not constant throughout the day but changes the same way it does physiologically.

Delayed Response

On top of that, it must be taken into account that the half life of levothyroxine is large and its metabolization into T3 slow, resulting in a long process that generates a delay. Consequently, it must be ensured that enough time is waited between measurements so that the registered values reflect the total effect of the previous injection, and not just partial. The uncontrolled continuous injection of diluted levothyroxine is quite risky: it could lead to hyperthyroidism! Therefore, the biosensor should take discrete measurements and the rate of injection must never exceed the defined maximum rate of 100 mcg per minute [4].

Related to our turbidostat

Let's continue with the software module of our turbidostat!

The turbidostat is controlled by the use of the open-source programming tool Node-Red, a browser based editor that uses a wide range of interconnected nodes to pursue several functions. The Firmata Library, which can be found within the Examples section of the Arduino software, enables the communication between the Arduino Microcontroller and the Node-Red software of the host computer.

Figure 4: Node-Red software connected to Arduino microcontroller.

Temperature control

The first variable to be controlled is the temperature at which the cell-culture's medium is, due to its direct effect on cellular growth. To do so, a PID controller is implemented.

This PID controller governs a heating and cooling process that aims to maintain the system at a steady temperature. In order to do so, it continuously computes an error value as the difference between the desired temperature and the measured one and applies a correction action, which in this case is turning the heating resistors on or off. As explained at the previous section, the proportional, integral and derivative terms can be empirically tuned in order to get the optimistic response.

Figure 5: Schematic showing the temperature PID controller of our turbidostat.

The PID controller’s ability to correctly respond to a certain hormonal-level, relies on its capacity to compute the error between the measured value (analog value given by the temperature sensor at the surface of the aluminum tube) and the desired value (defined as the cell-culture medium’s temperature setpoint). In order to be able to compare them, an equivalence must be established between these parameters, which can be obtained through the temperature calibration process. (see temperature calibration document in Contribution page). Once the equivalence is characterized, the inverse relation is applied to the temperature setpoint, so as to obtain the analog value the temperature sensor should read when the inner temperature reaches the reference value. Now, the PID can compute the proper correction action depending on the difference between the temperature that is being measured and the one that should be measured if the medium were to be at the temperature setpoint.

Optical Density control

The density of cells in liquid culture can be regulated by the use of the bang-bang control method, which switches continuously between two states, either On or Off.

For this method, when the measured OD value y(t) exceeds a certain threshold r(t), the control action u(t) is taken: the controller is in its On state. However, if y(t) is under the threshold, no control action is taken: the controller is in its Off state.

The corresponding control action is characterized by a dilution process that aims to lower the cell density via small LB injections. However, in order to preserve the total volume and not exceed the vial’s capacity, a complementary control volume is exerted. Therefore, if the defined OD is exceeded, the LB injecting pump is actioned, followed by the waste extracting pump. The amount of time during which the pumps are activated is defined by a pump calibration process (see pumping system calibration document in Contribution page).

Figure 6: Schematic showing the OD PID controller of our turbidostat.

The desired OD value will be set as the threshold and, so that it is possible to compare it to the analog value given by the photodiode, the equivalence between both terms is found. The transfer function, which defines that relationship, is acquired by the realization of an OD calibration process (see OD calibration document in Contribution page).

Software flow

The open-source programming tool Node-Red includes the dashboard library: a module that provides an iterative live data interface. It allows real time control of the turbidostat’s parameters and outcomes in a truly intuitive way for the user.

The interface is divided into three main columns:

Global control
OD regulation
Temperature stabilization

Global control of the turbidostat

It includes three main buttons:

The setup button is pressed at the beginning in order to fill the tubes that will later add LB to the medium and also to control the total volume so that it does not exceed the vial’s capacity.
The launch button must be pressed after the initial setpoint values for the temperature and OD are defined. Its activation causes a cascade of events that results in the stabilization of those parameters.
The stop button acts as an emergency switch that immediately interrupts the turbidostat’s activity. If pressed and no volume adjustment is needed, no setup is needed to resume the activity.

Figure 7: Node-Red interface adapted to Hormonic turbidostat.

Note that any of the components involved in the OD or temperature control can be turned on or off by the use of the various switches. Also note that all the OD and temperature values will be saved in excel documents.


[1] The Effects of Temperature and Atmospheric Perturbation During Cell Culture: The Silent Variables. (n.d.). Retrieved October 17, 2020, from

[2] Chen, S., Zhao, J., & Qian, J. (2007). A Design Method of Bang-Bang and PID Integrated Controller Based on Rough Set. Fourth International Conference on Fuzzy Systems and Knowledge Discovery (FSKD 2007). doi:10.1109/fskd.2007.17

[3] Li, J., & Johnson, J. D. (2009). MATHEMATICAL MODELS OF SUBCUTANEOUS INJECTION OF INSULIN ANALOGUES: A MINI-REVIEW. Discrete and continuous dynamical systems. Series B, 12(2), 401–414.

[4] PDR Search. (n.d.). Retrieved October 17, 2020, from