-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plots.m
189 lines (162 loc) · 5.02 KB
/
Plots.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
% This file is for processing data produced from the PID controller
%% Kp = 100, Ki = 0, Kd = 0 , supply 4V, 1.5A setpoint = 10 C
% write data from serial port to .dat file terminal command
% cat /dev/cu.usbmodem1411 > somefile.dat
% to view -- open in separate tab in terminal
% tail -f somefile.dat
close all; clear all; clc;
mat = csvread('./prop100.csv'); %%% this will give a nx3 matrix
temp = mat(:,1); %% makes this everything from the first column
pwm = mat(:,2);
time = mat(:,3);
% time is in ms -> convert to seconds
time = time/1000;
%Begin plotting:
% figure()
% p1 = plot(time, pwm);
% xlabel('Time (s)');
% ylabel('PWM signal');
% title('PWM output for K_{p} = 100, K_{i} = 0, K_{d} = 0', 'FontSize', 18);
% axis([0 250 0 300]);
figure()
p2 = plot(time, temp);
p2.LineWidth = 2;
p2.Color = 'black';
rl = refline(0, 10);
rl.Color = 'r';
rl.LineStyle = '--';
rl.LineWidth = 2;
%xlabel('time (s)');
%xlabel('Time (s)','FontSize',12,'FontWeight','bold','Color','r')
xlabel('Time (s)','FontSize',18);
ylabel('Temperature (C)', 'FontSize', 18);
title('Temperature for K_{p} = 100, K_{i} = 0, K_{d} = 0', 'FontSize', 18);
axis([0 250 8 25]);
%% Kp = 100, Ki = 0, Kd = 0 , supply 8V, 2.5A setpoint = 10 C
mat2 = csvread('./prop100_2.dat'); %%% this will give a nx3 matrix
temp2 = mat2(:,1); %% makes this everything from the first column
pwm2 = mat2(:,2);
time2 = mat2(:,3);
% time is in ms -> convert to seconds
time2 = time2/1000;
%Begin plotting:
figure(3)
plot(time2, pwm2);
xlabel('time (s)');
ylabel('pwm signal');
title('pwm output for Kp = 100, Ki = 0, Kd = 0 8v 2.5A source');
figure(4)
plot(time2, temp2);
xlabel('time (s)');
ylabel('Temperature (C)');
title('Temperature for Kp = 100, Ki = 0, Kd = 0 8v 2.5A source');
%% Kp = 100, Ki = 25, Kd = 0 , supply 8V, 2.5A setpoint = 0 C
mat = csvread('./exp3.dat'); %%% this will give a nx3 matrix
temp = mat(16:end,1); %% makes this everything from the first column
pwm = mat(16:end,2);
time = mat(16:end,3);
% time is in ms -> convert to seconds
time = time/1000;
%Begin plotting:
figure(5)
p1 = plot(time, pwm);
xlabel('Time (s)');
ylabel('PWM signal');
title('PWM output for K_{p} = 100, K_{i} = 0, K_{d} = 0', 'FontSize', 18);
axis([0 250 0 300]);
figure(6)
p2 = plot(time, temp);
p2.LineWidth = 2;
p2.Color = 'black';
rl = refline(0, 10);
rl.Color = 'r';
rl.LineStyle = '--';
rl.LineWidth = 2;
%xlabel('time (s)');
%xlabel('Time (s)','FontSize',12,'FontWeight','bold','Color','r')
xlabel('Time (s)','FontSize',18);
ylabel('Temperature (C)', 'FontSize', 18);
title('Temperature for K_{p} = 100, K_{i} = 0, K_{d} = 0', 'FontSize', 18);
axis([0 250 8 25]);
%% Kp = 100, Ki = 25, Kd = 0 , supply 8V, 2.5A setpoint = 12.5 C
mat = csvread('./exp4.dat'); %%% this will give a nx3 matrix
temp = mat(10:end,1); %% makes this everything from the first column
pwm = mat(10:end,2);
time = mat(10:end,3);
% time is in ms -> convert to seconds
time = time/1000;
%Begin plotting:
figure()
p1 = plot(time, pwm);
xlabel('Time (s)');
ylabel('PWM signal');
title('PWM output for K_{p} = 100, K_{i} = 25, K_{d} = 0', 'FontSize', 18);
axis([0 250 0 300]);
figure()
p2 = plot(time, temp);
p2.LineWidth = 2;
p2.Color = 'black';
rl = refline(0, 12.5);
rl.Color = 'r';
rl.LineStyle = '--';
rl.LineWidth = 2;
%xlabel('time (s)');
%xlabel('Time (s)','FontSize',12,'FontWeight','bold','Color','r')
xlabel('Time (s)','FontSize',18);
ylabel('Temperature (C)', 'FontSize', 18);
title('Temperature for K_{p} = 100, K_{i} = 25, K_{d} = 0', 'FontSize', 18);
axis([0 250 10 25]);
%% Kp = 100, Ki = 25, Kd = 15 , supply 8V, 2.5A setpoint = 12.5 C
%
% mat = csvread('./exp5.dat'); %%% this will give a nx3 matrix
% temp = mat(:,1); %% makes this everything from the first column
% pwm = mat(:,2);
% time = mat(:,3);
%
% % time is in ms -> convert to seconds
% time = time/1000;
%
% %Begin plotting:
% figure()
% p1 = plot(time, pwm);
% xlabel('time (s)');
% ylabel('pwm signal');
% title('pwm output for Kp = 100, Ki = 25, Kd = 15 8v 2.5A source');
%
% figure()
% p2 = plot(time, temp);
% rl = refline(0, 12.5);
% rl.Color = 'r'
% rl.LineStyle = '--'
% xlabel('time (s)');
% ylabel('Temperature (C)');
% title('Temperature for Kp = 100, Ki = 25, Kd = 15 8v 2.5A source');
% axis([0 250 10 25])
%% Kp = 100, Ki = 25, Kd = 50 , supply 8V, 2.5A setpoint = 12.5 C
mat = csvread('./exp5.dat'); %%% this will give a nx3 matrix
temp = mat(15:end,1); %% makes this everything from the first column
pwm = mat(15:end,2);
time = mat(15:end,3);
% time is in ms -> convert to seconds
time = time/1000;
%Begin plotting:
figure()
p1 = plot(time, pwm);
xlabel('time (s)');
ylabel('pwm signal');
title('pwm output for Kp = 100, Ki = 25, Kd = 50 8v 2.5A source');
axis([0 250 0 300]);
figure()
p2 = plot(time, temp);
p2.LineWidth = 2;
p2.Color = 'black';
rl = refline(0, 12.5);
rl.Color = 'r';
rl.LineStyle = '--';
rl.LineWidth = 2;
%xlabel('time (s)');
%xlabel('Time (s)','FontSize',12,'FontWeight','bold','Color','r')
xlabel('Time (s)','FontSize',24)
ylabel('Temperature (C)', 'FontSize', 24);
title('Temperature for K_{p} = 100, K_{i} = 25, K_{d} = 50', 'FontSize', 18);
axis([0 250 10 25])