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:
- 29:e7f37f801c93
- Parent:
- 28:c9d882501013
--- a/source/Camera.cpp Wed Jan 21 18:19:56 2015 +0000 +++ b/source/Camera.cpp Tue Jan 27 11:53:40 2015 +0000 @@ -4,24 +4,29 @@ #include "Camera.h" #include "Servo.h" + +#define ordre_temporel 5 +#define vitesse_mot 7 + // les 2 cameras sont en parallèle DigitalOut clk(PTE1); //clock cameras DigitalOut si(PTE0); // start cameras + + AnalogIn pix1(PTB2);//lecture camera1 AnalogIn pix2(PTB3);//lecture camera2 double ordre_servo=0; -#define ordre_temporel 30 int max_detect1; int max_detect2; int flag_new_image=0; double pixel1[128]= {0}; // double pixel2[128]= {0}; // Servo servo(PTD0); -double Periode_capture_image_us=50000; +double Periode_capture_image_us=20000; Ticker ticker_cam; - - +AnalogIn pot1(PTC1); +AnalogIn potar_vitesse(PTC11); AnalogOut FLAG(DAC0_OUT); void readline(void) // fonction de détection de la ligne @@ -187,27 +192,29 @@ } max_detect=(max_detect1+max_detect2)/2; // Réduction proportionelle de la vitesse moteur si l'angle du servo augmente + double coef_vitesse; + coef_vitesse=potar_vitesse.read(); if (max_detect>64) { - consigne_moteur_1=8*(1-(max_detect-64)/150.); - consigne_moteur_2=8*(1-(max_detect-64)/100.); + consigne_moteur_1=coef_vitesse*vitesse_mot*(1-(max_detect-64)/150.); + consigne_moteur_2=coef_vitesse*vitesse_mot*(1-(max_detect-64)/100.); } else { - consigne_moteur_1=8*(1-(64-max_detect)/100.); - consigne_moteur_2=8*(1-(64-max_detect)/150.); + consigne_moteur_1=coef_vitesse*vitesse_mot*(1-(64-max_detect)/100.); + consigne_moteur_2=coef_vitesse*vitesse_mot*(1-(64-max_detect)/150.); } // Lecture du potentiometre - //Kp_servo=2.0*pot1.read(); - ordre_servo=(/*consigne*/0-(max_detect1-max_detect2));//ya une merde ici + float Kp_servo=pot1.read(); + ordre_servo=(/*consigne*/0-(max_detect1-max_detect2)); - ordre_servo=(-ordre_servo)/254+0.5; + ordre_servo=(-ordre_servo*Kp_servo)/254+0.5; if (ordre_servo >=0.88) servo=0.88; - else if (ordre_servo <=0.22) - servo=0.22; + else if (ordre_servo <=0.13) + servo=0.13; else servo= ordre_servo; flag_new_image=1;