wassim boumaiza
/
Nucleo_PWM
servo
Fork of Nucleo_PWM by
Diff: main.cpp
- Revision:
- 2:197217bf7bca
- Parent:
- 1:6c59c6871460
--- a/main.cpp Tue Feb 09 15:44:08 2016 +0000 +++ b/main.cpp Wed Mar 23 11:54:22 2016 +0000 @@ -2,19 +2,13 @@ //TIM1_CH1 //Pince Bas gauche PwmOut PWM1(PA_8); //TIM1_CH4 //Pince bas droite -PwmOut PWM2(PA_11); +PwmOut PWM2(PA_9); //TIM16_CH1 -PwmOut PWM3(PA_12); +PwmOut PWM3(PB_4);// Pince Glissement Gauche //TIM3_CH1 -PwmOut PWM4(PB_0); +PwmOut PWM4(PB_10);//Pince Glissement droite //TIM3_CH4 -PwmOut PWM5(PB_7); -//TIM17_CH1N -PwmOut PWM6(PB_6); -//TIM3_CH4, -PwmOut PWM7(PB_1); -//TIM3_CH3 -PwmOut PWM8(PB_0); + float map (int x, int in_min,int in_max, float out_min, float out_max) { @@ -34,14 +28,14 @@ } void ouverture() { - Pince_Bas_Droite(0); - Pince_Bas_Gauche(40); +Pince_Bas_Gauche(80); +Pince_Bas_Droite(10); } void fermeture() { - Pince_Bas_Droite(35); - Pince_Bas_Gauche(5); - } + Pince_Bas_Gauche(30); + Pince_Bas_Droite(60); +} void Pince_Glissement_Gauche(int a) {//50avant 0 arriere PWM3.period_ms(20); @@ -49,16 +43,16 @@ } void Pince_Glissement_Droit(int a) -{//0 avant 50 arriere +{//0avant 50 arriere PWM4.period_ms(20); PWM4.write(map (a,0,180,0.028f,0.12f)); } -void Pince_avant() +void Pince_arriere() { Pince_Glissement_Droit(0); Pince_Glissement_Gauche(50); } -void Pince_arriere() +void Pince_avant() { Pince_Glissement_Droit(50); Pince_Glissement_Gauche(0); @@ -67,13 +61,14 @@ { - while(1) { -Pince_arriere(); -wait(1); -ouverture(); -wait(2); -fermeture(); -wait(2); -Pince_avant(); -wait(3); } + +while(1){ + Pince_Glissement_Gauche(90); +Pince_Glissement_Droit(90); + + wait(1); +Pince_Glissement_Gauche(0); +Pince_Glissement_Droit(0); + wait(1); + } }