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

📄 weld_all.c

📁 电焊机点焊程序
💻 C
📖 第 1 页 / 共 4 页
字号:
					  {   //// for first time set weld current = 90 
                          high_byte_1 = 0xea; low_byte_1 = 0x33; first_time = 1;
					  }
					  else
					  {
                          first_time = 0;
					  }
				   }
				   //// enable Syn interrupt
				   EX0 = 1;
		           break;
           //// now welding-2.  
           case 1: con = 0;
                   if(weld_adjust)
 		           {
		              //// check safe for every Syn
		              if(EXF2==1)
		              {
                           EXF2 = 0; safe = 1;
				      }				   
				      else 
				      {
				           //// no valid feedback signal
						   //// stop 
						   con = 0;
						   relay_A = 0;
						   relay_B = 0;
                           alarm_scr();
						   //// stop welding
                      	   EX0 = 0; start = 0;
						   //// current_n = 0 for next welding
						   current_n = 0;
						   //// disable interrupts of ZLG7289 and Satrt-A\B
						   EX1 = 0; ET2 = 0;
				   		   break;
    			      }
					  if(first_time)
					  {
                          TH1 = high_byte_1; TL1 = low_byte_1; first_time = 0;
					  }
					  else
					  {
		                  TH1 = high_byte_0; TL1 = low_byte_0;  		                  
					  }
					  TR1 = 1; ET1 = 1; 
				   }
		           counter = counter - 1;
				   if(counter==0)
				   {
                      counter = 2*parameter_value[10+criterion]; current_n = 2;
					  //// turn on the hold LED
				      segment(3,1);
					  segment(5,0);
				   }
				   //// enable Syn interrupt
				   EX0 = 1;
		           break;
		   //// now holding
		   case 2: con = 0;
		           counter = counter - 1;
		           //// enable Syn interrupt
 				   EX0 = 1;
		           if(counter==0)
				   {
                      counter = 2*parameter_value[11+criterion]; 
					  //// It's a one time welding
					  if(counter==0)
					  {  
					     //// set flag standing for end of the welding
						 start = 0;
						 //// enable interrupt for ZLG7289						 
						 EX1 = 1;			
						 //// enable interrupt for Start-A\B
						 ET2 = 1;
						 EXEN2 = 1;
						 EXF2 = 0;
			 			 //// disable Syn interrupt
 				         EX0 = 0;
						 //// current_n = 0 for next welding
						 current_n = 0;
						 //// shut down the two relays
						 relay_A = 0;
						 relay_B = 0;
						 //// no state LED is on
                         segment(3,0);
					  }
					  else 
					  {
					     current_n = 3;
						 //// turn on the stop LED
				         segment(3,0);
						 segment(2,1);
						 //// shut down the two relays
						 relay_A = 0;
						 relay_B = 0;
					  }
				   }				   
		           break;
		   //// now stoped
		   case 3: counter = counter - 1;
		           //// enable Syn interrupt
				   EX0 = 1;
		           if(counter==0)
				   {  
				      //// wether continue the welding
				      if((start_a==a_state)&&(start_b==b_state))
					  {  //// no state LED is on
				         segment(2,0);
					     start = 0;
					     current_n = 0;
                         counter = 2*parameter_value[1+criterion]; 						 	 
					  }
					  else
					  {					     
						 //// set flag standing for end of the welding
						 start = 0;  
  					     //// current_n = 0 for next welding
						 current_n = 0;
						 //// enable interrupt for ZLG7289
						 EX1 = 1;
						 //// enable interrupt for Start-A\B
						 ET2 = 1;
						 EXEN2 = 1;
						 EXF2 = 0;
						 //// disable Syn interrupt   
						 EX0 = 0;
						 //// shut the two relays
						 relay_A = 0;
						 relay_B = 0;
						 //// no state LED is on
						 segment(2,0);
					  }
				   }				   
		           break;
		   default: _nop_();
		  }
          break;
   ////  for normal mode  **************************************************************************************
   case 2:switch(current_n)
		  {
           //// the prepare time
		   case 0: if(start==0) 
		           {				       
					   start = 1;
					   //// two relays
					   relay_A = a_state;
					   relay_B = b_state;					     
					   counter = 2*parameter_value[0+criterion];
					   //// turn on the press LED
				       segment(6,1);
					   //// skip prepare if the prepare time is 0
					   if(counter==0)
					   {
                           counter = 2*parameter_value[1+criterion]; 
						   current_n = 1;
						   //// enable Syn interrupt
				           EX0 = 1;
						   break;
					   }
				   }
                   counter = counter - 1;  			   		   
				   if(counter==0) 
				   {
                        counter = 2*parameter_value[1+criterion]; current_n = 1;
				   }				   
				   //// enable Syn interrupt
				   EX0 = 1;
                   //// not enough time for prepare,so stop welding
				   if((~start_a)&(~start_b))
				   {
        		        //// set flag standing for end of the welding
				        start = 0;
				        //// enable interrupt for ZLG7289						 
				        EX1 = 1;			
				        //// enable interrupt for Start-A\B
				        ET2 = 1;
			            EXEN2 = 1;
						EXF2 = 0;
			 	        //// disable Syn interrupt
 			            EX0 = 0;
			            //// current_n = 0 for next welding
			            current_n = 0;
				        //// shut the two relays
				        relay_A = 0;
				        relay_B = 0;
						//// no state LED is on
						segment(6,0);
				   }
		           break;
           //// the the press time
		   case 1: counter = counter - 1;
		           if(counter==0)
				   {  //// wether both welding-1 and cooling-1 are not needed		
	      		      if(parameter_value[2+criterion]==0)
					  {   //// wether cooling-1 is not needed
                          if(parameter_value[4+criterion]==0)
						  {   //////// both welding-1 and cooling-1 are not needed,so prepare for welding-2
						      //// turn on the weld LED
				              segment(5,1);
					          segment(6,0);
                              counter = 2*parameter_value[5+criterion]; current_n = 4;
					          weld_current = parameter_value[6+criterion];
					          //// timer = 66535-(9900-48*weld_current)
					          timer = 55635 + 48*weld_current;  
					          high_byte_0 = timer/256; low_byte_0 = timer%256;	
							  //// wether the weld current is bigger than 100
					          if(weld_current>100)
					          {
                                   high_byte_1 = 0xea; low_byte_1 = 0x33; first_time = 1;
					          }
					          else
					          {
                                   first_time = 0;
					          }
                              //// enable Syn interrupt
				              EX0 = 1;
		                      break;
						  }
						  //// welding-1 is not needed,so prepare for cooling-1
						  else
						  {
                               counter = 2*parameter_value[4+criterion]; current_n = 3;
					           //// turn on the cool LED
				               segment(4,1);
					           segment(6,0);
							   //// enable Syn interrupt
				               EX0 = 1;
		                       break;
						  }
					  }
				      else
					  {
				         //// turn on the weld LED for welding-1
				         segment(6,0); 
					     segment(5,1);
				         counter = 2*parameter_value[2+criterion]; current_n = 2;
  					     weld_current = parameter_value[3+criterion];		
			  		     //// timer = 66535-(9900-48*weld_current)
					     timer = 55635 + 48*weld_current;  
					     high_byte_0 = timer/256; low_byte_0 = timer%256;	
						 //// wether the weld current is bigger than 100
					     if(weld_current>100)
					     {
                             high_byte_1 = 0xea; low_byte_1 = 0x33; first_time = 1;
					     }
					     else
					     {
                             first_time = 0;
					     }
			     	  }
				   }
				   //// enable Syn interrupt
				   EX0 = 1;
		           break;
           //// now welding-1. 
	       case 2:con = 0;
                  if(weld_adjust)
		          {
		              //// check safe for every Syn		                     
		              if(EXF2==1)
		              {
                           EXF2 = 0; safe = 1;
				      }				   
				      else 
				      {    //// no valid feedback signal
					       con = 0;
						   relay_A = 0;
						   relay_B = 0;
						   alarm_scr();
						   //// stop welding
                      	   EX0 = 0; start = 0;
						   //// current_n = 0 for next welding
						   current_n = 0;
						   //// disable interrupts of ZLG7289 and Satrt-A\B
						   EX1 = 0; ET2 = 0;
				   		   break;
    			      }   
		              if(first_time)
					  {
                          TH1 = high_byte_1; TL1 = low_byte_1; first_time = 0;
					  }
					  else
					  {
		                  TH1 = high_byte_0; TL1 = low_byte_0;  		                  
					  }  
		              TR1 = 1; ET1 = 1; 
				   }
		           counter = counter - 1;
				   if(counter==0)
				   {  //// wether skip cooling-1
				      if(parameter_value[4+criterion]==0)
					  {  //// prepare for welding-2
					     counter = 2*parameter_value[5+criterion]; current_n = 4;
					     weld_current = parameter_value[6+criterion];
					     //// timer = 66535-(9900-48*weld_current)
					     timer = 55635 + 48*weld_current;  
					     high_byte_0 = timer/256; low_byte_0 = timer%256;	
						 //// wether the weld current is bigger than 100
					     if(weld_current>100)
					     {
                             high_byte_1 = 0xea; low_byte_1 = 0x33; first_time = 1;
					     }
					     else
					     {
                             first_time = 0;
					     }
                         //// enable Syn interrupt
				         EX0 = 1;
		                 break;
					  }
				      else
					  {  //// prepare for cooling-1
                         counter = 2*parameter_value[4+criterion]; current_n = 3;
					     //// turn on the cool LED
				         segment(4,1);
					     segment(5,0);
					  }
				   }
				   //// enable Syn interrupt
				   EX0 = 1;
		           break;
		   //// now cooling-1
		   case 3: con = 0;
		           counter = counter - 1;
				   if(counter==0) 
				   { 
				      //// turn on the weld LED,prepare for welding-2
				      segment(5,1);
					  segment(4,0);
                      counter = 2*parameter_value[5+criterion]; current_n = 4;
					  weld_current = parameter_value[6+criterion];
					  //// timer = 66535-(9900-48*weld_current)
					  timer = 55635 + 48*weld_current;  
					  high_byte_0 = timer/256; low_byte_0 = timer%256;		
			  		  //// wether the weld current is bigger than 100
					  if(weld_current>100)
					  {
                          high_byte_1 = 0xea; low_byte_1 = 0x33; first_time = 1;
					  }
					  else
					  {
                          first_time = 0;
					  }
				   }
				   //// enable Syn interrupt
				   EX0 = 1;
		           break;
		   //// now welding-2
		   case 4:con = 0;
                  if(weld_adjust)
		          {
		              //// check safe for every Syn		                     
		              if(EXF2==1)
		              {
                           EXF2 = 0; safe = 1;
				      }				   
				      else 
				      {    //// no valid feedback signal
					       con = 0;
						   relay_A = 0;
						   relay_B = 0;
						   alarm_scr();
						   //// stop welding
                      	   EX0 = 0; start = 0;
						   //// current_n = 0 for next welding
					       current_n = 0;
						   //// disable interrupts of ZLG7289 and Satrt-A\B
						   EX1 = 0; ET2 = 0;
				   		   break;
    			      }   
		              if(first_time)
					  {
                          TH1 = high_byte_1; TL1 = low_byte_1; first_time = 0;
					  }
					  else
					  {
		                  TH1 = high_byte_0; TL1 = low_byte_0;  		                  
					  }  
		              TR1 = 1; ET1 = 1;  
				   }
		           counter = counter - 1;
				   if(counter==0)
				   {  //// skip cooling-2

⌨️ 快捷键说明

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