codevoor esther
Dependencies: Encoder MODSERIAL mbed
Revision 10:36281503362a, committed 2013-11-04
- Comitter:
- gerjan
- Date:
- Mon Nov 04 21:25:46 2013 +0000
- Parent:
- 9:ca6c6295b5f1
- Commit message:
- voor naar de emg;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r ca6c6295b5f1 -r 36281503362a main.cpp --- a/main.cpp Mon Nov 04 21:14:30 2013 +0000 +++ b/main.cpp Mon Nov 04 21:25:46 2013 +0000 @@ -26,7 +26,7 @@ // Variabelen benoemen voor regelaar motor. double theta, theta_pen, up_theta, kp_theta, kd_theta, dtheta, ei_theta, ui_theta, ki_theta, ed_theta, u_theta, ud_theta, theta_pwm; - double r, r_pen, up_r, kp_r, kd_r, dr, ei_r, ui_r, ki_r, ed_r, u_r, ud_r, r_pwm, dr_1, utot_r, inputsinus; + double r, r_pen, up_r, kp_r, kd_r, dr, ei_r, ui_r, ki_r, ed_r, u_r, ud_r, r_pwm, dri, dri_1, utot_r, inputsinus; double motor1_maxu, motor2_maxu; double Ts; @@ -61,9 +61,10 @@ y=0; kp_r = 0.006; - ki_r = 0.015; + ki_r = 0.005; inputsinus=0; + dri=0; // Oneidige loop... while(true) { @@ -76,7 +77,7 @@ x = 0;//sin(inputsinus)*297.0; y = sin(inputsinus)*210.0; - inputsinus = inputsinus + (Ts*0.1)*pi; + inputsinus = inputsinus + (Ts*0.5)*pi; //Binnen bereik blijven @@ -110,10 +111,11 @@ //REGELAAR up_r = kp_r * dr; //P-actie - ui_r = (dr_1 + (dr * Ts)) * ki_r; //I-actie + dri = dri_1 + dr*Ts; + ui_r = dri_1 * ki_r; //I-actie utot_r = up_r + ui_r; // - dr_1 = dr; //nieuwe waardes oud maken. + dri_1 = dri; //nieuwe waardes oud maken. theta_pwm = (dtheta)*3.0; r_pwm = (utot_r/1.0);