Physics 37100
Advanced Physics Laboratory I
Lab #5
(PART II: PID---The Controller)
1)
Make a sketch
using getPhoto() to control the LED using proportional control. Here is an outline:
a. Set out=0;
b. Loop for k=1 to 100
c. Set analogWrite() to out
d. Wait 100ms.
e. Measure V using getPhoto
f.
Serial.println V
g.
Define err ie e=Vset-V;
h.
Define out=P*e;
i.
Make sure out is
between [0 255].
j.
Serial.println e
and out
k. End loop
2)
Find the largest
value of P=Pmax that does not causes the V to oscillate. How does it compare to your estimate from
part I?
3)
What is the
value of the error for the largest P that will not oscillate?
4)
Plot V and out
verses step k from above for Pmax, Pmax/2, and Pmax/10.
5)
Add Integral
control. Initialize es to 0 before the
loop and after line g above add es=es+e; Then change line h to out=P*e+I*es.
6)
Find values of
P=P0 and I=I0 that give good control.
7)
Plot V and out
verses step k for (P0,I0), (P0,I0/10), (P0/10,I0), and (P0/10,I0/10). You may have to lengthen the k loop to see
the full effects. Give a brief explanation
of the plots.