You are on page 1of 6

EE 370L

Control Systems Lab


Process Control
Text: Process Control
Kit: Process Control, Homework Board or BOE
The kits for the lab in EE 370L are available from the following site:
https://www.parallax.com/product/81022

These kits contain the process control parts.

You need to get the Homework Board separately.

The kits come with a serial cable. If your computer only has a USB port (no serial port)
you need a serial to USB converter cable. Make sure you buy one from the Parallax site
to make sure it is compatible and works. Also, you can power the Homework Board using
a 9 Volt battery. That is OK for half of the labs. When you reach the heat experiments,
you will need power supplies otherwise you will go through several batteries (costing you
more than a power supply $10). So please consider purchasing an appropriate power
supply (DC output 10-20 Volts and 500-800 mA is OK).
Down load link for Text and Kit:
http://www.parallax.com/Store/Education/KitsandBoards/tabid/182/ProductID/318/List/1
/Default.aspx?SortField=ProductName,ProductName
Grading: Lab assignments and attendance. You get 10 points for each lab. Unexcused
absence gives you (-1) point.
Lab #1: Introduction to Parallax BASIC Stamp
1. Down load Parallax BASIC Stamp Tutorial pdf document from here:
www.ecst.csuchico.edu/~juliano/csci224/Slides/bs2Tutorial.pdf
2. Read the tutorial and build a simple circuit to blink an LED when a switch is
pressed. Prepare a report and demo your circuit during the lab. The reports
should have a Cover Page with your name, course number and section, Date,
Instructor name, and Lab number. All labs will include programs and circuits,
you should always include programs (with your name as a comment) and a

circuit diagram. Later on you will have graphs, tables of data, analysis, Matlab
output and Simulink diagrams.
For the first lab, turn in your code and circuit diagram, even if your equipment
is not ready yet. Lab report is due at the start of the next lab meeting.
3. Down load Whats a Microcontroller? pdf document from link below and
study chapter 1 for Lab #2 next week.
http://www.parallax.com/dl/docs/books/edu/wamv2_1.pdf
Lab #2: Purpose of this lab is to become familiar with basic flow charting and
programming in Parallax BASIC Stamp. From Process Control text book:
1. Do all the Challenges in Chapter 1 through Challenge 1-5. You will be given a
problem to build by the instructor.
Lab#3: The purpose of this lab is to become familiar with the Parallax Basic Stamp Plot
program. From Process Control text book:
1. Do Challenge 2-1 and Activity 2. In all cases include the code, circuit
diagrams, and be ready to demo to the instructor.

Lab#4: The Purpose of this lab is to become familiar with Digital Inputs such as
mechanical and electronic switches and their various configurations. The book has a very
good and extensive discussion on transistors and their use as digital switches. From
Process Control text books chapter 3:
1. Do Activity 1, 2, 3, 4, 5, 6. Build all activities and record all results
2. Do Challenge 3-2 (Demo) , 3-3, 3-5 (Demo), 3-6
Lab #5: From Process Control text book:
1. Read Chapter 4 and do Activity 1, Challenge 4.1 and Activity 6
Lab #6: This Lab is about PWM which is a way to actuate motors and other devices. It
is a very popular method and this whole lab is very important. The activities begin by
letting you manually do PWM by switching the fan on and off. It then moves on to the
Stamp's PWM command, and discusses many issues related to PWM. We will use PWM
to generate heat later on. From Process Control text book:

1.
2.
3.
4.
5.

Read Chapter 5,
Do and demo Challenge 5-1,
Do Activity 2 and get graphs 5-7, 8, 9.
Do and demo challenge 5-2.
Do Activity 3 and get graphs 5-12 and 13.

Lab #7: From chapter 5 of Process Control text book:


1.
2.
3.
4.
5.
6.
7.

Do Activity 4 and 5,
Do and demo Challenge 5-5,
Do Activity 6 and demo Challenge 5-6.
Read Chap 6
Do Activity 1 and plot Figure 6-3
Do Challenge 6-1.
Read thru Pages 202. We will finish Chap 6 next time.

Lab #8: Learning about ADC, Open Loop Control , manual and using PWM. From
chapter 6 of Process Control text book:
1. Do Activity 2 and get Figure 6-4
2. Do Activity 3 and get figure 6-20
3. Get and demo Figure 6-23
Lab #9: Closed loop Control: Nonlinear, ON-OFF, and Differential Gap control,
getting Transfer Function model, Simulink modeling. From chapter 7 of Process
Control text book:
1.
2.
3.
4.

Do and demo Activity 1 and show figure 7-5


Do and demo Activity 2 and get Figure 7-10
Get transfer function G(s) of the plant
Do a Simulink simulation of both Activity 1 and 2. Show corresponding
Simulink graphs to Figure 7-5 and 7-10

5.
Lab #10 Linear Control Proportional Control, P, PD, PI, PID Control. From of
Process Control text book:
1.
2.
3.
4.

Read Ch. 8
Do Activity 1 and get Figure 8-8 and 8-9, 8-10.
Do Challenge 1
Do and demo Activity 2 and get Figure 8-13

Lab #11 Linear Control Proportional Control, P, PD, PI, PID Control. From chapter 8
of Process Control text book:
1. Do Activity 3 and get Figure 8-15 (Repeat with Simulink)
2. Do Activity 5, PI, and get Figure 8-17 (Repeat with Simulink)
3. Do Activity 6, PD, and get Figure 8-18 (Repeat with Simulink),
Lab #12 PID Design.
1. Design a PID controller to get the fastest possible response with minimal
steady state error.
2. Report your gains and response.
3. Design using 3 methods.
A. Method 1: Use the 5 step procedure in the book on Page 297.
B. Method 2: Use Zeigler Nichols method, refer to Sec 3.7 in your EE 370
textbook
C. Method 3: Use the CHR methodrefer to Sec 3.7 in your EE 370 textbook
4. In all methods show all intermediate graphs and steps. Show final step
response with gains used. Show Simulink result.

Simulink Help:
Use Simulink Matlab Fcn: Under Matlab function, write down name of the following
files (e.g., bs_bb in below example).
Choose -1 for Pulse width.
Here is the Matlab Function for Bang-Bang (On-Off controller):
function y=bs_bb(u)
if u<0, y=0;
else y=10;
end
Try this for the Differential Gap, think about the logic, the upper and lower limits are 102
and 101 and the setpoint is 101.5
function y=bs_dg(u)
yd=101.5; U=102; L=101;

if u>yd-L, y=9;
else if u<yd-U, y=0;
else y=0
end
========================================
Matlab Function to find G(s) =K / (s+p1)(s+p2) using step response data t, y
function [k,p1,p2]=bs_sysid(t,y)
a=y(end); y1=y(1); z=round(a)-y;
lz=log(abs(z)); p1t=-diff(lz)./diff(t);
p1=p1t(end);
bt=(y-1)./exp(-p1*t);
b=bt(end); c=-(a+b)+y1; p2=-b*p1/c, k=a*p1*p2
========================================
To check the estimated transfer function, type these in Matlab
g=tf(1,poly([-1, -10])), [y,t]=step(g);
[k,p1,p2]=bs_sysid(t,y)
ge=tf(k,poly([-p1,-p2])); [ye,te]=step(ge);
plot(t,y,te,ye,'r'),grid
============= 2nd Algorithm for estimating a 2nd order G(s) = Ko / (a2.s^2+a1.s +
1 ) ========
function [k0,a1,a2]=bs_sysid2(t,y)
k0=y(end); dt=t(2)-t(1); y1=dt*cumtrapz(k0-y); k1=y1(end); a1=k1/k0;
y2t=dt*cumtrapz(k1-y1); k2=y2t(end); a2=(a1*k1-k2)/k0;
=====================
To test it out, type these in Matlab: G(s) = 10 / (s+1)(s+10)
g=tf(1,poly([-1, -10])), [y,t]=step(g);
[k0,a1,a2]=bs_sysid2(t,y); ge=tf(k0,[a2 a1 1]),
[ye,te]=step(ge); plot(t,y,te,ye,'r')
=========================

Discrete Simulation: Suppose the system G(s)=1/(s+1) and we want to do a dicrete


simulation:
1. First you need to know the Sample Period, Ts, then discretize the system using c2d, we
then extract the numerator and denominator of the discrete transfer function (G(z) using
the tfdata command.
>> gz=c2d(g,Ts)
>> [ngz,dgz]=tfdata(gz,'v')
Then go to Simulink: Grab both a Transfer function and a Zero Order Hold from the
Discrete Menu. Double click them and enter their parameters ngz, dgz, and Ts.
Then get a Gain, and a Sum from the Math Menu. Then grab a Step from the Sources
Menu and a Scope from the Sinks Menu.

You might also like