pour simone

Dependencies:   MPU6050 mbed

Committer:
ThomasGS
Date:
Fri Jun 03 14:50:37 2016 +0000
Revision:
2:146ff0747375
Parent:
0:63c6db89607f
version avec moteur parametre

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;
ThomasGS 0:63c6db89607f 9 MPU6050 mpu6050;
ThomasGS 2:146ff0747375 10
ThomasGS 0:63c6db89607f 11 PwmOut pwm1A(PA_10);
ThomasGS 0:63c6db89607f 12 PwmOut pwm1B(PA_6);
ThomasGS 0:63c6db89607f 13 PwmOut pwm1C(PB_6);
ThomasGS 0:63c6db89607f 14 DigitalOut enable1A(PA_7);
ThomasGS 0:63c6db89607f 15 DigitalOut enable1B(PA_9);
ThomasGS 2:146ff0747375 16
ThomasGS 2:146ff0747375 17 PwmOut pwm2A(PB_1);
ThomasGS 2:146ff0747375 18 PwmOut pwm2B(PB_10);
ThomasGS 2:146ff0747375 19 PwmOut pwm2C(PB_5);
ThomasGS 2:146ff0747375 20 DigitalOut enable2A(PB_4);
ThomasGS 2:146ff0747375 21 DigitalOut enable2B(PC_4);
ThomasGS 2:146ff0747375 22
ThomasGS 2:146ff0747375 23 brushlessservo moteur(pwm1A,pwm1B,pwm1C,enable1A,enable1B);
ThomasGS 2:146ff0747375 24 brushlessservo moteurB(pwm2A,pwm2B,pwm2C,enable2A,enable2B);
ThomasGS 2:146ff0747375 25
ThomasGS 0:63c6db89607f 26 float pitchAngle = 0;
ThomasGS 0:63c6db89607f 27 float rollAngle = 0;
ThomasGS 0:63c6db89607f 28
ThomasGS 0:63c6db89607f 29 void compFilter() {mpu6050.complementaryFilter(&pitchAngle, &rollAngle);}
ThomasGS 0:63c6db89607f 30 void toggle_led1() {myled!=myled;}
ThomasGS 0:63c6db89607f 31 void toggle_led2();
ThomasGS 0:63c6db89607f 32
ThomasGS 0:63c6db89607f 33 int main() {
ThomasGS 2:146ff0747375 34 //brushlessservo moteur;
ThomasGS 0:63c6db89607f 35 mpu6050.init();
ThomasGS 0:63c6db89607f 36 filter.attach(&compFilter, 0.005);
ThomasGS 0:63c6db89607f 37 wait(1);
ThomasGS 0:63c6db89607f 38 /*
ThomasGS 0:63c6db89607f 39 moteur.gotothetha(450);
ThomasGS 0:63c6db89607f 40 wait(1);
ThomasGS 0:63c6db89607f 41 moteur.gotothetha(0);
ThomasGS 0:63c6db89607f 42 wait(1);
ThomasGS 0:63c6db89607f 43 moteur.gotothetha(1350);
ThomasGS 0:63c6db89607f 44 moteur.gotothetha(0);
ThomasGS 0:63c6db89607f 45
ThomasGS 0:63c6db89607f 46 for(int i=0; i<1800;i+=5){
ThomasGS 0:63c6db89607f 47 moteur.gotothetha(i);
ThomasGS 0:63c6db89607f 48 wait_ms(100);
ThomasGS 0:63c6db89607f 49 }
ThomasGS 0:63c6db89607f 50 */
ThomasGS 0:63c6db89607f 51 // int32_t angle = 0;
ThomasGS 0:63c6db89607f 52
ThomasGS 0:63c6db89607f 53 while(1) {
ThomasGS 0:63c6db89607f 54 //printf("%f\n",pitchAngle);
ThomasGS 0:63c6db89607f 55 moteur.gotothetha( ((int)pitchAngle)*10 );
ThomasGS 0:63c6db89607f 56 //moteur.test();
ThomasGS 0:63c6db89607f 57 }
ThomasGS 0:63c6db89607f 58 }