Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Nucleo_PWM by
Revision 3:3b6b718a76cd, committed 2016-03-15
- Comitter:
- oussamapay
- Date:
- Tue Mar 15 03:04:25 2016 +0000
- Parent:
- 2:05faa0892bec
- Commit message:
- EtageHaut;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Feb 18 10:58:50 2016 +0000 +++ b/main.cpp Tue Mar 15 03:04:25 2016 +0000 @@ -1,104 +1,80 @@ #include "mbed.h" //TIM1_CH1 //Pince Bas gauche -PwmOut PWM1(PA_8); -//TIM1_CH4 //Pince bas droite -PwmOut PWM2(PA_11); -//TIM16_CH1 -PwmOut PWM3(PA_12); -//TIM3_CH1 -PwmOut PWM4(PB_0); -//TIM3_CH4 -PwmOut PWM5(PB_7); -//TIM17_CH1N -PwmOut PWM6(PB_6); -//TIM3_CH4, -PwmOut PWM7(PB_1); -//TIM3_CH3 -PwmOut PWM8(PB_0); +PwmOut PWM1(PA_8); //D9 + +PwmOut PWM2(PA_11); //D10 + +PwmOut PWM3(PF_0); //D7 + +PwmOut PWM4(PB_1); //D6 + float map (int x, int in_min,int in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } -void Pince_Bas_Gauche(int a) -{// 40 ouverture 0 fermeture + +void Pince_Gauche(int a) +{//50avant 0 arriere PWM1.period_ms(20); PWM1.write(map (a,0,180,0.028f,0.12f)); -} +} -void Pince_Bas_Droite(int a) +void Pince_Droite(int a) {// 0 ouverture 40 fermeture PWM2.period_ms(20); PWM2.write(map (a,0,180,0.028f,0.12f)); } void ouverture() { - Pince_Bas_Droite(0); - Pince_Bas_Gauche(40); + Pince_Droite(40); + Pince_Gauche(5); } void fermeture() { - Pince_Bas_Droite(35); - Pince_Bas_Gauche(5); + Pince_Droite(10); + Pince_Gauche(45); } -void Pince_Glissement_Gauche(int a) -{//50avant 0 arriere -PWM3.period_ms(20); -PWM3.write(map (a,0,180,0.028f,0.12f)); -} + -void Pince_Glissement_Droit(int a) +void GAUCHE_MONTE_CHARGE(int a) {//0 avant 50 arriere PWM4.period_ms(20); PWM4.write(map (a,0,180,0.028f,0.12f)); } -void Pince_avant() -{ -Pince_Glissement_Droit(0); -Pince_Glissement_Gauche(50); -} -void Pince_arriere() -{ -Pince_Glissement_Droit(50); -Pince_Glissement_Gauche(0); -} - -void Pince_Cylindre_Droit(int a) -{// -PWM5.period_ms(20); -PWM5.write(map (a,0,180,0.028f,0.12f)); +void DROITE_MONTE_CHARGE(int a) +{// 40 ouverture 0 fermeture +PWM3.period_ms(20); +PWM3.write(map (a,0,180,0.028f,0.12f)); } -void Pince_Cylindre_Gauche(int a) -{// -PWM6.period_ms(20); -PWM6.write(map (a,0,180,0.028f,0.12f)); +void Pince_Haut() +{ +GAUCHE_MONTE_CHARGE(40); +DROITE_MONTE_CHARGE(40); +} +void Pince_Bas() +{ +GAUCHE_MONTE_CHARGE(0); +DROITE_MONTE_CHARGE(0); } -void Pince_Cylindre_Haut() -{ -Pince_Cylindre_Gauche(0); -Pince_Cylindre_Droit(0); -} -void Pince_Cylindre_Bas() -{ -Pince_Cylindre_Gauche(0); -Pince_Cylindre_Droit(0); -} int main() { while(1) { -Pince_arriere(); +Pince_Bas(); wait(1); ouverture(); -wait(2); -fermeture(); -wait(2); -Pince_avant(); -wait(3); } +wait(1); +fermeture(); +wait(1); +Pince_Haut(); +wait(1); + + } } \ No newline at end of file