update with altimeter, swimfile.txt endleg.txt, etc see changes_13sep.txt also reset_PI()

Dependencies:   mbed MODSERIAL FATFileSystem

Revision:
5:15bd96205bb2
Parent:
4:66f13fbb035d
Child:
10:085ab7328054
--- a/main.cpp	Tue Oct 10 20:22:57 2017 +0000
+++ b/main.cpp	Fri Oct 20 10:59:13 2017 +0000
@@ -8,16 +8,18 @@
     char userInput;
 
     local();  //this makes sure the local file system is constructed
-    //pc().baud(115200);
+
     //Read in and load the BCE parameters from the text file "bce.txt"
-    load_BCE_config();
+    load_BCE_config(); // should say "bce.load_config(bce.txt);
     bce().init();
 
     ////Read in and load the battery mover parameters from the text file "batt.txt"
+    load_BATT_config();
+    batt().init();
 
     // do not leave this in. It is just there to check that things are working
-    pc().printf("\n\rP: %3.2f I: %3.2f D %3.2f zero: %3i limit %3.2f slope %3.2f  \n\r", bce().getControllerP(), bce().getControllerI(), bce().getControllerD(), bce().getZeroCounts(), bce().getTravelLimit(), bce().getPotSlope());
-
+    pc().printf("\n\rbce P: %3.2f I: %3.2f D %3.2f zero: %3i limit %3.2f slope %3.2f  \n\r", bce().getControllerP(), bce().getControllerI(), bce().getControllerD(), bce().getZeroCounts(), bce().getTravelLimit(), bce().getPotSlope());
+    pc().printf("\n\rbatt P: %3.2f I: %3.2f D %3.2f zero: %3i limit %3.2f slope %3.2f  \n\r", batt().getControllerP(), batt().getControllerI(), batt().getControllerD(), batt().getZeroCounts(), batt().getTravelLimit(), batt().getPotSlope());
     //Front load the desired parameters into the linear acuator objects.
     //This could be done using ConfigFile, if it worked
 
@@ -44,6 +46,41 @@
 
     batt().start();
     batt().pause();
+    
+    batt().setPosition_mm(positionCmd);
+    
+    batt().unpause();
+
+
+
+
+    while(1) {
+
+        
+        if (pc().readable()) {
+            // get the key
+            userInput = pc().getc();
+
+            //check command against desired control buttons
+            if (userInput == '=') {
+                //increment the duty cycle
+                positionCmd += 5.0 ;
+            } else if (userInput == '-') {
+                //decrement the duty cycle
+                positionCmd -= 5.0 ;
+            } else if (userInput == '\r') {
+                batt().setPosition_mm(positionCmd);
+                bce().setPosition_mm(positionCmd);
+            }
+        }
+        //pc().printf("set point %3.1f  \r", positionCmd);
+        //pc().printf("pos: %3.2f mm pos: %3.2f counts vel: % 3.2f mm/s  Set Point %3.1f       \r", bce().getPosition_mm(), bce().getPosition_counts(), bce().getVelocity_mms(), positionCmd);
+        //pc().printf("pos: %3.2f mm pos: %3.2f counts vel: % 3.2f mm/s  Set Point %3.1f       \r", batt().getPosition_mm(), batt().getPosition_counts(), batt().getVelocity_mms(), positionCmd);
+        pc().printf("pos bce: %3.2f mm, pos batt: %3.2f mm, Set Point %3.1f       \r", bce().getPosition_mm(), batt().getPosition_mm(), positionCmd);
+    }
+}
+
+
 
     //read in a script file describing the dive cycle
     //I envision entries such as
@@ -58,10 +95,10 @@
     // then some logic is needed to check the box when the desired condition is reached
     // like a waypoint threshold. This allows you to get away from worrying as much about
     // keeping time 
-
+    
+    
+    
 
-
-    while(1) {
         //psuedo code to outline what we want to do
         /*
         check for and parse IMU data
@@ -80,29 +117,4 @@
 
 
         //This can be ignored for now this was the old serial comms stuff for when I
-        //was prototyping the BCE controls
-        
-        if (pc().readable()) {
-            // get the key
-            userInput = pc().getc();
-
-            //check command against desired control buttons
-            if (userInput == '=') {
-                //increment the duty cycle
-                positionCmd += 5.0 ;
-            } else if (userInput == '-') {
-                //decrement the duty cycle
-                positionCmd -= 5.0 ;
-            } else if (userInput == '\r') {
-                bce().setPosition_mm(positionCmd);
-            }
-        }
-
-        //pc().printf("set point %3.1f  \r", positionCmd);
-
-
-        //pc().printf("Position: %10.1f mm  Velocity: % 2.2f mm/s  Output: % 1.3f   switch: %d    \r", bce().getPosition_mm(), bce().getVelocity_mms(), bce().getOutput(), bce().getSwitch());
-        pc().printf("pos: %3.2f mm  vel: % 3.2f mm/s  Set Point %3.1f       \r", bce().getPosition_mm(), bce().getVelocity_mms(), positionCmd);
-
-    }
-}
+        //was prototyping the BCE controls
\ No newline at end of file