Motor calibration
Dependencies: BioroboticsMotorControl mbed BioroboticsEMGFilter MODSERIAL
Diff: main.cpp
- Revision:
- 6:656fb0834a1a
- Parent:
- 5:43aa136aecda
- Child:
- 7:5cbb59d98416
--- a/main.cpp Wed Oct 31 12:44:47 2018 +0000 +++ b/main.cpp Wed Oct 31 12:45:43 2018 +0000 @@ -57,28 +57,29 @@ if (current_angle2 - motor_threshold <= last_angle2 && last_angle2 <= current_angle2 + motor_threshold) // If the motor angle is within a margin of the current motor angle { time_passed_in_this_state2++; - calibLED1 = !calibLED1; // LED turns blue + calibLED1 = !calibLED1; // LED becomes blue } else { - motor_angle2 = current_angle2; - motor_angle2 = motor_angle2 - 30*motor_threshold; // Subtracting five degree angle from the current angle + motor_angle2 = motor2.get_current_angle(); + motor_angle2 = motor_angle2 - 5*motor_threshold; // Subtracting five degree angle from the current angle motor2.set_target_angle(motor_angle2); time_passed_in_this_state2 = 0; // Set time passed in this state back to zero - calibLED2 = !calibLED2; // LED turns red + calibLED2 = !calibLED2; } if (time_passed_in_this_state2 >= 10) // After 5 seconds have passed (10 times Ticker motor_calib) { motor2.define_current_angle_as_x_radians(-0.733038); // Defines beginstate motor 2 as -42 degrees motor_calib2.detach(); // Stop looping the function - calibLED3 = !calibLED3; // LED becomes red (purple if both motors are calibrated) + calibLED3 = 0; // LED becomes red (purple if both motors are calibrated) + wait(0.1f); + calibLED3 = !calibLED3; } - + last_angle2 = current_angle2; } - int main() { calibLED1 = 1;