1st Revision of clean control code for project biorobotics
Dependencies: Encoder FastPWM MODSERIAL Servo mbed
Fork of kinematics_control_v3 by
Diff: main.cpp
- Revision:
- 1:570c0d599b9e
- Parent:
- 0:5f4bc2d63814
- Child:
- 2:2c2c9d8238d4
diff -r 5f4bc2d63814 -r 570c0d599b9e main.cpp --- a/main.cpp Thu Oct 19 19:42:08 2017 +0000 +++ b/main.cpp Fri Oct 20 09:32:21 2017 +0000 @@ -14,7 +14,7 @@ Ticker MyControllerTicker1; Ticker MyControllerTicker2; const double RAD_PER_PULSE = 0.00074799825*2; -const float CONTROLLER_TS = 0.5; +const float CONTROLLER_TS = 0.01; const double PI = 3.14159265358979323846; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ @@ -53,7 +53,7 @@ //------------------------------------------------------------------------------ AnalogIn potmeter1(A3); AnalogIn potmeter2(A4); -const float max_rangex = 300.0; +const float max_rangex = 500.0; const float max_rangey = 300.0; const float x_offset = 156.15; const float y_offset = -76.97; @@ -122,8 +122,8 @@ DigitalIn ENC2A(D12); DigitalIn ENC2B(D13); Encoder encoder1(D13,D12); -const float MOTOR1_KP = 20.0; -const float MOTOR1_KI = 10.0; +const float MOTOR1_KP = 50.0; +const float MOTOR1_KI = 30.0; double m1_err_int = 0; const double motor1_gain = 2*PI; @@ -138,7 +138,7 @@ pc.printf("\r\n"); - if (magnitude1 < 0){ + if (magnitude1 < 0){ motor1DirectionPin = 1; } else{ @@ -161,8 +161,8 @@ DigitalIn ENC1A(D10); DigitalIn ENC1B(D11); Encoder encoder2(D10,D11); -const float MOTOR2_KP = 20.0; -const float MOTOR2_KI = 10.0; +const float MOTOR2_KP = 50.0; +const float MOTOR2_KI = 30.0; double m2_err_int = 0; const double motor2_gain = 2*PI;