Simple program used to calibrate AFRO ESC's from HobbyKing

Dependencies:   mbed

Used to calibrate 4 ESC's at once. Connect each ESC's PWM input pin to p22, p23, p24, p25 respectively. This will calibrate the ESC's with a maximum PWM pulse width of 1860 and a minimum of 1060. These numbers can be changed to match your setup.

Committer:
joe4465
Date:
Thu Sep 18 08:33:53 2014 +0000
Revision:
0:974ec566f994
Final version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joe4465 0:974ec566f994 1 #include "mbed.h"
joe4465 0:974ec566f994 2
joe4465 0:974ec566f994 3 DigitalOut myled(LED1);
joe4465 0:974ec566f994 4 Serial pc(USBTX, USBRX); // tx, rx
joe4465 0:974ec566f994 5
joe4465 0:974ec566f994 6 PwmOut _motor1(p22);
joe4465 0:974ec566f994 7 PwmOut _motor2(p23);
joe4465 0:974ec566f994 8 PwmOut _motor3(p24);
joe4465 0:974ec566f994 9 PwmOut _motor4(p25);
joe4465 0:974ec566f994 10
joe4465 0:974ec566f994 11 int main()
joe4465 0:974ec566f994 12 {
joe4465 0:974ec566f994 13 float period = 1.0 / 500;
joe4465 0:974ec566f994 14 _motor1.period(period);
joe4465 0:974ec566f994 15 _motor2.period(period);
joe4465 0:974ec566f994 16 _motor3.period(period);
joe4465 0:974ec566f994 17 _motor4.period(period);
joe4465 0:974ec566f994 18
joe4465 0:974ec566f994 19 _motor1.pulsewidth_us(1860);
joe4465 0:974ec566f994 20 _motor2.pulsewidth_us(1860);
joe4465 0:974ec566f994 21 _motor3.pulsewidth_us(1860);
joe4465 0:974ec566f994 22 _motor4.pulsewidth_us(1860);
joe4465 0:974ec566f994 23
joe4465 0:974ec566f994 24 myled = 1;
joe4465 0:974ec566f994 25
joe4465 0:974ec566f994 26 while(1)
joe4465 0:974ec566f994 27 {
joe4465 0:974ec566f994 28 if(pc.readable())
joe4465 0:974ec566f994 29 {
joe4465 0:974ec566f994 30 if(pc.getc() == 'a')
joe4465 0:974ec566f994 31 {
joe4465 0:974ec566f994 32 myled = 0;
joe4465 0:974ec566f994 33 _motor1.pulsewidth_us(1060);
joe4465 0:974ec566f994 34 _motor2.pulsewidth_us(1060);
joe4465 0:974ec566f994 35 _motor3.pulsewidth_us(1060);
joe4465 0:974ec566f994 36 _motor4.pulsewidth_us(1060);
joe4465 0:974ec566f994 37 }
joe4465 0:974ec566f994 38 }
joe4465 0:974ec566f994 39 }
joe4465 0:974ec566f994 40 }