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

📄 jf_act.c

📁 一款完整的家用电器程序,具有控制商用机的功能,应用广泛,有一定的参考价值
💻 C
📖 第 1 页 / 共 5 页
字号:

void fun_act_on(void )	//根据请求动作
{
//压缩机开/关 排气高(连续3次)、排气感温包故障、高压保护、低压保护(连续3次)、压缩机过载保护(连续3次)时关压缩机
	if ((fault_state4 &b_fault_hpp) ||(fault_comp_guozai_times>=3) ||(fault_lpp_times>=3)||(fault_exTH0_times>=3) ||(fault_exh_times>=3))
		fun_comp_off_fault();  //故障时关压缩机立即停止
	else if (manual_set &b_comp_onask) //D6压缩机手动开
		{ 
		  if (PINB &b_comp)	//压缩机开时
		 	{
		 	  if (manual_set & b_dry_offask)  //D3除湿阀手动关	
		 		PORTC &=~ b_yv_dry; //PC0除湿阀YV-DRY off
		 	  else 	PORTC |= b_yv_dry; //PC0除湿阀YV-DRY on
		 	}
		  else	//压缩机关时
		   	{//低压保护计时3min 到或没有低压保护计时可以开压缩机启动
		   	//排气保护3分钟	正在计时 或低压保护正在计时者 不可以开压缩机
		   	//排气保护或排气感温包开路或短路计时3min 到或没有排气保护计时可以开压缩机启动
		   	if (((start_state2 &b_exTHh_delaystart)!=0) ||((start_state2 &b_exTH0_delaystart)!=0) ||((start_state2 &b_lpp_delay2start)!=0))	NOP();
	   	        else  if (PING &b_fan)  fun_comp_delayon(); //内风机开时压缩机等待延时开
			else	fun_fan_delay_on(); //内风机关时等待内风机延时启动
			}
		}	
	else	//D6压缩机手动关
	{
	   if (PINB &b_comp)  fun_comp_off(); //关压缩机	//压缩机开时关压缩机	
	   else  if (PING &b_ofan) fun_ofandelayoff(); //冷凝风机等待延时关
	 }
	
//电加热1请求	
  if (((manual_set &b_heat1_onask)!=0) && ((fault_state3 &b_fault_overheat1)==0) )
 	 {//D4电加热2请求开,有限温器故障/电加热1保护OVHEAT1时立即关闭电加热
	    if (PING &b_fan) PORTB |=b_heat1; //内风机开时立即启动电加热
	    else fun_fan_delay_on(); //内风机关时等待内风机延时启动
	  }
   else   PORTB &=~b_heat1; //有限温器故障时立即关闭电加热/请求关时立即关闭电加热
 
/*电加热2请求开时,系统判断送风机是否已经启动,
若已经启动则启动电加热。若送风机还没启动,则按流程启动送风机。
选择关闭时,则立即关闭电加热。*/
  if (((manual_set &b_heat2_onask)!=0) && ((fault_state3 &b_fault_overheat2)==0))
 	 {//D4电加热2请求开,有限温器故障/电加热1保护OVHEAT1时立即关闭电加热
	    if (PING &b_fan) PORTB |=b_heat2; //内风机开时立即启动电加热
	    else fun_fan_delay_on(); //内风机关时等待内风机延时启动
	  }
   else   PORTB &=~b_heat2; //有限温器故障时立即关闭电加热/请求关时立即关闭电加热
  fun_humid_on(); //加湿器动作 
	
//能量调节阀在开请求或低压保护启动开计时 开
   if (manual_set &b_yvadjust_onask) PORTG|= b_yv_adjust;
   else
     	{
     		if (start_state2 &b_yvadjust_delaystart) PORTG|= b_yv_adjust;
   		else  PORTG &=~ b_yv_adjust; //关PG1调节阀YV-ADJUST	
	}  
		
/*送风机:当手动选择送风机开时,机组会按已经设定的送风机延时时间启动。
选择关闭时,系统判断其它执行机构:压缩机、电加热、加湿器是否处于运行状态
,若处于运行状态则,先按流程关闭其它执行机构,再延时180s关闭送风机。
若其它机构处于关闭状态,则立即关闭送风机。*/
    if (manual_set &b_fan_onask) //D7送风机手动开
       {
          if (PING &b_fan) NOP();	//内风机已开时空操作
    	  else fun_fan_delay_on(); //内风机关时等待内风机延时启动
	}
    else	//送风机手动关
      {
      	if (PING &b_fan) fun_fan_delay_off(); //内风机等待延时关
      }
}

void fun_fan_delay_on(void) //内风机等待延时启动
  {
//20080201  	if (mode & b_fast_test) run_state  |= b_fan_ondelay; //20071113快测时取消风机延时开;
  	if (run_state &b_fan_ondelay) 
		{ PORTG |=b_fan;	//内风机FAN=1	
		  t_fan_ondelay=0;	//送风机延时启动时间=0
		  run_state &=~b_fan_ondelay; //风机启动后延时启动标志清0
		}
	else if (!(start_state &b_fan_ondelaystart))//送风机开延时=0时先开延时计时位
		{     t_fan_ondelay=0;	//送风机延时启动时间=0
	      	  start_state |=b_fan_ondelaystart;//开延时计时位
 		}
  }
  
void fun_fan_delay_off(void) //内风机等待延时关
  {
  	if (run_state &b_fan_offdelay) 
		{ PORTG &=~b_fan;	//内风机FAN=0	
		  t_fan_offdelay=0;	//送风机延时关时间=0
		  run_state &=~b_fan_offdelay; //风机关后延时关标志清0
		}
	else if (!(start_state &b_fan_offdelaystart))//送风机关延时=0时先开延时计时位
		{     t_fan_offdelay=0;	//送风机延时关时间=0
	      	  start_state |=b_fan_offdelaystart;//开延时计时位
 		}
  }  

 
void fun_comp_delayon(void)	//压缩机等待延时开 
{
	if (run_state & b_comp_ondelay) //延时到时压缩机开
	    {	
		PORTB |= b_comp;   // 开压缩机
		PORTC |= b_yv_dry; //PC0除湿阀YV-DRY开
		PORTG |= b_ofan;   //PG0外风机OFAN
		run_state &=~ b_comp_ondelay;  //关压缩机延时计时到标志
		start_state |=b_yvcomp_delaystart;//需延时5秒开YV-COMP	PORTD |= b_yv_comp; //PD7压缩机阀YV-COMP开
	    t_yvcomp_ondelay=0;	//供液阀延时启动时间5秒
	    }
	else	//延时未到时检查延时开始,为0则检查压缩机停机时间到否,到则置延时开始
	    {
	    if ((start_state & b_comp_ondelaystart)==0) //延时未开始=0
	      {	
	    	if  (run_state &b_comp_stop)
		    	{
		    	  start_state |= b_comp_ondelaystart;
		    	   t_comp_ondelay=0;
		        }
		   } 		
	    }    	
  }			 
 
void fun_ofandelayoff(void)	// //冷凝风机等待延时关
  {
 	if ((start_state2 &b_ofan_offdelaystart)==0)
 	{
 		t_ofan_offdelay=0;	//冷凝风机延时关时间=0
	start_state2 |=b_ofan_offdelaystart;//开冷凝风机关的延时标志
	}
  }   
  
/*
加湿量4Kg/h
额定加湿量	30%	50%	70%	100%   最大值
		1.3	2.2	3.1	4.4	5.3
a、若I1<0.9Imax时,开进水电磁阀,加湿器进水;当I1>Imax×1.2时,关进水电磁阀,停止进水。
b、若I1>Imax×1.3时,开排水电磁阀,加湿器进行排水;当I1<Imax时,关排水电磁阀,停止排水。
c、当加湿器运行时间达到设定间隔排水时间时,关加湿器,开排水阀,进行排水,排水时间到时,关排水阀。
 */
 void fun_humid_on(void) //加湿器动作程序
 {
//当加湿器运行时间达到设定间隔排水时间时,关加湿器,开排水阀,进行排水,排水时间到时,关排水阀。
   if (((fault_state3 &b_fault_humid_paishui)==0) &&((fault_state2 &b_fault_highwater)==0)&&((fault_state2 &b_fault_humid_lowi)==0))
  	{ //无加湿故障\高水位保护、低电流故障时可以动作,有故障时全关
  	  NOP();
  	  if (manual_set &b_humid_onask)	//加湿开时则加湿逻辑动作
	   {//刚开始要加湿时需要进行清洗,加湿关大于5小时,加湿大清洗,加湿关小于5小时,加湿小换水
  		 if ((manual_set_temp &b_humid_onask)==0)
			{//刚开始要加湿时		
				auto_state &=~b_humid_clean_end;	//加湿清洗结束
				t_humid_clean_start=0;	//加湿清洗计时清0
				auto_state  &=~b_humid_clean_big;
			//20080128加湿关小于5小时,加湿小换水,>24h不清洗,在5-24小时间清洗
			if (t_humid_stop>=4320) auto_state |=b_humid_clean_end;	//20080128加湿关>24h加湿清洗结束
			else if (t_humid_stop>=900) auto_state  |=b_humid_clean_big;	//20080128加湿关大于5小时且<24小时,加湿大清洗
			 
			}
		else
		  {//加湿已开
		  	if ((t_humid_run>90)&&((flag & b_humid_paikong)==0))
			  {//当加湿器HUMID连续闭合时间超过30分钟,关闭HUMID,对加湿器进行清洗
				flag |= b_humid_paikong;	//排水空
				auto_state &=~b_humid_clean_end;	//加湿清洗结束
				t_humid_paikong=0;	//加湿排水空计时清0
			  }
		  }	
	     NOP();
	     if (mode &b_manual_on) auto_state |=b_humid_clean_end;	//20080417手动增加加湿清洗结束1,不进入清洗
	  	 else NOP();
	  	 if (PING &b_fan)  // 内风机开时启动加湿器
  		   {
  		 	if (auto_state &b_humid_clean_end)
  		 	 {
  		 		PORTD |=b_humid;	//PD0加湿HUMID ON
  		 		fun_humid_i_act(imax10_set); //加湿清洗结束按电流大小来动作加湿器
  		 	 }
  		 	else if (flag & b_humid_paikong)fun_humid_paikong();	//加湿器排空水
  		 	else if(auto_state &b_humid_clean_big) fun_humid_clean_big();	//大清洗
  		 	else  fun_humid_clean_low();	//加湿小换水 		 		
  		   }
		 else fun_fan_delay_on(); //内风机关时等待内风机延时启动
	   }
	 else //加湿关要求时清除所有清洗标志
	   {//在加湿器关时则手动排水进水按手动设置动作,自动时已清除排水及进水请求。加湿开时则排水进水按加湿逻辑动作
	 		PORTD &=~b_humid;	//PD0加湿HUMID关
		 	auto_state &=~b_humid_clean_end;	//加湿清洗结束
		 	t_humid_clean_start=0;	//加湿清洗计时清0
		 	auto_state &=~b_humid_clean_big;
		 	flag &=~ b_humid_paikong;	//排水空
				t_humid_paikong=0;	//加湿排水空计时清0
		 	 if (manual_set &b_paishui_onask)	PORTD |=b_yv_out;	//手动排水开排水阀YV-OUT开
			 else PORTD &=~b_yv_out;	//PD5排水阀YV-OUT关
			 if (mokuai_set &b_jinshui_onask)
			   {//高水位无连续10秒才可以动作进水阀
			 	if (t_highwater_ok>=10)PORTD |=b_yv_in;	//手动进水开进水阀YV-IN开
			 	else PORTD &=~b_yv_in;	//PD1进水阀YV-IN关
			  }
			 else PORTD &=~b_yv_in;	//PD1进水阀YV-IN关
		 }
	}
  else  //故障  手动加湿器关/手动排水关
	{
	  PORTD &=~b_humid;	//PD0加湿HUMID关
	  NOP();
	  PORTD &=~b_yv_in;	//PD1进水阀YV-IN关
	  PORTD &=~b_yv_out;	//PD5排水阀YV-OUT关	
	}
	manual_set_temp=manual_set;	//保存当前动作请求
//20080417当加湿器HUMIN连续停止时间超过24小时,则先打开排水阀,加湿器排水时间到后关闭排水阀。 	
	if ((t_humid_stop>=4320) && ((mode &b_manual_on)==0)) //20080417手动增加加湿清洗结束1,不进入清洗	//20080417 
	{//加湿器连续停止时间超过24小时排空水
		if ((auto_state &b_humid_paishui_end)==0) fun_humid_paishui();	//加湿排空水未结束时排水
			
		}
	else
	{//加湿器连续停止时间<24小时,
		t_humid_paishui=0;	//
		auto_state &=~b_humid_paishui_end;	//加湿排空水结束
		}
}

 
void fun_delaytime_1s(void) //在1S中动作定时程序
 {
 //需开始计时时,计时时间+1,如到达设置时间,则置到达标志,清开始计时标志及时间	
 //内风机启动 延时
 	if (start_state &b_fan_ondelaystart)	//D7送风机开的延时5秒 计时开始
 		{
 		  t_fan_ondelay++;	//计时+1
 		  if (t_fan_ondelay >=t_fan_ondelay_set)
 			{  run_state |=b_fan_ondelay;
 			   start_state &=~b_fan_ondelaystart;
 			   t_fan_ondelay=0; //计时清0
 			}
 		}
 
 //冷凝风机关机 延时5秒关	
  	if (start_state2 &b_ofan_offdelaystart)	
 		{
 		  t_ofan_offdelay++;	//计时+1
 		  if (t_ofan_offdelay >=t_ofan_offdelay_set)//时间到置标志1
 			{  run_state2|=b_ofan_offdelay;
 			   start_state2 &=~b_ofan_offdelaystart;//清开始计时标志
 			   t_ofan_offdelay=0; //计时清0
 			   PORTG &=~b_ofan; //PG0冷凝风机OFAN关的延时5秒计时到
 			}
 		}

 //D2供液阀延时5秒后开
 	if (start_state &b_yvcomp_delaystart)	
 	    {
 		t_yvcomp_ondelay++;	//供液阀延时启动时间5秒
 		if (t_yvcomp_ondelay >=5)
 			{ 
 			   if ((fault_state4 &b_fault_comp_guozai)==0)
 			   PORTD |=b_yv_comp;  //无过载故障时启动供液阀
 			   start_state &=~b_yvcomp_delaystart;
 			   t_yvcomp_ondelay =0; //计时清0
 			}
 	    } 
 
  //1S中定时5s	
  t_5s_times++;	//计时+1
  if (t_5s_times >=5)	 //定时5s到
 	 {
 	  	t_5s_times=0;	//计时清0
 	    time_flag |=b_time_5s;	//置标志1
 	    if (PINB &b_heat1)  //heat1 on
	   	   {
	   	   	if (t_heat1_on <=250) 	t_heat1_on++;  //电加热1开时间
	   	   	t_heat1_off=0;  //电加热1关时间
	   	   }
	   	else    //heat1 off
	   	   {
	   	   	if (t_heat1_off <=250) 	t_heat1_off++;  //电加热1关时间
	   	   	t_heat1_on=0;  //电加热1开时间
	   	   } 
	   	if (PINB &b_heat2)  //heat2 on
	   	   {
	   	   	if (t_heat2_on <=250) 	t_heat2_on++;  //电加热2开时间
	   	   	t_heat2_off=0;  //电加热2关时间
	   	   }
	   	else    //heat2 off
	   	   {
	   	   	if (t_heat2_off <=250) 	t_heat2_off++;  //电加热2关时间
	   	   	t_heat2_on=0;  //电加热2开时间
	   	   }     
	   	   	
 	  } 	  
//压缩机停机/运行时间 延时	计到20秒时次数t_comp_stop_times+1
  	if (PINB &b_comp)   //压缩机启动
  	   {	
  	   	t_lpp_compoff=0;	//20080115压缩机启动时断开的低压检测清0
  		//连续3秒过载,停压缩机, 指示灯闪烁。

⌨️ 快捷键说明

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