wesh gros, ajout des ref dans brushlessservo

Dependencies:   MPU6050 mbed

Fork of Gimbal_ENSEA by Thomas Giraud-Sauveur

Committer:
sype
Date:
Fri Jun 03 14:17:35 2016 +0000
Revision:
2:d0606d66af96
Parent:
0:63c6db89607f
Ajout ref brushlessservo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThomasGS 0:63c6db89607f 1 #include "mbed.h"
ThomasGS 0:63c6db89607f 2 #include "mycontroller.h"
ThomasGS 0:63c6db89607f 3 #include "MPU6050.h"
ThomasGS 0:63c6db89607f 4
ThomasGS 0:63c6db89607f 5 DigitalOut myled(LED1);
ThomasGS 0:63c6db89607f 6 Serial pc(USBTX, USBRX);
ThomasGS 0:63c6db89607f 7 Ticker filter;
ThomasGS 0:63c6db89607f 8 Ticker toggler1;
sype 2:d0606d66af96 9 MPU6050 mpu6050;
sype 2:d0606d66af96 10
sype 2:d0606d66af96 11 PwmOut pwmA1(PA_1);
sype 2:d0606d66af96 12 PwmOut pwmA2(PA_2);
sype 2:d0606d66af96 13 PwmOut pwmA3(PA_3);
sype 2:d0606d66af96 14
sype 2:d0606d66af96 15 PwmOut pwmB1(PA_4);
sype 2:d0606d66af96 16 PwmOut pwmB2(PA_5);
sype 2:d0606d66af96 17 PwmOut pwmB3(PA_6);
sype 2:d0606d66af96 18
sype 2:d0606d66af96 19 brushlessservo moteur(pwmA1,pwmA2,pwmA3);
sype 2:d0606d66af96 20 brushlessservo moteurB(pwmB1,pwmB2,pwmB3);
sype 2:d0606d66af96 21
ThomasGS 0:63c6db89607f 22 /*
ThomasGS 0:63c6db89607f 23 PwmOut pwm1A(PA_10);
ThomasGS 0:63c6db89607f 24 PwmOut pwm1B(PA_6);
ThomasGS 0:63c6db89607f 25 PwmOut pwm1C(PB_6);
ThomasGS 0:63c6db89607f 26 DigitalOut enable1A(PA_7);
ThomasGS 0:63c6db89607f 27 DigitalOut enable1B(PA_9);
ThomasGS 0:63c6db89607f 28 */
ThomasGS 0:63c6db89607f 29 float pitchAngle = 0;
ThomasGS 0:63c6db89607f 30 float rollAngle = 0;
ThomasGS 0:63c6db89607f 31
ThomasGS 0:63c6db89607f 32 void compFilter() {mpu6050.complementaryFilter(&pitchAngle, &rollAngle);}
ThomasGS 0:63c6db89607f 33 void toggle_led1() {myled!=myled;}
ThomasGS 0:63c6db89607f 34 void toggle_led2();
ThomasGS 0:63c6db89607f 35
ThomasGS 0:63c6db89607f 36 int main() {
ThomasGS 0:63c6db89607f 37 mpu6050.init();
ThomasGS 0:63c6db89607f 38 filter.attach(&compFilter, 0.005);
ThomasGS 0:63c6db89607f 39 wait(1);
ThomasGS 0:63c6db89607f 40 /*
ThomasGS 0:63c6db89607f 41 moteur.gotothetha(450);
ThomasGS 0:63c6db89607f 42 wait(1);
ThomasGS 0:63c6db89607f 43 moteur.gotothetha(0);
ThomasGS 0:63c6db89607f 44 wait(1);
ThomasGS 0:63c6db89607f 45 moteur.gotothetha(1350);
ThomasGS 0:63c6db89607f 46 moteur.gotothetha(0);
ThomasGS 0:63c6db89607f 47
ThomasGS 0:63c6db89607f 48 for(int i=0; i<1800;i+=5){
ThomasGS 0:63c6db89607f 49 moteur.gotothetha(i);
ThomasGS 0:63c6db89607f 50 wait_ms(100);
ThomasGS 0:63c6db89607f 51 }
ThomasGS 0:63c6db89607f 52 */
ThomasGS 0:63c6db89607f 53 // int32_t angle = 0;
ThomasGS 0:63c6db89607f 54
ThomasGS 0:63c6db89607f 55 while(1) {
ThomasGS 0:63c6db89607f 56 //printf("%f\n",pitchAngle);
ThomasGS 0:63c6db89607f 57 moteur.gotothetha( ((int)pitchAngle)*10 );
ThomasGS 0:63c6db89607f 58 //moteur.test();
ThomasGS 0:63c6db89607f 59 }
ThomasGS 0:63c6db89607f 60 }