Thomas Giraud-Sauveur
/
Gimbal_ENSEA
pour simone
main.cpp
- Committer:
- ThomasGS
- Date:
- 2016-06-03
- Revision:
- 2:146ff0747375
- Parent:
- 0:63c6db89607f
File content as of revision 2:146ff0747375:
#include "mbed.h" #include "mycontroller.h" #include "MPU6050.h" DigitalOut myled(LED1); Serial pc(USBTX, USBRX); Ticker filter; Ticker toggler1; MPU6050 mpu6050; PwmOut pwm1A(PA_10); PwmOut pwm1B(PA_6); PwmOut pwm1C(PB_6); DigitalOut enable1A(PA_7); DigitalOut enable1B(PA_9); PwmOut pwm2A(PB_1); PwmOut pwm2B(PB_10); PwmOut pwm2C(PB_5); DigitalOut enable2A(PB_4); DigitalOut enable2B(PC_4); brushlessservo moteur(pwm1A,pwm1B,pwm1C,enable1A,enable1B); brushlessservo moteurB(pwm2A,pwm2B,pwm2C,enable2A,enable2B); float pitchAngle = 0; float rollAngle = 0; void compFilter() {mpu6050.complementaryFilter(&pitchAngle, &rollAngle);} void toggle_led1() {myled!=myled;} void toggle_led2(); int main() { //brushlessservo moteur; mpu6050.init(); filter.attach(&compFilter, 0.005); wait(1); /* moteur.gotothetha(450); wait(1); moteur.gotothetha(0); wait(1); moteur.gotothetha(1350); moteur.gotothetha(0); for(int i=0; i<1800;i+=5){ moteur.gotothetha(i); wait_ms(100); } */ // int32_t angle = 0; while(1) { //printf("%f\n",pitchAngle); moteur.gotothetha( ((int)pitchAngle)*10 ); //moteur.test(); } }