forked from APMonitor/arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_Heaters.m
85 lines (77 loc) · 1.81 KB
/
test_Heaters.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
close all; clear all; clc
% include tclab.m for initialization
tclab;
disp('Test Heater 1')
disp('LED Indicates Temperature')
figure(1)
t1s = [];
t2s = [];
h1s = [];
h2s = [];
% initial heater values
ht1 = 0;
ht2 = 0;
h1(ht1);
h2(ht2);
for i = 1:399
tic;
if i==5
disp('Turn on heater 1 to 60%')
ht1 = 60;
h1(ht1);
end
if i==105
disp('Turn off heater 1')
ht1 = 0;
h1(ht1);
end
if i==150
disp('Turn on heater 2 to 80%')
ht2 = 80;
h2(ht2);
end
if i==205
disp('Turn off heaters')
ht1 = 0;
ht2 = 0;
h1(ht1);
h2(ht2);
end
% read temperatures
t1 = T1C();
t2 = T2C();
% LED brightness
brightness1 = (t1 - 30)/50.0; % <30degC off, >100degC full brightness
brightness2 = (t2 - 30)/50.0; % <30degC off, >100degC full brightness
brightness = max(brightness1,brightness2);
brightness = max(0,min(1,brightness)); % limit 0-1
led(brightness);
% plot heater and temperature data
h1s = [h1s,ht1];
h2s = [h2s,ht2];
t1s = [t1s,t1];
t2s = [t2s,t2];
n = length(t1s);
time = linspace(0,n+1,n);
clf
subplot(2,1,1)
plot(time,t1s,'r.','MarkerSize',10);
hold on
plot(time,t2s,'b.','MarkerSize',10);
ylabel('Temperature (degC)')
legend('Temperature 1','Temperature 2','Location','NorthWest')
subplot(2,1,2)
plot(time,h1s,'r-','LineWidth',2);
hold on
plot(time,h2s,'b--','LineWidth',2);
ylabel('Heater (0-5.5 V)')
xlabel('Time (sec)')
legend('Heater 1','Heater 2','Location','NorthWest')
drawnow;
t = toc;
pause(max(0.01,1.0-t))
end
disp('Turn off heaters')
h1(0);
h2(0);
disp('Heater Test Complete')