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/Camera.cpp
- Revision:
- 28:c9d882501013
- Parent:
- 27:d1da489fc79a
- Child:
- 29:e7f37f801c93
--- a/source/Camera.cpp Wed Jan 21 17:34:38 2015 +0000 +++ b/source/Camera.cpp Wed Jan 21 18:19:56 2015 +0000 @@ -10,8 +10,8 @@ AnalogIn pix1(PTB2);//lecture camera1 AnalogIn pix2(PTB3);//lecture camera2 -double ordre=0; -#define ordre_temporel 5 +double ordre_servo=0; +#define ordre_temporel 30 int max_detect1; int max_detect2; int flag_new_image=0; @@ -87,8 +87,8 @@ // Actualisation de l'image filtrée for (i=0;i<128;i++) { - pixel1[i]=(tamponpixel1[i]+tamponpixel1[127+i])/2; - pixel2[i]=(tamponpixel2[i]+tamponpixel2[127+i])/2; + pixel1[i]=(tamponpixel1[i]+tamponpixel1[127+i])/2.; + pixel2[i]=(tamponpixel2[i]+tamponpixel2[127+i])/2.; } } @@ -165,7 +165,7 @@ moyenne_temporelle(); //passebas(4); - for (int i=0;i<15;i++) + for (int i=0;i<5;i++) { pixel1[i]=0; pixel2[i]=0; @@ -189,27 +189,27 @@ // Réduction proportionelle de la vitesse moteur si l'angle du servo augmente if (max_detect>64) { - consigne_moteur_1=6*(1-(max_detect-64)/150.); - consigne_moteur_2=6*(1-(max_detect-64)/100.); + consigne_moteur_1=8*(1-(max_detect-64)/150.); + consigne_moteur_2=8*(1-(max_detect-64)/100.); } else { - consigne_moteur_1=6*(1-(64-max_detect)/100.); - consigne_moteur_2=6*(1-(64-max_detect)/150.); + consigne_moteur_1=8*(1-(64-max_detect)/100.); + consigne_moteur_2=8*(1-(64-max_detect)/150.); } // Lecture du potentiometre //Kp_servo=2.0*pot1.read(); - ordre=(/*consigne*/0-(max_detect1-max_detect2));//ya une merde ici + ordre_servo=(/*consigne*/0-(max_detect1-max_detect2));//ya une merde ici - ordre=(-ordre)/254+0.5; + ordre_servo=(-ordre_servo)/254+0.5; - if (ordre >=0.88) + if (ordre_servo >=0.88) servo=0.88; - else if (ordre <=0.22) + else if (ordre_servo <=0.22) servo=0.22; else - servo= ordre; + servo= ordre_servo; flag_new_image=1; FLAG.write(0);