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.
Dependencies: mbed freescal_cup_k22f
Diff: source/main.cpp
- Revision:
- 24:7b04db280873
- Parent:
- 23:fa834aa184e0
- Child:
- 25:f9d3d30cbb5d
--- a/source/main.cpp Sat Jan 17 18:15:32 2015 +0000 +++ b/source/main.cpp Sat Jan 17 20:58:26 2015 +0000 @@ -23,7 +23,7 @@ int compteur_uart=0; int max_detect1=indexMin; int min_detect2=indexMin; - int max_detect=(max_detect1+min_detect2)/2; + int index_milieu=(max_detect1+min_detect2)/2; float Kp_servo = 0; uart.baud(115200); init_led(); @@ -78,22 +78,22 @@ min_detect2=j; } } - max_detect=(max_detect1+min_detect2)/2; + index_milieu=(max_detect1+min_detect2)/2; // Réduction proportionelle de la vitesse moteur si l'angle du servo augmente - if (max_detect>64) + if (index_milieu>64) { - consigne_moteur_1=6*(1-(max_detect-64)/150.); - consigne_moteur_2=6*(1-(max_detect-64)/100.); + consigne_moteur_1=6*(1-(index_milieu-64)/150.); + consigne_moteur_2=6*(1-(index_milieu-64)/100.); } else { - consigne_moteur_1=6*(1-(64-max_detect)/100.); - consigne_moteur_2=6*(1-(64-max_detect)/150.); + consigne_moteur_1=6*(1-(64-index_milieu)/100.); + consigne_moteur_2=6*(1-(64-index_milieu)/150.); } // Lecture du potentiometre Kp_servo=2.0*pot1.read_u16()/65000.0; - servo = Kp_servo*(double(max_detect)/128.-0.5)+0.5; + servo = Kp_servo*(index_milieu/128.0-0.5)+0.5; }