FSG / Battery_Linear_Actuator

Dependents:   7_21_17_FSG 7_26_17_FSG

Fork of Battery_Linear_Actuator_ by FSG

Files at this revision

API Documentation at this revision

Comitter:
mdavis30
Date:
Wed Jul 26 14:10:24 2017 +0000
Parent:
4:346911ee5450
Commit message:

Changed in this revision

Battery_Linear_Actuator.cpp Show annotated file Show diff for this revision Revisions of this file
Battery_Linear_Actuator.h Show annotated file Show diff for this revision Revisions of this file
--- a/Battery_Linear_Actuator.cpp	Tue Jul 25 17:40:26 2017 +0000
+++ b/Battery_Linear_Actuator.cpp	Wed Jul 26 14:10:24 2017 +0000
@@ -17,12 +17,9 @@
     linear_actuator_step_size = 10000;   //default confirmed with Dan Edwards
     linear_actuator_motor_speed = 500;  //5 seconds of full travel between 0 and 175,000 (1000 is about 3 seconds)
     
-    map_check = 0;  //remove?
-    
+    map_check = 0;  //TROY: Using this on keyboard a and d
+    max_extended_position = 180000;
     
-//    la_P_gain = 1.0;  //was 0.10
-//    la_I_gain = 0.00;
-//    la_D_gain = 0.00;
     curr_time = 0.00;
     dt = 0.00;    
     la_error = 0.00;
@@ -98,12 +95,6 @@
     return homing_string;
 }
 
-string Battery_Linear_Actuator::Keyboard_J() //L.A. POSITION ONLY
-{
-    MC.printf("pos\r");
-    return "\nL.A. POSITION COMMAND RECEIVED.\n";
-}
-
 string Battery_Linear_Actuator::Velocity(int velocity) //EXTEND with velocity command
 {
     string la_position = Battery_Linear_Actuator::get_pos();  //get the position data in  string format
@@ -117,7 +108,7 @@
 
     int int_position = atoi(la_position_char);
 
-    if (int_position >= 0 && int_position <= 175000)
+    if (int_position >= 0 && int_position <= max_extended_position)
     {
         MC.printf("en\r");
         MC.printf("V%d\r", velocity);    
@@ -135,7 +126,7 @@
 string Battery_Linear_Actuator::velocity_only(int velocity) //EXTEND with velocity command
 {
     //this uses the position record saved in the object
-    if (actual_position >= 0 && actual_position <= 175000)
+    if (actual_position >= 0 && actual_position <= max_extended_position)
     {
         //send velocity command and get the return value
         MC.printf("en\r");
@@ -155,31 +146,31 @@
 
 string Battery_Linear_Actuator::Keyboard_K() //EXTEND with velocity command
 {
-    if (motor_absolute_position >= 0 && motor_absolute_position <= 175000)
+    if (motor_absolute_position >= 0 && motor_absolute_position <= max_extended_position)
     {   
         MC.printf("en\r");
         MC.printf("V50\r");
         return "\nVELOCITY COMMAND. Extending.\n";
     }
     else
-        return "\nmotor position out of bounds (below 0 or above 175000)\n";
+        return "\nmotor position out of bounds (below 0 or above 180000)\n";
 }
 
 string Battery_Linear_Actuator::Keyboard_L() //RETRACT with velocity command
 {
-    if (motor_absolute_position >= 0 && motor_absolute_position <= 175000)
+    if (motor_absolute_position >= 0 && motor_absolute_position <= max_extended_position)
     {   
         MC.printf("en\r");
         MC.printf("V-50\r");
         return "\nVELOCITY COMMAND. Retracting.\n";
     }
     else
-        return "\nmotor position out of bounds (below 0 or above 175000)\n";
+        return "\nmotor position out of bounds (below 0 or above 180000)\n";
 }
-string Battery_Linear_Actuator::Keyboard_U()
+string Battery_Linear_Actuator::Keyboard_U()    //stop linear actuator
 {
     MC.printf("v0\r");  //velocity 0
-    MC.printf("di\r");  //motor disabled
+    //MC.printf("di\r");  //motor disabled
     return "\nVelocity=0, L.A. motor disabled.\n";
 }
 
@@ -280,11 +271,11 @@
 //EXTEND
 string Battery_Linear_Actuator::Keyboard_D()
 {
-    if (motor_absolute_position <= 175000)
+    if (motor_absolute_position <= max_extended_position)
     {
         //explicitly written, check if this will not go past 175000
         map_check = motor_absolute_position + linear_actuator_step_size;
-        if (map_check <= 175000) 
+        if (map_check <= max_extended_position) 
             motor_absolute_position += linear_actuator_step_size;
     }
                     
@@ -382,7 +373,7 @@
     //found this out through testing
     //if velocity is positive you extend the nut
     //but you don't want it to extend past the limit of 175,000
-    if ((integer_output > 0) && (double_actual_position <= 180000.0))
+    if ((integer_output > 0) && (double_actual_position <= max_extended_position))
         string velocity_only_string = Battery_Linear_Actuator::velocity_only(integer_output);   //send the velocity command if this condition is true
     else if ((integer_output < 0) && (double_actual_position >= 3000.0)) //it's a little jumpy (so go here instead of zero)
         string velocity_only_string = Battery_Linear_Actuator::velocity_only(integer_output);   //send the velocity command if this condition is true
--- a/Battery_Linear_Actuator.h	Tue Jul 25 17:40:26 2017 +0000
+++ b/Battery_Linear_Actuator.h	Wed Jul 26 14:10:24 2017 +0000
@@ -16,13 +16,11 @@
     int linear_actuator_step_size;   //default confirmed with Dan Edwards
     int linear_actuator_motor_speed;  //5 seconds of full travel between 0 and 175,000 (1000 is about 3 seconds)
     
-    int map_check;
+    int map_check;              //used on keyboard a and d functions
+    int max_extended_position;  //max extended position of linear actuator
     
     int actual_position;
     
-//    float la_P_gain;
-//    float la_I_gain;
-//    float la_D_gain;
     float curr_time;
     float dt;    
     float la_error;
@@ -44,7 +42,6 @@
     string Keyboard_E();
     string Keyboard_H();
     string Keyboard_I();
-    string Keyboard_J();
     string Keyboard_K();
     string Keyboard_L();
     string Keyboard_O();