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

📄 process.c

📁 电表解决方案概要power_meter_r8c2g_source_code
💻 C
📖 第 1 页 / 共 3 页
字号:
	 
	 if (i >= 1)					/* 水位下降超过一档时进行补水处理 */
	  {
	    status_buff = STOP;					
		run_inlet_flag = 1;
		if (water_buff != water_level_buff)	
		 {	
			inlet(0, 0, water_level_buff);	
			return;
		 }
	  }
   }
   
  if (lid_open)				/* 浸泡开盖,进行错误处理 */
   {
       err_buff = OPEN_LID_ERR;  				
       return;
   }

  if (soak_time == 10)		/* 10分钟浸泡组合程序处理 */
   {
	   if ((process_left_time == 0)&&(soak_2_cycle_buff != 1))
	   process_left_time = soak_time * 60;
	   
	   process_left_time --;  
	   
	   if (soak_1_cycle_buff != 1)
	   soak_1();			/* 执行浸泡过程 1 */
	   
	   if ((soak_2_cycle_buff != 1)&&(soak_1_cycle_buff == 1))
	   soak_2();			/* 执行浸泡过程 2 */
	   
	   else if (soak_2_cycle_buff == 1)
	    {
			pass_time_counter ++;
			operation_counter ++;
			process_left_time = 0;
	    }
		
	   return;
   }
  else if (soak_time == 20)		/* 20分钟浸泡组合程序处理 */
   {
	   if ((process_left_time == 0)&&(soak_3_cycle_buff != 1))
	   process_left_time = soak_time * 60;
	   
	   process_left_time --;  
	   	   
	   if (soak_1_cycle_buff != 1)
	   soak_1();			/* 执行浸泡过程 1 */
	   
	   if ((soak_2_cycle_buff != 1)&&(soak_1_cycle_buff == 1))
	   soak_2();			/* 执行浸泡过程 2 */
	   
	   if ((soak_3_cycle_buff != 1)&&(soak_2_cycle_buff == 1)&&(soak_1_cycle_buff == 1))
	   soak_3();			/* 执行浸泡过程 3 */
	   
	   else if (soak_3_cycle_buff == 1)
	    {
			pass_time_counter ++;
			operation_counter ++;
			process_left_time = 0;
		}
	   return;
   }
  else if (soak_time == 30)		/* 30分钟浸泡组合程序处理 */
   {
	   if ((process_left_time == 0)&&(soak_3_cycle_buff != 2))
	   process_left_time = soak_time * 60;
	   
	   process_left_time --;  	   
	   
	   if (soak_1_cycle_buff != 1)
	   soak_1();			/* 执行浸泡过程 1 */
	   
	   if ((soak_2_cycle_buff != 1)&&(soak_1_cycle_buff == 1))
	   soak_2();			/* 执行浸泡过程 2 */
	   
	   if ((soak_3_cycle_buff != 2)&&(soak_2_cycle_buff == 1)&&(soak_1_cycle_buff == 1))
	   soak_3();			/* 执行浸泡过程 3 */
	   
	   else if (soak_3_cycle_buff == 2)
	    {
			pass_time_counter ++;
			operation_counter ++;
			process_left_time = 0;
	    }
	   return;
   }
  else if (soak_time == 40)		/* 40分钟浸泡组合程序处理 */
   {
	   if ((process_left_time == 0)&&(soak_3_cycle_buff != 3))
	   process_left_time = soak_time * 60;
	   
	   process_left_time --;  	   
	   
	   if (soak_1_cycle_buff != 1)
	   soak_1();			/* 执行浸泡过程 1 */
	   
	   if ((soak_2_cycle_buff != 1)&&(soak_1_cycle_buff == 1))
	   soak_2();			/* 执行浸泡过程 2 */
	   
	   if ((soak_3_cycle_buff != 3)&&(soak_2_cycle_buff == 1)&&(soak_1_cycle_buff == 1))
	   soak_3();			/* 执行浸泡过程 3 */
	   
	   else if (soak_3_cycle_buff == 3)
	    {
			pass_time_counter ++;
			operation_counter ++;
			process_left_time = 0;
	    }
	   return;	   
   }
  else
  return;
}

/******************************************************************************************

void wash(unsigned int wash_time): 洗涤过程处理程序

******************************************************************************************/

void wash(unsigned int wash_time)
{
  unsigned char i;
  unsigned char j;
    	
if (water_full_flag == 0)
 {
	i = water_level_buff - water_buff;  	/* 判定洗涤运行中水位下降是否超过一档 */
	 
	if (i >= 1)								/* 水位下降超过一档时进行补水处理 */
	 {
	    status_buff = STOP;					
		run_inlet_flag = 1;
		if (water_buff != water_level_buff)	
		 {	
			inlet(0, 0, water_level_buff);
			return;
		 }
	 }
 }
   
if (lid_open)								/* 洗涤开盖,进行错误处理 */
 {
	err_buff = OPEN_LID_ERR;  				
	return;
 }

if (program_auto_flag == 1)
 {
	 ;
 }

//if (wash_finish_flag != 1)
// {
	if (wash_start_flag == 0)			/* 洗涤过程开始,设置运行参数 */
 	 {
	 	wash_start_flag = 1;
	 	balance_time_buff = 30;
	 	run_stream_time = wash_time;
		process_left_time = wash_time + balance_time_buff;
 	 }

	if (wash_start_flag == 1)			/* 洗涤过程运行 */
 	 {
	 	if (run_stream_time > 0)
	  	 {
		   if ((program_buff >= 3)&&(program_buff <= 6)&&(water_level >= 1))
		    {			/* 有加强水流程序运行时进行带加强水流的洗涤 */
			  if (main_stream_time > 0)
			   {
				  stream_buff = MAIN_STREAM;			/* 设置电机正反转参数 */
				  main_stream_time --;
			   }
			  if (main_stream_time == 0)
			   {
				  if (ext_stream_time > 0)
				   {
					  stream_buff == EXT_STREAM;		/* 执行加强水流 */
					  ext_stream_time --;
				   }	  
				  if (ext_stream_time == 0)				/* 加强水流时间为0,洗涤结束 */
				   {
					  main_stream_time = 170;
					  ext_stream_time = 10; 
					  stream_buff = MAIN_STREAM;
				   }
			   }
			}
		   else 
		   stream_buff = MAIN_STREAM;		/* 不带加强水流程序运行主水流循环 */
		   
		   run_stream_time --;
		   process_left_time --;
		   
	  	 }
	 	if (run_stream_time == 0)			/* 洗涤运行完成时,进行30平衡水流洗涤和结束处理 */
	  	 {
		 	stream_buff = BALANCE_STREAM;
		 
		 	if (balance_time_buff > 0)		/* 30平衡水流洗涤和结束处理 */
			 {
		 		balance_time_buff --;
				process_left_time --;
			 }
		 
		 	if (balance_time_buff == 0)		/* 结束处理 */
		  	 {
			  	balance_time_buff == 30;
				wash_start_flag = 0;
//			  	wash_finish_flag = 1;
				stream_buff = STREAM_STOP;
				
				mot_cycle_buff &= MOT_STOP;				
				output_buff &= (~CW);
				output_buff &= (~CCW);
				
				operation_counter += 2;
				pass_time_counter += 2;
				
				process_left_time = 0;
				return;
		  	 }
	  	 }
		return;
 	 }
// }
 return;
}

/******************************************************************************************

void interm_spin(unsigned int interm_spin_time): 简短脱水过程处理程序

******************************************************************************************/

void interm_spin(unsigned int interm_spin_time)
{
  static unsigned char interm_spin_cycle;
  
  if (process_left_time == 0)		/* 程序剩余时间为0,重置剩余时间 */
  process_left_time = interm_spin_time;
  
  if (lid_open)						/* 脱水开改进行错误处理 */
   {
	   err_buff = OPEN_LID_ERR;  		
       return;
   }
  if (unbalance_flag == 1)		/* 判定是否进行不平衡修正 */
   {
	   if (water_full_flag == 0)		/* 补水 */
	    {
			if (balance_inlet_flag == 0)
			 {				 
				 balance_inlet_flag = 1;
//				 inlet(0, 0, water_level_buff);
				 output_buff |= INLET;
				 inlet_2m_buff = INLET_SET_TIME;			 
			 }
			 
			if (inlet_2m_buff >= 0)
			inlet_2m_buff --;		 

			if (balance_stream_flag == 1)
			 {
				 balance_inlet_flag = 0;
				 balance_stream_flag = 0;
				 balance_drain_flag = 0;
				 inlet_2m_buff = INLET_SET_TIME;
				 drain_2m_buff = DRAIN_SET_TIME;
				 spin_balance_time_buff = 60;					  
				 unbalance_flag = 0;
			 }			 
			 
	    }
	   if (water_full_flag == 1)		/* 补水完成时进行不平衡修正的平衡水流洗涤过程 */
	    {
			if (balance_stream_flag == 0)
			 {
				balance_stream_flag = 1;
			 	output_buff &= (~INLET);
			 	stream_buff = BALANCE_STREAM;
			 	spin_balance_time_buff = 60;
			 }
			
			if (spin_balance_time_buff > 0)
			 {
				 spin_balance_time_buff --;
			 }
			if (spin_balance_time_buff == 0)
			 {
				 stream_buff = STREAM_STOP;
				 output_buff &= (~CW);
				 output_buff &= (~CCW);
				 
				 if (water_full_flag != 0)
				  {
					  if (balance_drain_flag == 0)
					   {
						   balance_drain_flag = 1;
						   drain_2m_buff = DRAIN_SET_TIME;
						   output_buff |= DRAIN;
//						   drain();
					   }
					   
					  if(drain_2m_buff >= 0)
					  drain_2m_buff --;
				  }

			 }
	    }
	   return;
   }

  else if (interm_spin_time == 135)		/* 间断脱水时间为135s时,进行9次10s/5s组合 */
   {  
    if (interm_spin_10s_buff > 0)
	 {
		 mot_cycle_buff = MOT_RIGHT;
		 output_buff |= CW;
		 	
		 interm_spin_10s_buff --;
		 process_left_time --;
	 }
    if (interm_spin_10s_buff == 0)
     {
        mot_cycle_buff = MOT_STOP;
		output_buff &= (~CW);
		
	    if (interm_spin_5s_buff > 0)
		 {
	    	interm_spin_5s_buff --;
			process_left_time --;
		 }
	    if (interm_spin_5s_buff == 0)
	     {
		    interm_spin_10s_buff = 10;
		    interm_spin_5s_buff = 5;
				 
		    interm_spin_cycle ++;
		    if (interm_spin_cycle == 9)
		     {
			   interm_spin_cycle = 0;
			   
			   process_left_time = 0;			   
		       operation_counter ++;
			   pass_time_counter ++;
			   
			   mot_cycle_buff = MOT_RIGHT;
			   output_buff |= CW;
		       return;
		     }
	     }
        else
	    return;
     }
    else
    return;
   }
  else if (interm_spin_time != 135)	/* 间断脱水时间不为135s时,根据情况进行对应次数4s/3s组合 */
   {  
    if (interm_spin_4s_buff > 0)
	 {
		 mot_cycle_buff = MOT_RIGHT;
		 output_buff |= CW;
		 
		 interm_spin_4s_buff --;
		 process_left_time --;
	 }
    if (interm_spin_4s_buff == 0)
     {
        mot_cycle_buff = MOT_STOP;
		output_buff &= (~CW);
		
	    if (interm_spin_3s_buff > 0)
		 {
			 process_left_time --;
	    	interm_spin_3s_buff --;
		 }
	    if (interm_spin_3s_buff == 0)
	     {
		    interm_spin_4s_buff = 4;
		    interm_spin_3s_buff = 3;
				 
		    interm_spin_cycle ++;
		    if (interm_spin_time == 20)			/* 间断脱水时间为20s时,进行3次4s/3s组合 */
		     {
		       if (interm_spin_cycle == 3)
		        {
			      interm_spin_cycle = 0;
				  
				  process_left_time = 0;				  
				  pass_time_counter ++;
		          operation_counter ++;
				  
			      mot_cycle_buff = MOT_RIGHT;
				  output_buff |= CW;
				  				  
		          return;
		        }
		     }
		    else if (interm_spin_time == 30)	/* 间断脱水时间为30s时,进行4次4s/3s组合 */
		     { 
		       if (interm_spin_cycle == 4)
		        {
			      interm_spin_cycle = 0;
				  
				  process_left_time = 0;
		          operation_counter ++;
				  pass_time_counter ++;
				  
			      mot_cycle_buff = MOT_RIGHT;
				  output_buff |= CW;
				  
		          return;
		        }
		     }
		    else if (interm_spin_time == 60)	/* 间断脱水时间为60s时,进行8次4s/3s组合 */
		     {
		       if (interm_spin_cycle == 8)
		        {
			      interm_spin_cycle = 0;
				  
				  process_left_time = 0;				  
		          operation_counter ++;
				  pass_time_counter ++;
				  
			      mot_cycle_buff = MOT_RIGHT;
				  output_buff |= CW;
				  
		          return;
		        }
		     }
		    else if (interm_spin_time >= 255)	/* 间断脱水时间大于255s时,进行简短脱水时间/7次4s/3s组合 */
		     {
		       if (interm_spin_cycle == interm_spin_time/7)
		        {
			      interm_spin_cycle = 0;

⌨️ 快捷键说明

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