Пример #1
0
void Run_Task(void)
{
	if( rxBuffer.cmd == CMD_PCR_RUN && 
		currentTargetTemp != rxBuffer.currentTargetTemp )
	{
		prevTargetTemp = currentTargetTemp;
		currentTargetTemp = rxBuffer.currentTargetTemp;

		if ( !(fabs(prevTargetTemp - currentTargetTemp) < .5) ) 
		{
			lastIntegral = 0;
			lastError = 0;
		}
	}
	
	//in Run_Task, 150901 kimjd
	if(prevTargetTemp>currentTargetTemp ) 
	{
		if( currentTemp>prevTargetTemp-1 ) 
		{
			Fan_ON();
			fanFlag = 1;
		}

		if( (fanFlag == 1) && (currentTemp-currentTargetTemp<= FAN_STOP_TEMPDIF) ) 
		{
			Fan_OFF();
			fanFlag = 2;
			freeRunning = TRUE;
		}
	}
	else
	{
		fallingTargetArrival = 0;
		fanFlag = 0;
		Fan_OFF();
	}
	PID_Control();
}
Пример #2
0
int main()
{
  RCC_Configuration();
  NVIC_Configuration();
  GPIO_Configuration();
 
  USART_Configuration(USART3, 230400); 
  USART_Configuration(USART2, 9600);
  USART_Configuration(UART4, 9600);
  
  TIM_Configuration();
  initailze_wifiSet();
  Initailze_value();
  
  GPIO_SetBits(GPIOB, GPIO_Pin_0);
  delay_ms(100);
       
  while(!Wifi_fly_Set)
 {
    if(Wifi_Connect)
    {
      printf("AT+CIPSEND=0,21\n");
      delay_ms(150);
      printf("Angle,NN\n");     
      delay_ms(350);
    }
 }
  delay_ms(150);
  Send_Count = 0;
  while(1) {     
   
      
      if((Send_Count%5) == 0)        Tx_Data16t(USART3, 0x5555);
      else if((Send_Count%5) == 1)   Tx_Data16t(USART3, Drone_Control.axis[ROLL].Target);
      else if((Send_Count%5) == 2)   Tx_Data16t(USART3, Drone_Control.axis[PITCH].Target);
      else if((Send_Count%5) == 3)   Tx_Data16t(USART3, Drone_Control.Throttle);
      else if((Send_Count%5) == 4)   Tx_Data16t(USART3, 0xFFFF);

      if(Send_Exit)
      {
        GPIO_ResetBits(GPIOB, GPIO_Pin_1);
        if(Send_Exit > 200)  {   Drone_Control.Throttle = 100; /*Send_Throttle = 0; */  }
        else                 {   Send_Exit++;   }
      }
      
            
      if(Wifi_Land_Set) {
        Send_Throttle = 0;
        if(Drone_Control.axis[HEIGHT].Current < 3000){ Send_Exit = 1;  Wifi_Land_Set = 0;}
        else Drone_Control.Throttle -= 2; 
      }  
      
      if(Send_Count == 4){
     
        GPIO_SetBits(GPIOA, GPIO_Pin_8);
        delay_us(10);
        GPIO_ResetBits(GPIOA, GPIO_Pin_8);
        if(Send_Throttle)  PID_Control();
        Send_Count++;
      }
      
      
      else if(Send_Count == 9)
      {
        GPIO_SetBits(GPIOA, GPIO_Pin_5);
        delay_us(10);
        GPIO_ResetBits(GPIOA, GPIO_Pin_5);
 
        Send_Count = 0;
        if(Send_Throttle)  PID_Control();
        
      }
      else  Send_Count++;

      delay_ms(1);
  }
}