jetfishteam / Mbed 2 deprecated brushless_test

Dependencies:   ESC Servo mbed

Fork of brushlessmotor by jetfishteam

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "Servo.h"
00003 #include "esc.h"
00004 #include "MainController.h"
00005 
00006 //ESC esc1(p25);
00007 //
00008 //Serial pc(USBTX, USBRX); //serial communication via usb cable to display terminal //https://developer.mbed.org/handbook/SerialPC
00009 //Timer t; //this is a timer interrupt that is 
00010 //float throttle_var = 0.5; 
00011 //
00012 //
00013 //int main() {
00014 //    //arm motor by keeping throttle in neutral position
00015 //    throttle_var = 0.5; 
00016 //    esc1 = throttle_var;
00017 //    esc1();
00018 //    wait_ms (8000);
00019 //    
00020 //        
00021 //    while(1){
00022 //        //... update throttle_var ...
00023 //        throttle_var = 0.15;
00024 //        esc1 = throttle_var; //memorize the throttle value (it doesn't send it to the ESC).
00025 //        esc1(); //actually sets the throttle to the ESC.
00026 //        //20ms is the default period of the ESC pwm; the ESC may not run faster.
00027 //        wait_ms(3000);  
00028 //        
00029 //        //flip direction no braking in between
00030 //        throttle_var = .85;
00031 //        esc1 = throttle_var;
00032 //        esc1();
00033 //        wait_ms(3000);
00034 //        
00035 //    }
00036 //}
00037 
00038 //////////////////////////////////////////////////////////////////////
00039 
00040 
00041 Serial pc(USBTX, USBRX); //serial communication via usb cable to display terminal //https://developer.mbed.org/handbook/SerialPC
00042 Timer t; //this is a timer interrupt that is 
00043 
00044 int main()
00045 {
00046     t.start();
00047     
00048     MainController mC;
00049        
00050     mC.start();
00051 
00052     while(true) {
00053   
00054         pc.printf("amp: %.4f, dutyCycle %.4f, t: %.4f\n",
00055          mC.getAmplitude(), mC.getDutyCycle(), t.read());
00056 
00057         wait_ms(900);
00058     }
00059     //t.stop();
00060     //mC.stop();
00061 }