control for robotic arm that can play chess using a granular gripper
Dependencies: Encoder mbed HIDScope Servo MODSERIAL
Fork of chessRobot by
Revision 101:b821e89fc108, committed 2015-10-22
- Comitter:
- annesteenbeek
- Date:
- Thu Oct 22 09:34:31 2015 +0000
- Parent:
- 100:222c27f55b85
- Child:
- 102:b3ab436fbe8e
- Commit message:
- working but possible motor1Bug;
Changed in this revision
--- a/actuators.cpp Thu Oct 22 08:51:50 2015 +0000 +++ b/actuators.cpp Thu Oct 22 09:34:31 2015 +0000 @@ -31,8 +31,8 @@ double motor2PWM = 0; // Set PID values - double Kp1 = 1; - double Ki1 = 0; + double Kp1 = 0.008; + double Ki1 = 0.08; double Kd1 = 0; double Kp2 = 0.008; @@ -119,10 +119,9 @@ void motorControl(){ // EMG signals to motor speeds - const double scaleVel = 20; - motor1SetSpeed = x_velocity*scaleVel; - motor2SetSpeed = y_velocity*scaleVel; - servoSpeed = z_velocity*scaleVel; + motor1SetSpeed = x_velocity*2; + motor2SetSpeed = y_velocity*20; + servoSpeed = z_velocity*20; // get encoder positions in degrees // 131.25:1 gear ratio
--- a/buttons.cpp Thu Oct 22 08:51:50 2015 +0000 +++ b/buttons.cpp Thu Oct 22 09:34:31 2015 +0000 @@ -4,6 +4,8 @@ #include "actuators.h" #include "PID.h" +//#define TUNEPID // enable tuning PID parameters with potmeters +//#define SETPOS // enable position tuning with potmeters // functions for reading all the buttons and switches AnalogIn pot2(pot2Pin); AnalogIn pot1(pot1Pin); @@ -47,10 +49,17 @@ button1Pressed = false; } - #ifdef TUNEPID - setForPID(); // if TUNEPID is defined, use potmeters for PID tuning - #else +// #ifdef TUNEPID +// setForPID(); // if TUNEPID is defined, use potmeters for PID tuning +// #endif + #ifdef SETPOS setForPositions(); // else use it for motor control + #else // still show that motors are enabled using RGB led + if(motorsEnable){ + redLed.write(0); greenLed.write(0); blueLed.write(1); + }else{ + redLed.write(1); greenLed.write(1); blueLed.write(1); + } #endif }
--- a/debug.cpp Thu Oct 22 08:51:50 2015 +0000 +++ b/debug.cpp Thu Oct 22 09:34:31 2015 +0000 @@ -38,15 +38,15 @@ #endif #ifdef TUNEEMG -HIDScope scope(5); // Number of scopes +HIDScope scope(6); // Number of scopes void debugProcess(){ - scope.set(0,y_velocity); - scope.set(1,motor2SetSpeed); - scope.set(2,z_velocity); - scope.set(3,mode); - scope.set(4,DOF); - scope.set(5,motorsEnable); + scope.set(0,x_velocity); + scope.set(1,motor1SetSpeed); + scope.set(2,motor1Speed); + scope.set(3,motor1PWM); + scope.set(4,mode); + scope.set(5,DOF); scope.send(); } #endif \ No newline at end of file
--- a/debug.h Thu Oct 22 08:51:50 2015 +0000 +++ b/debug.h Thu Oct 22 09:34:31 2015 +0000 @@ -9,7 +9,12 @@ extern double motor2Speed; extern double motor2Pos; extern double motor2PWM; +extern double motor1SetSpeed; +extern double motor1Speed; +extern double motor1Pos; +extern double motor1PWM; extern bool motorsEnable; + extern int actuatorState; extern double prevTime;