Mi domandavo se questo codice che ho trovato puo' funzionare (non ho provato) per calibrare gli esc via software:
/*
www.fuzzydrone.org
by Bogdan Matei
*/
//#include <Servo.h>
#include <ServoTimer2.h>
ServoTimer2 serv1;
ServoTimer2 serv2;
ServoTimer2 serv3;
ServoTimer2 serv4;
ServoTimer2 serv5;
// a maximum of eight servo objects can be created
#define PPM_PIN_INTERRUPT attachInterrupt(0, rxInt, RISING); //PIN 0
volatile uint16_t rcValue[8] = {1502,1502,1502,1502,1502,1502,1502,1502}; // interval [1000;2000]
void rxInt() {
uint16_t now,diff;
static uint16_t last = 0;
static uint8_t chan = 0;
now = micros();
diff = now - last;
last = now;
if(diff>3000) chan = 0;
else {
if(900<diff && diff<2200 && chan<8 ) { //Only if the signal is between these values it is valid, otherwise the f
ailsafe counter should move up
rcValue[chan] = diff;
#if defined(FAILSAFE)
if(failsafeCnt > 20) failsafeCnt -= 20; else failsafeCnt = 0; // clear FailSafe counter - added by MIS //in
compatible to quadroppm
#endif
}
chan++;
}
}
int pos = 0; // variable to store the servo position
int val=0;
int minv=50;
int maxv=170;
void setup()
{
Serial.begin(115200);
PPM_PIN_INTERRUPT
//11,10,9,3
serv1.attach(11);
serv2.attach(10);
serv3.attach(9);
serv4.attach(3);
serv5.attach(6);
Serial.print(rcValue[2]);Serial.print(" ");Serial.println(val);
}
void loop()
{
// val=map(rcValue[2], 1000, 2000, 0, 180);
// val = constrain(val, minv, maxv);
Serial.print(rcValue[2]);Serial.print(" ");Serial.println("");
serv1.write(rcValue[2]);
serv2.write(rcValue[2]);
serv3.write(rcValue[2]);
serv4.write(rcValue[2]);
serv5.write(rcValue[2]);
//delay(1);
}
Nel particolare non capisco questo
volatile uint16_t rcValue[8] = {1502,1502,1502,1502,1502,1502,1502,1502}; // interval [1000;2000]
Sarebbe bello evitarsi la sbatta di farlo a mano, e poi tanto mi vengono sempre tutti diversi...
ps. ho provato la versione 2.0 e funziona sostanzialmente bene come la 1.8 e non vedo l'ora di provare qualche novita' della due.