⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 heat_sup.m

📁 Matlab学习课件
💻 M
字号:
function done = heat_sup
% Supervisory task - this task generates the setpoint for the PID control task.
% This is a continuous task -- it runs whenever it is given a scan.
% File: heat_sup.m

heatglbl 	% Global definitions

% The 'next-state'is maintained as a separate variable so that the
% initialization canbe handled correctly and so a test can be
% constructed to tell whether the entry function of a state
% should be run. The next-state variable must be static so it
% remembered across function invocations. The 'global' designation
% is the only way Matlab has of making a variable static.
% The default value of the next-state variable is -1, indicating
% that no state change has taken place.

global Sheat_sup_next sup_start_time
	% Next state for this task (other local statics
	% can be listed here.
	% These aren't really global,  but do have to be 'static'
	% Matlab doesn't have a 'static' declaration so this will have to do!

if Sheat_sup == 0
	% Initialization section - occurs once only
	Sheat_sup = 1;	% Make sure this section is not executed again!
	Sheat_sup_next = 1;	% First state.
		%The default is -1 which indicates stay in same state
	temp_set = 0;	% Initial temperature setpoint
	return;
end

if Sheat_sup_next ~= -1
	% There has been a state change (including self-transition)
	[i_audit,trans_trail] = audit(3,Sheat_sup,Sheat_sup_next,tstep,...
		trans_trail,i_audit);
		% Record this transition
	Sheat_sup = Sheat_sup_next;
	run_entry = 1;
	Sheat_sup_next = -1;	% Default - stay in same state
else
	run_entry = 0;
end

% Run the code associated with the current state
if Sheat_sup == 1	% **Heat to holding temperature**
	% Entry section
	if run_entry % Only run this on entry to the state
		% code for entry section goes here (if any)
		temp_set = temp_soak;
	end
	% Action section
		% code for action section goes here (if any)
		% No action function for this task
	%Test/exit section 
	% If temperature is near processign temperature, start process timing
	if x(1) >= (temp_soak - 0.03)
		Sheat_sup_next = 2; % Transition to Soak
		% Exit section
			% code for exit section (if any)
			% No exit section for this transition
	end

elseif Sheat_sup == 2	% **Soak**
	% Entry section
	if run_entry % Only run this on entry to the state
		% code for entry section goes here (if any)
		sup_start_time = get_time;  % Start time for processing
	end
	% Action section
		% code for action section goes here (if any)
		% No action function for this task
	%Test/exit section 
	if get_time >= (sup_start_time + soak_time)
		Sheat_sup_next = 3; % Transition to Cool_Down
		% Exit section for this transition
		temp_set = temp_init;
	end

elseif Sheat_sup == 3	% **Cool_Down**
	% Stay in this state until program terminates - nothing to do here
	% Entry section
	% Action section
		% code for action section goes here (if any)
		% No action function for this task
	%Test/exit section 

else	% Check for a state variable value that doesn't
	% correspond to a defined state.
	fprintf('Uknown state: %f\n',Sheat_sup);
	error('Task: heat_sup -- unknown state encountered');
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -