Thursday, 16 January 2020




RC SERVO BASED, GOVERNOR FOR HOME BUILT ALTERNATOR/PETROL ENGINE SET.

Positive portion of sine wave from the alternator plus load current via CT's plus a setting are used to generate a pulse to a servo, driving the engine throttle. As load is increased or decreased, the proper signal length is sent to the servo.
Feel free to use.

Arduino NANO Sketch:
  // Electronic speed governor for petrol engine coupled to 3 phase alternator
  // The positive portion (on time) of the alternator frequency is measured
  // Potentiometer is used to increase speed if necessary
  // 3 x CT load current information is also used to increase speed if necessary
  // CT currents rectified and connected in series
  // Pulses are sent to RC servo coupled to engine throttle linkage

//////////////////////////////////////////////////////////////////
 ///////////////////////// Variable setup ////////////////////////
 float On_time_uSec;                   //integer for storing high time
  int division_value = 7;              // Change big value to smaller value in total_time_mSec. Determine by testing
   float total_time_mSec;              // Value after division
    int increase_speed_value = 0;      // Analogue value to zero
     int increase_speed_setting;       // Setting value after mapping to smaller value
      int servo_pulse;                 // Pulse to servo
       int increase_speed_Pin = 6;     // Analog 6 for value to increase speed from potentiometer
        int ct_Pin = 7;                // Analog 7 for current value from CT's to increase speed slightly
         int freq_Pin = 8;             // Digital pin 8 (PB0) for freq value from squaring IC 4093 
          int servo_Pin = 9;           // Digital pin 9 (PB1) for signal to servo
           int ct_mapped;              // CT analogue value to smaller value
            int ct_value = 0;          // CT analogue value to zero
           
void setup()
{
  pinMode(freq_Pin,INPUT);              // Set frequency pin to input
   pinMode(servo_Pin, OUTPUT);          // Set the servo pin as output
   
  //   Serial.begin(9600);               // Only used during testing
}

void loop()
{
//////////////////////////////////////////////////////////// 
///////////////// Read Analog values ///////////////////////   
   increase_speed_value = analogRead(increase_speed_Pin);               //read the increase speed pot pin
    increase_speed_setting  = map(increase_speed_value, 0, 1023, 0, 150);    // change to smaller value

   ct_value = analogRead(ct_Pin);                   // read the ct value pin
    ct_mapped  = map(ct_value, 0, 1023, 0, 100);    // change to smaller value
   
///////////////////////////////////////////////////////////////////     
///////////////// Read on time pulse length ///////////////////////   
    On_time_uSec = pulseIn(freq_Pin,HIGH);                // read the ontime of frequency on Pin 8
     total_time_mSec = (On_time_uSec)/division_value;    //change value to workable value for servo

///////////////Adding increase speed setting + CT values to servo pulse ///////////////////
    servo_pulse = (total_time_mSec) + (increase_speed_setting) + (ct_mapped);   // transfer value to pulse for servo

/////////////////////////////////////////////////////////////////     
///////////////// Limit the movement of servo ///////////////////
   if (servo_pulse <= 800)    // limit servo movement on low side
{
      servo_pulse = 800;      // limit servo movement on low side
}
   if (servo_pulse >= 2000)   // limit servo movement on high side
{
      servo_pulse = 2000;     // limit servo movement on high side
}

/////////////////////////////////////////////////////////////
///////////////// Send pulse to servo ///////////////////////
  digitalWrite(servo_Pin, HIGH);    // prepare servo pin for pulse to servo
   delayMicroseconds(servo_pulse);  // send pulse to servo
    digitalWrite(servo_Pin, LOW);   // sets the servo pin off
     delayMicroseconds(10000);      // waits for a 10 mSec

//   Serial.println("servo_pulse");          // used only to check initial values
//   Serial.println(servo_pulse);            // used only to check initial values

//    Serial.println("setting");             // used only to check initial values
//    Serial.println(setting);               // used only to check initial values

//     Serial.println("Total_time_mSec");    // used only to check initial values
//     Serial.println(Total_time_mSec);      // used only to check initial values

//      Serial.println("CT value");          // used only to check initial values
//      Serial.println(ct_mapped);           // used only to check initial values

}




No comments:

Post a Comment