PID controll for the robot motors.

Dependencies:   BioroboticsMotorControl MODSERIAL mbed

Files at this revision

API Documentation at this revision

Comitter:
brass_phoenix
Date:
Wed Oct 31 09:12:59 2018 +0000
Parent:
6:cc3e47c7aac2
Commit message:
+ Added reduction ratios.

Changed in this revision

BioroboticsMotorControl.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BioroboticsMotorControl.lib	Fri Oct 19 11:21:40 2018 +0000
+++ b/BioroboticsMotorControl.lib	Wed Oct 31 09:12:59 2018 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/Biorobotics-7/code/BioroboticsMotorControl/#0bb9adb89005
+https://os.mbed.com/teams/Biorobotics-7/code/BioroboticsMotorControl/#48a0b4a67283
--- a/main.cpp	Fri Oct 19 11:21:40 2018 +0000
+++ b/main.cpp	Wed Oct 31 09:12:59 2018 +0000
@@ -9,14 +9,16 @@
 const double Ki = 0.1;
 const double Kd = 0.5;
 
-AnalogIn potmeter1(A1); // Analoge input van potmeter 1 -> Motor 1
-AnalogIn potmeter2(A2); // Analoge input van potmeter 2 -> Motor 2
+AnalogIn potmeter1(A5); // Analoge input van potmeter 1 -> Motor 1
+AnalogIn potmeter2(A4); // Analoge input van potmeter 2 -> Motor 2
 Serial pc(USBTX, USBRX);
 
 Motor motor1(D6, D7, D13, D12, &pc);
 Motor motor2(D5, D4, D10, D11, &pc);
 
 
+const double PI = 3.14159265359;
+
 // Normalizes a potmeter value from it's original range of [0, 1] to [-1, 1]
 double normalize_pot(double pot_value) {
     // scales value potmeter from 0-1 to -1 - 1.
@@ -30,6 +32,10 @@
     pc.printf("Starting.");
     motor1.set_pid_k_values(Kp, Ki, Kd);
     motor2.set_pid_k_values(Kp, Ki, Kd);
+    
+    motor1.set_extra_reduction_ratio(-0.5);
+    motor2.set_extra_reduction_ratio(0.5);
+    
     // Start the motor controller at the desired frequency.
     motor1.start(pid_period);
     motor2.start(pid_period);