control for robotic arm that can play chess using a granular gripper

Dependencies:   Encoder mbed HIDScope Servo MODSERIAL

Fork of chessRobot by a steenbeek

Files at this revision

API Documentation at this revision

Comitter:
annesteenbeek
Date:
Tue Oct 20 12:33:23 2015 +0200
Parent:
74:75be98779124
Child:
77:6c6b9cd550bb
Commit message:
working safety

Changed in this revision

actuators.cpp Show annotated file Show diff for this revision Revisions of this file
actuators.h 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/actuators.cpp	Tue Oct 20 12:14:18 2015 +0200
+++ b/actuators.cpp	Tue Oct 20 12:33:23 2015 +0200
@@ -7,6 +7,8 @@
 #include "Servo.h"
     // functions for controlling the motors
     bool motorsEnable = false;
+    bool safetyOn = false; // start with safety off for calibration
+
 
     double encoder1Counts = 0;
     double encoder2Counts = 0;
@@ -132,7 +134,7 @@
 
 void writeMotors(){
     motor1PID.Compute(); // calculate PID outputs, output changes automatically
-    pidOut = motor2PID.Compute();
+    motor2PID.Compute();
 // write new values to motor's
     if (motor1SetSpeed >= 0 ){ // CCW rotation 
         direction1 = false;
@@ -146,11 +148,9 @@
     }
     motor1Dir.write(direction1);
     motor2Dir.write(direction2);
-    
-    double motor2FF = 0.0012*motor2SetSpeed+0.02;
 
     motor1.write(abs(motor1PWM));
-    motor2.write(abs(motor2PWM)+motor2FF);
+    motor2.write(abs(motor2PWM));
 }
 
 void servoControl(){
@@ -189,10 +189,10 @@
     // // set the encoder values for angle.
     // encoder1.setValue(0);
     // encoder2.setValue(0);
+    safetyOn = true; // turn safety on after callibration
 }
 
 
-safetyOn = false; // start with safety off for calibration
 void safety(){
     if (safetyOn){
         motorsEnable = false;
--- a/actuators.h	Tue Oct 20 12:14:18 2015 +0200
+++ b/actuators.h	Tue Oct 20 12:33:23 2015 +0200
@@ -28,5 +28,6 @@
 void servoControl();
 void calibrateMotors();
 void writeMotors();
+void safety();
 
 #endif 
\ No newline at end of file
--- a/main.cpp	Tue Oct 20 12:14:18 2015 +0200
+++ b/main.cpp	Tue Oct 20 12:33:23 2015 +0200
@@ -22,12 +22,10 @@
 void motor_activate(){motor_go=true;};
 void emg_activate(){emg_go=true;};
 
-bool safetyOn = false; // start with safety off for calibration
 double motorCall = 0.01; // set motor frequency global so it can be used for speed.
 int main(){
 motorInit();    
-// calibrateMotors(); // start calibration procedure
-safetyOn = true; // turn safety on after calibration
+calibrateMotors(); // start calibration procedure
 
 switches.attach(&switches_activate, 0.02f);
 debug.attach(&debug_activate, 0.03f);