control for robotic arm that can play chess using a granular gripper
Dependencies: Encoder mbed HIDScope Servo MODSERIAL
Fork of chessRobot by
Diff: actuators.cpp
- Revision:
- 81:71e7e98deb2c
- Parent:
- 79:cf500b63f349
- Child:
- 82:4cc8f9ad3fec
diff -r 8f030bd5dd15 -r 71e7e98deb2c actuators.cpp --- a/actuators.cpp Tue Oct 20 13:39:05 2015 +0200 +++ b/actuators.cpp Tue Oct 20 14:25:31 2015 +0200 @@ -135,13 +135,17 @@ // write new values to motor's if (motor1SetSpeed >= 0 ){ // CCW rotation direction1 = false; + motor1PID.SetDirection(DIRECT); // increase in input > increase in output }else{ direction1 = true; // CW rotation + motor1PID.SetDirection(REVERSE); // increase in input > decrease in output } if (motor2SetSpeed >= 0 ){ // CCW rotation direction2 = false; + motor2PID.SetDirection(DIRECT); }else{ direction2 = true; // CW rotation + motor2PID.SetDirection(REVERSE); } motor1Dir.write(direction1); motor2Dir.write(direction2); @@ -165,9 +169,16 @@ void calibrateMotors(){ // bool calibrating1 = true; // bool calibrating2 = true; + // float motorCalSpeed = 0.1; // %PWM // motor1Dir.write(false); // motor2Dir.write(false); // // move motors CCW until they reach outer most position + // // setmotorspeed contant + // // first move motor 1 using PID + // // wait until motor hits pin + // // switch direction + // // set motor speed1 0 + // // repeat for motor 2 // while (calibrating1 || calibrating2){ // if(motor1AnglePin == 0){ // motor1.write(0.3f); @@ -192,7 +203,7 @@ void safety(){ if (safetyOn){ - if (safetyIn.read() != 0){ + if (safetyIn.read() != 1){ motorsEnable = false; } }