Part 1
measuring warming
measuring warming
%%
part 2
%%
Part 3
%%
Part 4 proportinal and bang bang control
% Bang Bang control
% define setpower
% define temperature read_temp
clf
delete(instrfindall) % find and delete old serial port objects
s= serial('/dev/tty.usbserial-A700eYqg') % % for USB-serial connection
set(s,'BaudRate',19200)
fopen(s)
npts = 300
y=[];
tic
setpower(s,100)
hold on
axis ([0 npts 200 500])
for i=1:npts
y=[y readtemp(s)];
if readtemp(s) < 340
setpower(s,100)
else readtemp(s) >= 350
setpower(s,0)
end
plot(y)
pause(1);
end
toc
setpower(s,0)
%
% proportional heating
% define setpower
% define temperature read_temp
clf
delete(instrfindall) % find and delete old serial port objects
s= serial('/dev/tty.usbserial-A700eYqg') % % for USB-serial connection
set(s,'BaudRate',19200)
fopen(s)
npts = 300
y=[];
tic
setpower(s,100)
k = .05;
target = 340;
hold on
axis ([0 npts 200 500])
for i=1:npts
y=[y readtemp(s)];
present = readtemp(s)
error = target - present
setpower(s,k*(error));
plot(y);
pause(1);
end
toc
setpower(s,0)
%
No comments:
Post a Comment