unit test for brushless motors using a potentiometer and a castle creations esc with 0.5 center duty cycle

Dependencies:   ESC Servo mbed

Fork of brushlessmotor by jetfishteam

Committer:
rkk
Date:
Fri Feb 26 14:35:02 2016 +0000
Revision:
3:605f216167f6
Parent:
2:040b8c8f4f92
brushless test program

Who changed what in which revision?

UserRevisionLine numberNew contents of line
demaille 0:187bb46ed128 1 #include "mbed.h"
demaille 0:187bb46ed128 2 #include "Servo.h"
demaille 0:187bb46ed128 3 #include "esc.h"
demaille 0:187bb46ed128 4 #include "MainController.h"
demaille 0:187bb46ed128 5
demaille 2:040b8c8f4f92 6 //ESC esc1(p25);
demaille 0:187bb46ed128 7 //
demaille 0:187bb46ed128 8 //Serial pc(USBTX, USBRX); //serial communication via usb cable to display terminal //https://developer.mbed.org/handbook/SerialPC
demaille 0:187bb46ed128 9 //Timer t; //this is a timer interrupt that is
demaille 0:187bb46ed128 10 //float throttle_var = 0.5;
demaille 0:187bb46ed128 11 //
demaille 0:187bb46ed128 12 //
demaille 0:187bb46ed128 13 //int main() {
demaille 0:187bb46ed128 14 // //arm motor by keeping throttle in neutral position
demaille 0:187bb46ed128 15 // throttle_var = 0.5;
demaille 0:187bb46ed128 16 // esc1 = throttle_var;
demaille 0:187bb46ed128 17 // esc1();
demaille 0:187bb46ed128 18 // wait_ms (8000);
demaille 0:187bb46ed128 19 //
demaille 0:187bb46ed128 20 //
demaille 0:187bb46ed128 21 // while(1){
demaille 0:187bb46ed128 22 // //... update throttle_var ...
demaille 0:187bb46ed128 23 // throttle_var = 0.15;
demaille 0:187bb46ed128 24 // esc1 = throttle_var; //memorize the throttle value (it doesn't send it to the ESC).
demaille 0:187bb46ed128 25 // esc1(); //actually sets the throttle to the ESC.
demaille 0:187bb46ed128 26 // //20ms is the default period of the ESC pwm; the ESC may not run faster.
demaille 0:187bb46ed128 27 // wait_ms(3000);
demaille 0:187bb46ed128 28 //
demaille 0:187bb46ed128 29 // //flip direction no braking in between
demaille 0:187bb46ed128 30 // throttle_var = .85;
demaille 0:187bb46ed128 31 // esc1 = throttle_var;
demaille 0:187bb46ed128 32 // esc1();
demaille 0:187bb46ed128 33 // wait_ms(3000);
demaille 0:187bb46ed128 34 //
demaille 0:187bb46ed128 35 // }
demaille 0:187bb46ed128 36 //}
demaille 0:187bb46ed128 37
demaille 0:187bb46ed128 38 //////////////////////////////////////////////////////////////////////
demaille 0:187bb46ed128 39
demaille 0:187bb46ed128 40
demaille 0:187bb46ed128 41 Serial pc(USBTX, USBRX); //serial communication via usb cable to display terminal //https://developer.mbed.org/handbook/SerialPC
demaille 0:187bb46ed128 42 Timer t; //this is a timer interrupt that is
demaille 0:187bb46ed128 43
demaille 0:187bb46ed128 44 int main()
demaille 0:187bb46ed128 45 {
demaille 0:187bb46ed128 46 t.start();
demaille 0:187bb46ed128 47
rkk 3:605f216167f6 48 MainController mC;
demaille 0:187bb46ed128 49
rkk 3:605f216167f6 50 mC.start();
demaille 0:187bb46ed128 51
demaille 0:187bb46ed128 52 while(true) {
demaille 0:187bb46ed128 53
rkk 3:605f216167f6 54 pc.printf("amp: %.4f, dutyCycle %.4f, t: %.4f\n",
rkk 3:605f216167f6 55 mC.getAmplitude(), mC.getDutyCycle(), t.read());
demaille 0:187bb46ed128 56
demaille 0:187bb46ed128 57 wait_ms(900);
demaille 0:187bb46ed128 58 }
demaille 0:187bb46ed128 59 //t.stop();
rkk 3:605f216167f6 60 //mC.stop();
demaille 2:040b8c8f4f92 61 }