Section 4: Flight-Control-Functions.

........ Emergency Motor Control Source Code .......

======= File-Name: 21_Emergency_Motor_Control.ino ========


//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++ Begin Emergency-Motor Control Function +++++++++++++
//              Last Update: 08-08-2022  
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

void Emergency_Motor_Control()
   {
    int Emrev_up_val;
    int Emrev_MIN = 0;    // Potmeter 'minimum' PWM count value for the map-formula
    int Emrev_MAX = 290;  // was 308, the 'maximum' measured drone potmeter value for map-formula 
     
// Read the PWM to Analog Value at Teensy analog pin 14.
// 10 bit: resolution is 1024=2**10 Values returned from 0-3.3V by the Analog value
// Note: 0 to 3.3Volt results in values from 0 to 1023 for a 10bit ADC
   EmVreadValue = analogRead(EmVPin14);  // Teensy Pin 14 for Analog Input to read  Emergency PWM to Voltage values
//   EmCorrection => This value is listed in Set-Up function
   Emrev_up_val = abs(EmVreadValue - EmCorrection); //runs from 2 to 290 
   if (Emrev_up_val >= Emrev_MAX) Emrev_up_val = Emrev_MAX;

// Serial.print("22:  Emrev_up_val =  ");
// Serial.println(Emrev_up_val);  //runs between 0 and 290

// Rev-Up Motor with Servo-3    
// Emrev_up_Motor = map(Emrev_up_val, Emrev_MIN, Emrev_MAX, Emrev_upPWM_min, Emrev_upPWM_max);

   Emrev_up_Motor = map(Emrev_up_val, Emrev_MIN, Emrev_MAX, 1600, 2400);
// Serial.print("22:  Emrev_up_Motor =  ");
// Serial.println(Emrev_up_Motor);  //runs between 1600 and 2400
   
   }  
  
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++ End Emergency-Motor Control Function +++++++++
//+++++++++++++++ End Emergency-Motor Control Function +++++++++
//+++++++++++++++ End Emergency-Motor Control Function +++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Free-Drones Company 2022