Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

18/1/2020 TCLab On/Off Control

OPTIONS:

Dynamics and Control view edit history print

home syllabus schedule

Main

TCLab On/Off Control SEARCH


Go
Objective: Generate data from an On/Off controller and determine the parameters
of a 2nd order underdamped model that best fits the response.

On/off control is used in most cooling and heating applications where the actuator
can only be On or Off. Run the temperature control lab with On/Off control for 4
minutes to reach a setpoint of 40oC.
COURSE INFORMATION
On/Off Control (4 min)
Course Overview
import tclab
import time Syllabus
a = tclab.TCLab() # connect to TCLab Schedule
fid = open('data.csv','w')
fid.write('Time,Q1,T1\n') Competencies
fid.write('0,0,'+str(a.T1)+'\n')
fid.close() Info Sheet
for i in range(240):  # 4 minute test Video Playlist
    time.sleep(1)
    T1 = a.T1 # temperature
    Q1 = 100 if T1<=40.0 else 0 # On/Off Control
    a.Q1(Q1) # set heater ASSIGNMENTS
    print('Time: '+str(i)+' Q1: '+str(Q1)+' T1 (SP=40): '+str(T1))
    fid = open('data.csv','a')
    fid.write(str(i)+','+str(Q1)+','+str(T1)+'\n')
    fid.close() PROJECTS
a.close()
[$[Get Code]] Lab: Temperature Control
Generate Plot Project: Process Control

import matplotlib.pyplot as plt


import pandas as pd EXAMS
data = pd.read_csv('data.csv')
plt.figure(figsize=(10,7)) 1 - Dynamic Modeling
ax=plt.subplot(2,1,1); ax.grid()
plt.plot(data['Time'],data['Q1'],'b-',label=r'$Q_1$ (%)') 2 - Closed Loop Control
plt.legend(); plt.ylabel('Heater')
ax=plt.subplot(2,1,2); ax.grid() 3 - System Analysis
plt.plot(data['Time'],data['T1'],'r-',label=r'$T_1$ $(^oC)$') Final Exam
plt.legend(); plt.xlabel('Time (sec)'); plt.ylabel('Temperature')
plt.show()
[$[Get Code]]
DYNAMIC MODELING
Use a graphical method to fit a 2nd order model to the closed-loop response by
finding Kp , ζ , and τs . Dead-time θp is not needed for this model. Introduction
Solve with ODEINT
2
d T1 dT1 Balance Equations
2
τs + 2ζ τ s + T1 = Kp Q1
2 Linearization
dt dt
First Order
Follow the steps to obtain a graphical approximation of a step response of the Time Delay
underdamped (oscillating) second order system. An underdamped system implies FOPDT Graphical Fit
that 0 ≥ ζ > 1.
FOPDT Optimization Fit
1. Find ΔT1 from step response. Laplace Transforms
Transfer Functions
2. Find ΔTS P as the input to the step response.
State Space
ΔT1
Second Order
3. Calculate Kp = .
ΔTS P SOPDT Graphical Fit
4. Calculate damping factor ζ from overshoot OS or decay ratio DR.
SOPDT Optimization Fit
Simulate TF, SS, ODE
5. Calculate τs from equations for rise time tr , peak time tp , or period P

.
EQUIPMENT DESIGN
Data Acquisition
Sensors and Signals
Valve Design

CONTROL DESIGN
Introduction
P-only

https://apmonitor.com/pdc/index.php/Main/TCLabOnOffControl 1/3
18/1/2020 TCLab On/Off Control
PI
PID
Stability Analysis
Cascade Control
Feedforward Control

OPTIMAL CONTROL
Optimization Intro
Linear Programming
Nonlinear Programming
Refinery Optimization
Model Predictive Control

RELATED COURSES
Computational Tools
Dynamics & Control
Add the underdamped (0 ≤ ζ < 1) analytic solution to data plot to compare the Optimization
graphical fit to the data. See Second Order Systems for additional information on Dynamic Optimization
analytic solutions.
Admin

t ζ t
′ −ζ t/τs 2 2
T (t) = Kp ΔTS P (1 − e [cos( √1 − ζ ) + sin( √1 − ζ )])
1
τs √1 − ζ 2 τs

Solution

TCLab Arduino On / Off Heater Control

1. Find ΔT 1 from step response.

The temperature starts at 20oC and has an average final value above the
setpoint (40oC) at 41oC. The change in temperature is 21oC.

2. Find ΔT SP as the input of the step response.

The heater setpoint changes from 20 to 40oC.

ΔT 1
3. Calculate Kp = .
ΔT SP

https://apmonitor.com/pdc/index.php/Main/TCLabOnOffControl 2/3
18/1/2020 TCLab On/Off Control

Kp = 21/20 = 1.05oC/oC.

4. Calculate damping factor ζ from overshoot OS or decay ratio DR.

The overshoot (OS) ratio is (44-41)/(41-20) = 0.143.

 2
 (ln(OS))

ζ = = 0.527
⎷ 2
2
π + (ln(OS))

5. Calculate τs from the equation peak time tp .

√1 − ζ 2
τs = tp = 23.2
π

import matplotlib.pyplot as plt


import pandas as pd
import numpy as np
data = pd.read_csv('data.csv')
# graphical fit
Delta_SP = 20
Delta_T1 = 21
OS = (44-41)/(41-20)
tp = 86.0
Kp = Delta_T1/Delta_SP
lnOS2 = (np.log(OS))**2
zeta = np.sqrt(lnOS2/(np.pi**2+lnOS2))
taus = tp * np.sqrt(1-zeta**2)/np.pi
print('Kp: ' + str(Kp))
print('zeta: ' + str(zeta))
print('taus: ' + str(taus))
# analytic solution
t = data['Time'].values
T0 = data['T1'].values[0]
a = np.sqrt(1-zeta**2)
b = t/taus
c = np.cos(a*b)
d = (zeta/a)*np.sin(a*b)
T1 = Kp*Delta_SP*(1-np.exp(-zeta*b)*(c+d))+T0
plt.figure(figsize=(10,7))
ax=plt.subplot(2,1,1); ax.grid()
plt.plot(data['Time'],data['Q1'],'b-',label=r'$Q_1$ (%)')
plt.legend(); plt.ylabel('Heater')
ax=plt.subplot(2,1,2); ax.grid()
plt.plot(data['Time'],data['T1'],'r-',label=r'$T_1$ Meas $(^oC)$')
plt.plot(t,T1,'k:',label=r'$T_1$ Pred $(^oC)$')
plt.legend(); plt.xlabel('Time (sec)'); plt.ylabel('Temperature')
plt.show()
[$[Get Code]]

Page last modified on November 05, 2019, at 05:58 AM

https://apmonitor.com/pdc/index.php/Main/TCLabOnOffControl 3/3

You might also like