Question 2:
dT is assumed to be 0 because there is no rise in temperature. Thus, we are also able to eliminate dt when we multiply it by 0. After some calculations, I was able to determine that a good value for P is about 71.7647.
Feedback and control program
Question 1:
% Simulation of heating coffee
% heatsim.m
C = 1000; % heat capacity
Tair = 293; % ambient temperature
Rth = 0.85; % thermal resistance
T = Tair; % initial coffee temperature
t = 0; % starting time
tmax =10000; % duration of simulation
dt = 100; % time step
%P = 85; % power added by heater
clf % clear old figure
clc % clear command center
hold on
axis([0 tmax Tair (T + 100)])
xlabel ('time (seconds)') % axes labels
ylabel ('temperature (K)')
while t < tmax
if (T-Tair<337)
P = 100;
else
P = 0;
end
dE_in = P * dt;
dE_out = ((T - Tair) / Rth) * dt;
dE= dE_in - dE_out;
dT = dE / C;
T = T + dT;
t = t + dt;
plot(t,T,'ro')
drawnow
end
We added if else statements to the code. When the temperature of the coffee cup reaches room temperature, the heater turns on to warm the cup to its desired temperature. We could have also adjusted the temperature in the if else statement to make it higher than room temperature so that the coffee doesn't go completely cold. However, we chose room temperature because it is a definite point at which the coffee needs to be heated.
Bang-bang control is successful for thermal systems because as soon as the temperature reaches the set temperature, the system is able to rapidly revert that state back to a desired state. In this example, the coffee was able to be kept at a near 84C. This system may be insufficient because while the coffee did stay at around 84C, it was constantly fluctuating around the point rather than at 84C. However, the system ultimately achieved its goal, unlike the proportional control as we will see next.
Question 2:
% Simulation of heating coffee
% heatsim.m
C = 1000; % heat capacity
Tair = 293; % ambient temperature
Rth = 0.85; % thermal resistance
T = Tair; % initial coffee temperature
t = 0; % starting time
tmax =10000; % duration of simulation
dt = 100; % time step
%P = 85; % power added by heater
clf % clear old figure
clc % clear command center
hold on
axis([0 tmax Tair (T + 100)])
xlabel ('time (seconds)') % axes labels
ylabel ('temperature (K)')
while t < tmax
if (T-Tair<357);
P = 0.99 * (357- T);
else
P = 0;
end
dE_in = P * dt;
dE_out = ((T - Tair) / Rth) * dt;
dE= dE_in - dE_out;
dT = dE / C;
T = T + dT;
t = t + dt;
plot(t,T,'ro')
drawnow
end
We incorporated the proportional control equation into our code.
P = k * error The error being (357-T).
In order to determine the best k value, I played around with varying levels of it to see if it would yield something close to the desired Starbucks temperature. However, even after setting it at 0.99, I was unable to get the temperature to raise to 357. Thus, proportional control cannot work for this type of system since it cannot achieve its goal of getting the system to its desired level.
Proportional control with delay
% Simulation of heating coffee
% heatsim.m
C = 1000; % heat capacity
Tair = 293; % ambient temperature
Rth = 0.85; % thermal resistance
T = Tair; % initial coffee temperature
t = 0; % starting time
tmax =10000; % duration of simulation
dt = 100; % time step
%P = 85; % power added by heater
delay = 5; %seconds
clf % clear old figure
clc % clear command center
hold on
axis([0 tmax Tair (T + 100)])
xlabel ('time (seconds)') % axes labels
ylabel ('temperature (K)')
for i = 1:500
if (i - delay > 0);
P(i) = 0.99 * (357 - T(i-delay));
else
P(i) = 0;
end
dE_in = P(i) * dt;
dE_out = ((T(i) - Tair) / Rth) * dt;
dE= dE_in - dE_out;
dT = dE / C;
T(i+1) = T(i) + dT;
t(i) = i * dt;
plot(t(i),T(i),'ro')
drawnow
end
Bang-Bang control with delay
% Simulation of heating coffee
% heatsim.m
C = 1000; % heat capacity
Tair = 293; % ambient temperature
Rth = 0.85; % thermal resistance
T = Tair; % initial coffee temperature
t = 0; % starting time
tmax =10000; % duration of simulation
dt = 100; % time step
%P = 85; % power added by heater
delay = 5; %seconds
clf % clear old figure
clc % clear command center
hold on
axis([0 tmax Tair (T + 100)])
xlabel ('time (seconds)') % axes labels
ylabel ('temperature (K)')
while t < tmax
for i = 1:500
if (i - delay > 0);
if (T-Tair<337) ;
P(i) = 100;
else
P(i) = 0;
end
end
dE_in = P(i) * dt;
dE_out = ((T(i) - Tair) / Rth) * dt;
dE= dE_in - dE_out;
dT = dE / C;
T(i+1) = T(i) + dT;
t(i) = i * dt;
plot(t(i),T(i),'ro')
drawnow
end
end
it appears that the biggest effect that the delay has on the bang-bang and proportional control is that the initial onset of the effect is delayed by the designated delay time. For the bang-bang feedback, it reduced the amount of variation around 84C since the system had to wait to respond to the changes. Thus, instead of vacillating around a set point, the system only had time to respond to the change which eliminated that problem. For the proportional control, the system was still unable to reach its goal of 357K. There was the initial delay period followed by a short period in which the temperature of the coffee went over its goal. However, it quickly centered itself at a lower rate than desired.
Other delays in the thermodynamic system include a delay in temperature change. There must be enough energy added to the system in order to get the temperature to change. If the system does not have enough energy, it either will not change at all or will change slowly to reflect the amount of energy in the system.





Great job on all the codes! They're clear and the graphs look really clean, especially the Bang-Bang.
ReplyDeleteThe final graph is clear and accurately describes proportional control. You can really see how as the temperature gets closer to the target, the distance between the dots gets smaller and smaller.
ReplyDeleteExcellent job!