Тестирование моторов+ESC на предрасположенность к потере синхронизации

Код для ардуино. Пояснения и результаты чуть позже.
Обсуждение: rcopen.com/forum/f123/topic380040

/*************************************************************************************
  Sergey dROb, Oct 2014, 

  This program will test ESC+motor (or servo), sending range of valid PPM signals to the output pin at "servoPin"
  Primarily, this is used to detect sync issues, happening when Motor is quickly accelerating from low to high speed.

  If LCD display is connected - it displays number of test and Start-End microseconds of PPM signal (you can then record, which scenario is problem for your motor)

  Connection: Plug the LCD Keypad to the Arduino. Output PPM will be on servoPin. Conect GND and servoPin to ESC.
  Discussion: 
**************************************************************************************/

#include <LiquidCrystal.h>
#include <Servo.h>

Servo myservo;  // create servo object to control a servo

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);           // select the pins used on the LCD panel

int servoPin = 22;

int lcd_key     = 0;
int adc_key_in  = 0;

#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5


void setup(){
  lcd.begin(16, 2);
  lcd.setCursor(0,0);
  lcd.print("Starting motor");

  lcd.setCursor(0,1);
  lcd.print("In 3 seconds..");
  myservo.attach(servoPin);

  myservo.writeMicroseconds(950);  // Init ESC

  delay(3000); // Waiting 3 seconds to avoid chopping of user hands

  myservo.writeMicroseconds(1250); // Start motor on low speed
}


void loop(){

  int test_no=1;
  int start_uS;
  int end_uS;
  int tact_delay=1000;

  lcd.clear();
  lcd.print("No: Start: End:");


  // Main cycle - start series of cycles, when motor jumps from set of speeds to higher set of speeds.
  for (start_uS=1100; start_uS<=1900; start_uS+=100){  // Start PPM from which motor will jump to End PPM
    servoOutput(start_uS);
    delay(tact_delay);
      for (end_uS=start_uS+100; end_uS<=1900; end_uS+=100){ // End PPM of the current cycle
        displayData(test_no, start_uS, end_uS);

        servoOutput(end_uS);
        tact_delay=end_uS - start_uS; if (tact_delay<400) tact_delay=400;// Intellectual delay. Pause will be bigger if motor have to change the speed a lot. But not less 0.4 sec
        delay(tact_delay);
        servoOutput(start_uS);
        delay(tact_delay);
        test_no++;
     }
  }

  lcd.setCursor(0,1);

  lcd_key = read_LCD_buttons();
  dispatch_keys(lcd_key);
}


void servoOutput(int uS){
  myservo.writeMicroseconds(uS);
}

void displayData(int test_no, int s_uS, int e_uS){
  lcd.setCursor(1,1);
  lcd.print(test_no);
  lcd.setCursor(5,1);
  lcd.print(s_uS);
  lcd.setCursor(11,1);
  lcd.print(e_uS);
  lcd.print("     ");
}

//////////////////////////////////////////////////////////////////////////////
// This is actually not really used. Added to be able to get Keypad presses //
//////////////////////////////////////////////////////////////////////////////

int read_LCD_buttons(){               // read the buttons
    adc_key_in = analogRead(0);       // read the value from the sensor

    if (adc_key_in > 1000) return btnNONE;

    if (adc_key_in < 50)   return btnRIGHT;
    if (adc_key_in < 250)  return btnUP;
    if (adc_key_in < 450)  return btnDOWN;
    if (adc_key_in < 650)  return btnLEFT;
    if (adc_key_in < 850)  return btnSELECT;

    return btnNONE;                // when all others fail, return this.
}




void dispatch_keys(int key){
     switch (key){

       case btnRIGHT:{
            break;
       }
       case btnLEFT:{
            break;
       }
       case btnUP:{
             lcd.print("UP    ");
             break;
       }
       case btnDOWN:{
             lcd.print("DOWN  ");
             break;
       }
       case btnSELECT:{
             lcd.print("SELECT");
             break;
             setup();
       }
       case btnNONE:{
             ("NONE  ");
             break;
       }
   }

}
  • 965