PID Test
Dependencies: AVEncoder mbed-src-AV
Diff: main.cpp
- Revision:
- 3:40333f38771d
- Parent:
- 2:82a11e992619
- Child:
- 4:112f3d35bd2d
--- a/main.cpp Tue Nov 24 04:13:10 2015 +0000 +++ b/main.cpp Tue Nov 24 05:24:55 2015 +0000 @@ -28,13 +28,13 @@ DigitalOut eLS(PC_2); AnalogIn rLS(PC_1); -//Right Front IR -DigitalOut eRF(PC_12); -AnalogIn rRF(PA_4); +//Right Side IR +DigitalOut eRS(PC_12); +AnalogIn rRS(PA_4); -//Right Side IR -DigitalOut eRS(PC_15); -AnalogIn rRS(PB_0); +//Right Front IR +DigitalOut eRF(PC_15); +AnalogIn rRF(PB_0); DigitalOut myled(LED1); @@ -47,29 +47,29 @@ volatile float line_accumulator = 0; volatile float line_decayFactor = 1; volatile float enco_accumulator = 0; -volatile float enco_decayFactor = 1.2; +volatile float enco_decayFactor = 2; volatile float gyro_accumulator = 0; -volatile float gyro_decayFactor = 1.2; +volatile float gyro_decayFactor = 1; -volatile float set_speed = 0.5; -volatile float left_speed = 0.5; -volatile float right_speed = 0.5; +volatile float set_speed = 1; +volatile float left_speed = 2; +volatile float right_speed = 2; -const float left_max_speed = 6; // max speed is 6 encoder pulses per ms. -const float right_max_speed = 6.2; +const float left_max_speed = 5.5; // max speed is 6 encoder pulses per ms. +const float right_max_speed = 5.7; const float gyro_propo = 6.5; const float gyro_integ = 0; const float gyro_deriv = 10; -const float enco_propo = .0005; -const float enco_integ = 0; -const float enco_deriv = .0002; +const float enco_propo = 1; +const float enco_integ = 3;//1; +const float enco_deriv = 40;//.0002; -const float spin_enco_weight = 0.75; +const float spin_enco_weight = 1; const float spin_gyro_weight = 1 - spin_enco_weight; -const float frontWall = 0.7; //need to calibrate this threshold to a value where mouse can stop in time +const float frontWall = 0.25; //need to calibrate this threshold to a value where mouse can stop in time //something like this may be useful volatile float enco_error; @@ -216,9 +216,13 @@ int main() { setup(); + + while(1) { - - pc.printf("enco_pid: %f, gyro_pid: %f, w_error: %f\r\n", enco_pid, gyro_pid, w_error); +// +// pc.printf("left pulss %f, right pulses %f \r\n", l_enco.getPulses(), r_enco.getPulses()); +// //wait(1); + } + // pc.printf("left pulses %d, right pulses %d \r\n", l_enco.getPulses(), r_enco.getPulses()); //encoder testing //wait(1); - } }