Pid Control: Thermofit: Author: Mackenzie Andrews Group Members: Kim Hua
Pid Control: Thermofit: Author: Mackenzie Andrews Group Members: Kim Hua
Figure 1: Circuit Schematic - Shows the set up of the breadboard and software interface through the
data acquisition device (DAQ). The low power resistor acted as the heating element thermally
coupled to the thermistor, which was our temperature sensor.
coupled using heat-shrink compound and Therefore, the farther the
was created in which half was the set point, the greater the output value
thermistor and half was the 10 KOhm sent to the actuator. The nature of a
resistor which scaled the output voltage proportional controller causes the system
to be near the center of the DAQ input to always produce an error relative to the
range at room temp. The low-value set point, therefore the desired value will
resistor was then placed in series with never actually be reached. In order to fix
the MOSFET. The DAQ output was then this problem and improve system
full circuit schematic can be observed in terms can be added such that:
between the desired and measured the functional units of the controller. The
E=T -T SET .
MEAS duty cycle which uses pulse width
Figure 2: General Feedback Control System Block Diagram – An input, X, is checked against the
current state of the system, Y, to generate an error, E(t). The error is then inputted into the
controller, which uses the PID algorithm. The output of the controller feeds into a duty cycle, which
powers the system.
The ratio between the output and H(s) = β/(s +2ζω s+ω )
2
0 0
2
input (or set point of the system) can be Where ω is the natural frequency and ζ
0
Taking the Laplace form of the +K s+K )/(s +(2ζω +K β)s +(ω +K β)s+K
P I
3
0 D
2
0
2
P
We can also derive the transfer function The first VI supplied was the
output. This VI allowed us to read the previously so that we know how our
system information from the DAQ system responds under control. Finally,
(voltage output from circuit). Using the we rearranged the transfer function and
PWM application VI, we were able to solved for the coefficients needed to be
obtain files of the measured voltage vs. plugged into the pid closed loop step
control voltage. In order to use the PWM response VI. This VI allowed us to
application VI, we also had to use the experiment with the various PID gain
PWM sub VI which implemented a duty values using the transfer function
cycle so that we could observe the effect derived from our system. This was
of a step change to the duty cycle so that helpful later on because it gave us an
we could measure the transfer function idea of how each gain value affects the
to apply a step change to the duty cycle approximate ratio of values needed to
and record both the duty cycle and achieve the response needed for our
reached, the VI process was ended and Using the last VI described above, we
the file was saved to the designated plugged in our transfer function
Then, using the Get TF fom files gain values to observe the effect each
2012 VI, we opened the file saved by the has on the system. Figure 3 shows the
previous VI. This VI fits a transfer front panel of the VI, with the transfer
function coefficients for the numerator of the system response on the lower
and denominator on the upper left, a right. The response shown in Figure 3 is
display of the transfer function on the our baseline comparator where all of the
Figure 3: Baseline Gain Value Comparator – We set all of the gain values (Kp, Ki, Kd) equal to 100.
We used this system response as a comparator to observe the effect of changing the individual gain
values.
(proportional control gain), Ki (integral also increased the error between the final
control gain), and Kd (derivative control value reached by the system and the set
gain) individually by increasing the gain point. Having an integral control gain
value from 100 to 200 and 300 (Figure allows the system to reach the exact set
4). When Kp was increased, the system point, however, when Ki was increased,
rose more rapidly to the set point (Figure the overshoot also increased as well as
4, column 1). Another effect of Kp, not the number and size of the oscillations
before reaching a steady state value the system and damped the oscillations
Figure 4: Effect of Changing Gain Values – We manipulated each gain value individually (Left to
Right: Kp, Ki, Kd). We stepped each gain value up to 200 (Top row) then 300 (Bottom row). Kp increased
rise time. Ki increased oscillations and overshoot. Kd damped the oscillations and decreased overshoot.
response with a fast rise time, fast desired by using the following K values
In order to build our own PID power the circuit. Figure 6 shows the
into a temperature, compare that diagram. The red, blue, and green
temperature to our set point, send that rectangles correspond to the components
error into a PID loop, run the PID documented in figures 7, 8, and 9,
The first step in building our own PID thermistor could be calculated using the
control was to convert the voltage voltage divider formula. We also know
reading from the DAQ to a temperature. the thermistor equation relating the
“Formula” block in the block diagram temperature output from the Formula
(Figure 7). The Voltage reading from the block was then subtracted from a user
DAQ was inputted into the Formula controlled set point labeled “Set
block so that the output would be the Temperature (K).” The input for the set
temperature of the thermistor. The point als appears on the front panel. The
current temperature was displayed on the current temperature subtracted from the
front panel (Figure 10) both as a numeric set point gives an error output from the
Figure 7: Conversion to Temperature and Error Calculation – System data was collected by the
DAQ which passed the current voltage into the formula block which converted the voltage to a current
temperature. The temperature was displayed on the front panel and compared to a set point to
calculate the error.
PID Implementation which outputs an integrated sum of the
We next took the error calculated in previous errors. This integral block
Figure 7 and fed that error into a PID output is converted into a double and
input into a proportional control, and labeled “Ki.” Finally, the derivative
The proportional control was the integral control, but instead used the
a user inputed gain value using the block gain of “Kd.” The outputs of the
labeled “Kp” (Figure 8). The integral proportional, integral, and derivative
control was implemented by using the control were then summed using a
error as the input to the “Integral” block multiple input summing block.
Figure 8: PID Implementation – The error was sent into 3 pathways. The first multiplied the error by a
constant, Kp (proportional control). The second was an integrator pathway, which integrated the error
with past error and multiplied by Ki (integral control). The final was a derivative pathway, which
calculated the rate of change of the error and multiplied by Kd (derivative control). The three outputs
were then summed.
greater than 10, it will be converted into
Duty Cycle Implementation a 10, divided by 10, giving 1. Likewise,
The output from the summated PID if the value is negative, it will be
calculation was then inputted into a converted into a 0. This output range
function that forces the value to be in a from 0 to 1 represents a percentage to be
certain range. This is denoted by the fed into the duty cycle. Since the value
block with the integers “0” and “10” represents a “percent ON time,” the
coming off of it (Figure 9). This is value was multiplied by 1000 to be
necessary because the input into the duty converted into milliseconds of ON time
cycle must be in the range of 0 to 1. and fed into a DAQ controller that tells
Since the output from the PID could be the DAQ to power the circuit for the
any range of values, including negative amount of time given as an input. The
values, we must force the output into a remainder of the 1000 milliseconds was
specific range. We used the range from 0 then calculated and sent into the DAQ as
to 10 then divided that range by 10. In an OFF time.
this case, if the output from the PID is
Figure 9: Duty Cycle Implementation – The output from the PID calculation was forced into a range
from 0 to 10 then divided by 10 to give a value from 0 to 1. This value represents a percent ON time
which was passed into the duty cycle and told the DAQ whether to power the system or not.
All of the user controls described percent ON time, and with the CH1 and
above as well as the output readings for CH2 indicator lights indicating whether
the current temperature value and plot the power to the circuit is ON or OFF.
are seen on the front panel (Figure 10). Finally, the current temperature response
Using the front panel, the user is able to of the circuit was displayed as a value
numbers into the entry fields labeled Temperature” box and on the plot.
“Kp,” “Ki,” and “Kd.” The set point for (Note: the control voltage range was
the system can be inputted into the “Set always set at 10 while the program was
Temperature (K)” field. The in use and the STOP button allowed us
functionality of the duty cycle can be to abort the while loop and end the
o Avoid overheating,
System Response to Alterations in Gain maintain biological safety
Values Minimal Oscillations
Once we implemented a usable PID o Constant external
controller interface in LabView, we next temperature for user, less
had to experiment with our gain values work for biological
to get the system response appropriate regulator
for our target design. Since we were In order to begin testing which gain
designing a thermoregulating running values gave us our target response we
jacket, we had the following response first tested the baseline values used for
parameters: the K value tests described in the
Rise time < 30 seconds Methods section, setting Kp = Ki = Kd =
o Respond rapidly but not 100 (Figure 11, Top). Our starting
instantaneously to temperature was 318 K and our target
temperature fluctuations temperature was 330 K. Using those
Overshoot < 2 degrees values, our system initially took 30
seconds to reach the set point but reduce Kp and Ki from 100, we set the
From those results, we knew that we set point was 310 K (Figure 11, Bottom).
had to decrease Kp to reduce the error in Using those gain values, the system took
the system and decrease Ki to reduce the 30 seconds to reach the setpoint but
proportionality between the gain values back to the set point and reaching a
original K value test, Kd = 2Kp = 20Ki. that out Ki was still too large, but the
Knowing that we had to significantly ratio used led to the correct rise time.
Figure 11: Altered K Values 1 – (Top) All gain values = 100, too much overshoot, large error. (Bottom)
Kp = 20, Ki = 2, Kd = 40, too much overshoot.
From these results, we knew that Our system started from a temperature of
we needed to reduce Ki, but we wanted 305 K with a set point of 310 K (Figure
to maintain the same ratio of gain values. 12, Top). The system reached the set
decrease all of our gain values by a degrees, we also observed more abrupt
Kp = 10 reduced damping.
of 100 (to remove the overshoot), but Our system started from 304 K with a set
increase the relative damping. This gave system reached the set point after 45
Figure 12: Altered K Values 1 – (Top) Kp = 10, Ki = 1, Kd = 20, too much overshoot, too fast of rise, too
little damping. (Bottom) Kp = 0.5, Ki = 0.01, Kd = 5, too slow of rise.
Finally, we increased our Kp by Figure 13 shows the response of our
factor of 2.5, keeping our Kd the set point of 325 K. The system reached
same. This gave us K values of: the set point in 30 seconds with no
Kd = 5 application.
Figure 13: Ideal Response - Kp = 1, Ki = 0.025, Kd = 5, rise time = 30 seconds, no overshoot. This was
the ideal response for the thermoregulating jacket application.
control allows the implementer to of a PID does is crucial for the ability to
device to target a set value. Through appropriate for the device being
very minimal LabView experience going systems use PID control to maintain
into this lab, so there was a large homeostasis with their environment.