Motor calibration
Dependencies: BioroboticsMotorControl mbed BioroboticsEMGFilter MODSERIAL
Diff: main.cpp
- Revision:
- 0:61f4586742be
- Child:
- 1:9c75e4cca419
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 31 09:12:19 2018 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" + +Motor motor1(D6, D7, D13, D12); // Defining motor pins (PWM, direction, encoder) +Motor motor2(D5, D4, D10, D11); // Defining motor pins (PWM, direction, encoder) + +const double Kp = 10.0; +const double Ki = 0.1; +const double Kd = 0.5; + +Ticker motor_cali; + +void Motor_Calibration() +{ + float motor_angle1 = motor1.get_current_angle; + motor_angle1--; + motor1.set_target_angle(motor_angle1); + + float motor_angle2 = motor2.get_current_angle; + motor_angle2--; + motor2.set_target_angle(motor_angle2); +} + +int main() +{ + motor1.set_pid_k_values(Kp, Ki, Kd); // Attach PID-controller + motor2.set_pid_k_values(Kp, Ki, Kd); + motor1.start(pid_period) // Attach PID time + motor2.start(pid_period); + motor.attach(Motor_Calibration,0.5); // Ticker for motor calibration fucntion + while (true) {} // Empty while loop to keep function from stopping +} \ No newline at end of file