Treehouse Mbed Team / Mbed 2 deprecated APS_DCM1SL2

Dependencies:   mbed

Revision:
33:6c7364ea360f
Parent:
31:be17caf56d22
Child:
34:419242dc004d
diff -r 05a15c208bfb -r 6c7364ea360f src/command.cpp
--- a/src/command.cpp	Wed Mar 06 23:37:45 2019 +0000
+++ b/src/command.cpp	Thu Aug 22 15:38:50 2019 +0000
@@ -37,11 +37,88 @@
 #include "boards.h"
 #include "menu.h"
 #include "command.h"
+#include "SOFBlock.h"
+#include "adc.h"
 
+uint8_t *storo;
+char storoBuild[50], storoFrag[10];
+char storoSpace[2] = ":";
 unsigned int boardsActive = ALLON;
 unsigned int boardMults = 32;
-unsigned int commandData;
+double commandData;
+unsigned int section;
+unsigned int fort;
+unsigned int select;
+double VOLTAGE_48_ACTUAL_VALUE = 1.51;
+double VOLTAGE_24_ACTUAL_VALUE = 1.55;
+double VOLTAGE_12_ACTUAL_VALUE = 1.65;
+double VOLTAGE_48_OFFSET = 0;
+double VOLTAGE_24_OFFSET = 0;
+double VOLTAGE_12_OFFSET = 0;
+int Vloc = 0;
+int Aloc = 0;
+double VOLTAGE_CAL_1;
+double VOLTAGE_CAL_2;
+double VOLTAGE_CAL_3;
+double VSTORE_1;
+double VSTORE_2;
+double VSTORE_3;
+struct adcValues adcVals;
+struct displayValues dvals;
+signed int CURRENT_48_DIV_FACTOR5 = -370;
+signed int CURRENT_48_DIV_FACTOR4 = -570;
+signed int CURRENT_48_DIV_FACTOR3 = -740;
+signed int CURRENT_48_DIV_FACTOR2 = -948;
+signed int CURRENT_48_DIV_FACTOR1 = -1541;
+signed int CURRENT_48_DIV_FACTOR0 = -1610;
+
+unsigned int CURRENT_48_DIV_THRESH5 = 3000;
+unsigned int CURRENT_48_DIV_THRESH4 = 2500;
+unsigned int CURRENT_48_DIV_THRESH3 = 2000;
+unsigned int CURRENT_48_DIV_THRESH2 = 1500;
+unsigned int CURRENT_48_DIV_THRESH1 = 500;
+
+signed int CURRENT_24_DIV_FACTOR = -376;
+
+signed int CURRENT_12_DIV_FACTOR5 = -188;
+signed int CURRENT_12_DIV_FACTOR4 = -186;
+signed int CURRENT_12_DIV_FACTOR3 = -182;
+signed int CURRENT_12_DIV_FACTOR2 = -177;
+signed int CURRENT_12_DIV_FACTOR1 = -179;
+signed int CURRENT_12_DIV_FACTOR0 = -175;
+
+unsigned int CURRENT_12_DIV_THRESH5 = 1600;
+unsigned int CURRENT_12_DIV_THRESH4 = 800;
+unsigned int CURRENT_12_DIV_THRESH3 = 600;
+unsigned int CURRENT_12_DIV_THRESH2 = 400;
+unsigned int CURRENT_12_DIV_THRESH1 = 200;
+
+unsigned int CURRENT_REF_1;
+unsigned int CURRENT_REF_2;
+unsigned int CURRENT_REF_3;
+unsigned int CURRENT_REF_4;
+unsigned int CURRENT_REF_5;
+unsigned int CURRENT_REF_6;
+double CURRENT_IN_1;
+double CURRENT_IN_2;
+double CURRENT_IN_3;
+double CURRENT_IN_4;
+double CURRENT_IN_5;
+double CURRENT_IN_6;
+
+double CURRENT_12_CORRECTION0;
+double CURRENT_12_CORRECTION1;
+double CURRENT_12_CORRECTION2;
+double CURRENT_12_CORRECTION3;
+double CURRENT_12_CORRECTION4;
+double CURRENT_12_CORRECTION5;
 extern unsigned short my12;
+char storage[50];
+
+/************* TEMPORARY WRITING BLOCK *********************/
+
+SOFWriter writer;
+SOFReader reader;
 
 /************* FILE SCOPE VARIABLES ************************/
 char setvalue = FALSE;
@@ -481,7 +558,7 @@
        tok = strtok(commandStringBuf, "=");
        strcpy(commandString, tok);
        tok = strtok(NULL, "=");
-       commandData = atoi(tok);
+       commandData = atof(tok);
     }
     else{
         strcpy(commandString, commandStringBuf);
@@ -583,6 +660,7 @@
       {
          sprintf(strbuf, " %d", boardMults);
          sendSerial(strbuf);
+         
       }
       else if (running == 1)
       {
@@ -599,7 +677,538 @@
             showRangeError(1, boardMults, 0.0);
          }
       }
+   }/*
+   else if (!strcmp(commandString, "PERM"))
+   {
+      if (readback)
+      {
+         reader.open(sector_index);
+         //printf("data %d bytes at %p :\r\n", reader.get_data_size(), reader.get_physical_data_addr());
+         //printf("%.*s\r\n", reader.get_data_size(), reader.get_physical_data_addr());
+         storo = reader.get_physical_data_addr();
+         reader.close();
+         printf("%s\r\n", storo);
+         sprintf(storage, "%s", storo);
+         int storage_size = strlen(storage);
+         char delim[] = ":";
+         char *ptr = strtok(storage, delim);
+         if (ptr != NULL)
+         {
+            CURRENT_48_DIV_FACTOR0 = atoi(ptr);
+            ptr = strtok(NULL, delim);
+            if (ptr != NULL)
+            {
+                CURRENT_48_DIV_FACTOR1 = atoi(ptr);
+                ptr = strtok(NULL, delim);
+                if (ptr != NULL)
+                {
+                    CURRENT_48_DIV_FACTOR2 = atoi(ptr);
+                    ptr = strtok(NULL, delim);
+                    if (ptr != NULL)
+                    {
+                        CURRENT_48_DIV_FACTOR3 = atoi(ptr);
+                        ptr = strtok(NULL, delim);
+                        if (ptr != NULL)
+                        {
+                            CURRENT_48_DIV_FACTOR4 = atoi(ptr);
+                            ptr = strtok(NULL, delim);
+                            if (ptr != NULL)
+                            {
+                                CURRENT_48_DIV_FACTOR5 = atoi(ptr);
+                                printf("%d\r\n", CURRENT_48_DIV_FACTOR0);
+                                printf("%d\r\n", CURRENT_48_DIV_FACTOR1);
+                                printf("%d\r\n", CURRENT_48_DIV_FACTOR2);
+                                printf("%d\r\n", CURRENT_48_DIV_FACTOR3);
+                                printf("%d\r\n", CURRENT_48_DIV_FACTOR4);
+                                printf("%d\r\n", CURRENT_48_DIV_FACTOR5);
+                            } else {
+                                printf("Insufficient variables found.");
+                            }
+                        } else {
+                            printf("Infussicient variables found.");
+                        }
+                    } else {
+                        printf("Insufficient variables found.");
+                    }
+                } else {
+                    printf("Insufficient variables found.");
+                }
+            } else {
+                printf("Insufficient variables found.");
+            }
+         } else {
+            printf("Infufficient variables found.");
+         }
+         sendSerial(strbuf);
+         
+      }
+      else if (running == 1)
+      {
+         sprintf(strbuf, " Parameters may not be updated while running!");
+         sendSerial(strbuf);
+      }
+      else
+      {
+         if(checkRange(boardMults, 0, 63) == 1){
+            writer.open(sector_index) ;
+            writer.write_data((uint8_t*) storoBuild, sizeof storoBuild);
+            writer.close();
+            testing = TRUE;
+         }else{
+            showRangeError(1, boardMults, 0.0);
+         }
+      }
    }
+   else if (!strcmp(commandString, "PREP"))
+   {
+      if (readback)
+      {
+         printf("%s\r\n", storo);
+         sendSerial(strbuf);
+      }
+      else
+      {
+         if (commandData == 0)
+         {
+             memset(storoBuild, 0, sizeof storoBuild);
+         }
+         else
+         {
+            sprintf(storoFrag, "%d", commandData);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            if(checkRange(boardMults, 0, 63) == 1){
+                printf("%s\r\n", storoBuild);
+                testing = TRUE;
+            }else{
+                showRangeError(1, boardMults, 0.0);
+            }
+         }
+      }
+    }*/
+    else if (!strcmp(commandString, "SECT"))
+    {
+        if (commandData == 48)
+        {
+            section = 48;
+        }
+        else if (commandData == 24)
+        {
+            section = 24;
+            fort = 0;
+        }
+        else if (commandData == 12)
+        {
+            section = 12;
+        }
+        else {
+            printf("Input not accepted.");
+        }
+    }/*
+    else if (!strcmp(commandString, "FORT"))
+    {
+        if (readback)
+        {
+            if (fort == 0)
+            {
+                printf("Currently accessing: Div Factors \r\n");
+            }
+            else if (fort == 1)
+            {
+                printf("Currently accessing: Div Thresholds \r\n");
+            } else {
+                printf("Currently accessing: Nothing \r\n");
+            }
+        }else if (section != 24){
+            if (commandData == 0)
+            {
+                fort = 0;
+                printf("Now accessing: Div Factors \r\n");
+            }
+            else if (commandData == 1)
+            {
+                fort = 1;
+                printf("Now accessing: Div Thresholds \r\n");
+            }
+        }
+    }*/
+    else if (!strcmp(commandString, "DIAL"))
+    {
+        if (Vloc == 0)
+        {
+            if (section == 48)
+            {
+                printf("Begin Voltage 48 calibration? (Enter Dial=1 to continue)");
+                Vloc = -1;
+            }
+            else if (section == 24)
+            {
+                printf("Begin Voltage 24 calibration? (Enter Dial=1 to continue)");
+                Vloc = 7;
+            }
+            else if (section == 12)
+            {
+                printf("Begin Voltage 12 calibration? (Enter Dial=1 to continue)");
+                Vloc = 1;
+            }
+        }
+        else if (Vloc == 1)
+        {
+            if (commandData == 1)
+            {
+                printf("Enter actual output at 12V load. (ex. Dial=1.52)");
+                Vloc = 2;
+            } else{
+                printf("Calibration cancelled.");
+                Vloc = 0;
+            }
+        }
+        else if (Vloc == 2)
+        {
+            VOLTAGE_CAL_1 = commandData;
+            printf("Enter actual output at 10V load. (ex. Dial=1.08)");
+            Vloc = 3;
+        }
+        else if (Vloc == 3)
+        {
+            VOLTAGE_CAL_2 = commandData;
+            printf("Enter actual output at 8V load. (ex. Dial=0.58)");
+            Vloc = 4;
+        }
+        else if (Vloc == 4)
+        {
+            VOLTAGE_CAL_3 = commandData;
+            Vloc = 0;
+            VOLTAGE_12_ACTUAL_VALUE = (VOLTAGE_CAL_1-VOLTAGE_CAL_3)*0.4125;
+            printf("\r\n%4.2f, %4.2f", VOLTAGE_CAL_1, VOLTAGE_CAL_3);
+            VOLTAGE_12_OFFSET = VOLTAGE_CAL_1-(VOLTAGE_12_ACTUAL_VALUE*12/1.65)+((VOLTAGE_CAL_2-(VOLTAGE_12_ACTUAL_VALUE*10/1.65))*0.5);
+            printf("\r\n12V calibration completed.\r\n");
+            printf("%4.2f, %4.2f\r\n", VOLTAGE_12_ACTUAL_VALUE, VOLTAGE_12_OFFSET);
+        }
+        else if (Vloc == -1)
+        {
+            if (commandData == 1)
+            {
+                printf("\r\n Enter actual output at 48V load. (ex. Dial=1.52) \r\n");
+                Vloc = -2;
+            } else{
+                printf("Calibration cancelled.");
+                Vloc = 0;
+            }
+        }
+        else if (Vloc == -2)
+        {
+            VOLTAGE_CAL_1 = commandData;
+            printf("\r\n Enter actual output at 44V load. (ex. Dial=1.08) \r\n");
+            Vloc = -3;
+        }
+        else if (Vloc == -3)
+        {
+            VOLTAGE_CAL_2 = commandData;
+            printf("\r\n Enter actual output at 40V load. (ex. Dial=0.58) \r\n");
+            Vloc = -4;
+        }
+        else if (Vloc == -4)
+        {
+            VOLTAGE_CAL_3 = commandData;
+            Vloc = 0;
+            VOLTAGE_48_ACTUAL_VALUE = (VOLTAGE_CAL_1-VOLTAGE_CAL_3)*0.20625;
+            printf("\r\n%4.2f, %4.2f", VOLTAGE_CAL_1, VOLTAGE_CAL_3);
+            VOLTAGE_48_OFFSET = VOLTAGE_CAL_1-(VOLTAGE_12_ACTUAL_VALUE*48/1.65)+((VOLTAGE_CAL_2-(VOLTAGE_12_ACTUAL_VALUE*44/1.65))*0.5);
+            printf("\r\n48V calibration completed.\r\n");
+            printf("%4.2f, %4.2f\r\n", VOLTAGE_12_ACTUAL_VALUE, VOLTAGE_12_OFFSET);
+        }
+        else if (Vloc == 7)
+        {
+            if (commandData == 1)
+            {
+                printf("\r\n Enter actual output at 24V load. (ex. Dial=1.52) \r\n");
+                Vloc = 13;
+            } else{
+                printf("Calibration cancelled.");
+                Vloc = 0;
+            }
+        }
+        else if (Vloc == 13)
+        {
+            VOLTAGE_CAL_1 = commandData;
+            printf("\r\n Enter actual output at 21V load. (ex. Dial=1.08) \r\n");
+            Vloc = 21;
+        }
+        else if (Vloc == 21)
+        {
+            VOLTAGE_CAL_2 = commandData;
+            printf("\r\n Enter actual output at 18V load. (ex. Dial=0.58) \r\n");
+            Vloc = 42;
+        }
+        else if (Vloc == 42)
+        {
+            VOLTAGE_CAL_3 = commandData;
+            Vloc = 0;
+            VOLTAGE_24_ACTUAL_VALUE = (VOLTAGE_CAL_1-VOLTAGE_CAL_3)*0.275;
+            printf("\r\n%4.2f, %4.2f", VOLTAGE_CAL_1, VOLTAGE_CAL_3);
+            VOLTAGE_24_OFFSET = VOLTAGE_CAL_1-(VOLTAGE_12_ACTUAL_VALUE*24/1.65)+((VOLTAGE_CAL_2-(VOLTAGE_12_ACTUAL_VALUE*21/1.65))*0.5);
+            printf("\r\n24V calibration completed.\r\n");
+            printf("%4.2f, %4.2f\r\n", VOLTAGE_12_ACTUAL_VALUE, VOLTAGE_12_OFFSET);
+        }
+    }
+    else if (!strcmp(commandString, "SCL"))
+    {
+        if (section == 48)
+        {
+            printf("Not yet implimented.");
+        }
+        else if (section == 24)
+        {
+            printf("Not yet implimented.");
+        }
+        else if (section == 12)
+        {
+            if (Aloc == 0)
+            {
+                printf("Begin Voltage 12 current calibration? (Enter Scl=1 to continue)");
+                Aloc = -1;
+            }
+            else if (Aloc == -1)
+            {
+                if (commandData == 1)
+                {
+                    printf("Set current to smallest reference point(1/6). Enter actual current amount. (Ex. Scl=1.25)");
+                    Aloc = -2;
+                } else{
+                    printf("Calibration cancelled.");
+                    Aloc = 0;
+                }
+            }
+            else if (Aloc == -2)
+            {
+                CURRENT_IN_1 = commandData;
+                adcValues adcVals = getADCresults();
+                CURRENT_REF_1 = adcVals.i12;
+                printf("Increase input current. Enter new actual input current(2/6).");
+                Aloc = -3;
+            }
+            else if (Aloc == -3)
+            {
+                CURRENT_IN_2 = commandData;
+                adcValues adcVals = getADCresults();
+                CURRENT_REF_2 = adcVals.i12;
+                printf("Increase input current. Enter new actual input current(3/6).");
+                Aloc = -4;
+            }
+            else if (Aloc == -4)
+            {
+                CURRENT_IN_3 = commandData;
+                adcValues adcVals = getADCresults();
+                CURRENT_REF_3 = adcVals.i12;
+                printf("Increase input current. Enter new actual input current(4/6).");
+                Aloc = -5;
+            }
+            else if (Aloc == -5)
+            {
+                CURRENT_IN_4 = commandData;
+                adcValues adcVals = getADCresults();
+                CURRENT_REF_4 = adcVals.i12;
+                printf("Increase input current. Enter new actual input current(5/6).");
+                Aloc = -6;
+            }
+            else if (Aloc == -6)
+            {
+                CURRENT_IN_5 = commandData;
+                adcValues adcVals = getADCresults();
+                CURRENT_REF_5 = adcVals.i12;
+                printf("Increase input current. Enter new actual input current(6/6).");
+                Aloc = -7;
+            }
+            else if (Aloc == -7)
+            {
+                CURRENT_IN_6 = commandData;
+                adcValues adcVals = getADCresults();
+                CURRENT_REF_6 = adcVals.i12;
+                Aloc = 0;
+                if ((CURRENT_REF_6 - CURRENT_12_OFFSET < 0 && CURRENT_REF_1 - CURRENT_12_OFFSET < 0 && CURRENT_REF_6 > CURRENT_REF_1)
+                || (CURRENT_REF_6 - CURRENT_12_OFFSET > 0 && CURRENT_REF_1 - CURRENT_12_OFFSET > 0 && CURRENT_REF_6 < CURRENT_REF_1))
+                {
+                    CURRENT_12_DIV_THRESH5 = CURRENT_REF_1-CURRENT_12_OFFSET;
+                    CURRENT_12_DIV_THRESH4 = CURRENT_REF_2-CURRENT_12_OFFSET;
+                    CURRENT_12_DIV_THRESH3 = CURRENT_REF_3-CURRENT_12_OFFSET;
+                    CURRENT_12_DIV_THRESH2 = CURRENT_REF_4-CURRENT_12_OFFSET;
+                    CURRENT_12_DIV_THRESH1 = CURRENT_REF_5-CURRENT_12_OFFSET;
+                    CURRENT_12_DIV_FACTOR5 = (CURRENT_REF_1-CURRENT_12_OFFSET)/CURRENT_IN_1;
+                    CURRENT_12_CORRECTION4 = ((CURRENT_REF_1-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR5)-CURRENT_IN_1;
+                    CURRENT_12_DIV_FACTOR4 = (CURRENT_REF_2-CURRENT_REF_1)/(CURRENT_IN_2-CURRENT_IN_1);
+                    CURRENT_12_CORRECTION4 = ((CURRENT_REF_2-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR4)-CURRENT_IN_2;
+                    CURRENT_12_DIV_FACTOR3 = (CURRENT_REF_3-CURRENT_REF_2)/(CURRENT_IN_3-CURRENT_IN_2);
+                    CURRENT_12_CORRECTION3 = ((CURRENT_REF_3-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR3)-CURRENT_IN_3;
+                    CURRENT_12_DIV_FACTOR2 = (CURRENT_REF_4-CURRENT_REF_3)/(CURRENT_IN_4-CURRENT_IN_3);
+                    CURRENT_12_CORRECTION2 = ((CURRENT_REF_4-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR2)-CURRENT_IN_4;
+                    CURRENT_12_DIV_FACTOR1 = (CURRENT_REF_5-CURRENT_REF_4)/(CURRENT_IN_5-CURRENT_IN_4);
+                    CURRENT_12_CORRECTION1 = ((CURRENT_REF_5-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR1)-CURRENT_IN_5;
+                    CURRENT_12_DIV_FACTOR0 = (CURRENT_REF_6-CURRENT_REF_5)/(CURRENT_IN_6-CURRENT_IN_5);
+                    CURRENT_12_CORRECTION0 = ((CURRENT_REF_6-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR0)-CURRENT_IN_6;
+                }
+                else if ((CURRENT_REF_6 - CURRENT_12_OFFSET < 0 && CURRENT_REF_1 - CURRENT_12_OFFSET < 0 && CURRENT_REF_6 < CURRENT_REF_1)
+                || (CURRENT_REF_6 - CURRENT_12_OFFSET > 0 && CURRENT_REF_1 - CURRENT_12_OFFSET > 0 && CURRENT_REF_6 > CURRENT_REF_1))
+                {
+                    CURRENT_12_DIV_THRESH5 = CURRENT_REF_5-CURRENT_12_OFFSET;
+                    CURRENT_12_DIV_THRESH4 = CURRENT_REF_4-CURRENT_12_OFFSET;
+                    CURRENT_12_DIV_THRESH3 = CURRENT_REF_3-CURRENT_12_OFFSET;
+                    CURRENT_12_DIV_THRESH2 = CURRENT_REF_2-CURRENT_12_OFFSET;
+                    CURRENT_12_DIV_THRESH1 = CURRENT_REF_1-CURRENT_12_OFFSET;
+                    CURRENT_12_DIV_FACTOR0 = (CURRENT_REF_1-CURRENT_12_OFFSET)/CURRENT_IN_1;
+                    CURRENT_12_CORRECTION0 = 0;
+                    CURRENT_12_DIV_FACTOR1 = (CURRENT_REF_2-CURRENT_REF_1)/(CURRENT_IN_2-CURRENT_IN_1);
+                    CURRENT_12_CORRECTION1 = ((CURRENT_REF_2-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR1)-CURRENT_IN_2;
+                    CURRENT_12_DIV_FACTOR2 = (CURRENT_REF_3-CURRENT_REF_2)/(CURRENT_IN_3-CURRENT_IN_2);
+                    CURRENT_12_CORRECTION2 = ((CURRENT_REF_3-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR2)-CURRENT_IN_3;
+                    CURRENT_12_DIV_FACTOR3 = (CURRENT_REF_4-CURRENT_REF_3)/(CURRENT_IN_4-CURRENT_IN_3);
+                    CURRENT_12_CORRECTION3 = ((CURRENT_REF_4-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR3)-CURRENT_IN_4;
+                    CURRENT_12_DIV_FACTOR4 = (CURRENT_REF_5-CURRENT_REF_4)/(CURRENT_IN_5-CURRENT_IN_4);
+                    CURRENT_12_CORRECTION4 = ((CURRENT_REF_5-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR4)-CURRENT_IN_5;
+                    CURRENT_12_DIV_FACTOR5 = (CURRENT_REF_6-CURRENT_REF_5)/(CURRENT_IN_6-CURRENT_IN_5);
+                    CURRENT_12_CORRECTION5 = ((CURRENT_REF_6-CURRENT_12_OFFSET)/CURRENT_12_DIV_FACTOR5)-CURRENT_IN_6;
+                }
+                printf("\r\n12V current calibration completed.\r\n");
+                //printf("%4.2f, %4.2f\r\n", VOLTAGE_12_ACTUAL_VALUE, VOLTAGE_12_OFFSET);
+            }
+        }
+    }
+    else if (!strcmp(commandString, "RCRD"))
+    {
+        if(checkRange(boardMults, 0, 63) == 1){
+            sprintf(storoFrag, "%4.2f", VOLTAGE_48_ACTUAL_VALUE);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", VOLTAGE_48_OFFSET);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", VOLTAGE_24_ACTUAL_VALUE);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", VOLTAGE_24_OFFSET);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", VOLTAGE_12_ACTUAL_VALUE);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", VOLTAGE_12_OFFSET);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_THRESH1);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_THRESH2);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_THRESH3);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_THRESH4);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_THRESH5);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR0);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION0);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR1);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION1);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR2);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION2);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR3);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION3);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR4);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION4);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%d", CURRENT_12_DIV_FACTOR5);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            sprintf(storoFrag, "%4.2f", CURRENT_12_CORRECTION5);
+            strcat(storoBuild, storoFrag);
+            strcat(storoBuild, storoSpace);
+            writer.open(sector_index) ;
+            writer.write_data((uint8_t*) storoBuild, sizeof storoBuild);
+            writer.close();
+            testing = TRUE;
+        }else{
+            showRangeError(1, boardMults, 0.0);
+        }
+    }
+    else if (!strcmp(commandString, "RTRV"))
+    {
+        reader.open(sector_index);
+        storo = reader.get_physical_data_addr();
+        reader.close();
+        sprintf(storage, "%s", storo);
+        int storage_size = strlen(storage);
+        char delim[] = ":";
+        char *ptr = strtok(storage, delim);
+        VOLTAGE_48_ACTUAL_VALUE = atof(ptr);
+        ptr = strtok(NULL, delim);
+        VOLTAGE_48_OFFSET = atof(ptr);
+        ptr = strtok(NULL, delim);
+        VOLTAGE_24_ACTUAL_VALUE = atof(ptr);
+        ptr = strtok(NULL, delim);
+        VOLTAGE_24_OFFSET = atof(ptr);
+        ptr = strtok(NULL, delim);
+        VOLTAGE_12_ACTUAL_VALUE = atof(ptr);
+        ptr = strtok(NULL, delim);
+        VOLTAGE_12_OFFSET = atof(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_THRESH1 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_THRESH2 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_THRESH3 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_THRESH4 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_THRESH5 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_FACTOR0 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_CORRECTION0 = atof(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_FACTOR1 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_CORRECTION1 = atof(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_FACTOR2 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_CORRECTION2 = atof(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_FACTOR3 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_CORRECTION3 = atof(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_FACTOR4 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_CORRECTION4 = atof(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_DIV_FACTOR5 = atoi(ptr);
+        ptr = strtok(NULL, delim);
+        CURRENT_12_CORRECTION5 = atof(ptr);
+        printf("Values retreived. \r\n");
+    }
    else if (!strcmp(commandString, "MY12"))
    // MULT is used to get/set the en_out value. 
    // The integer value of boardMults is used to change en_out via setBoardWeights(boardMults).
@@ -687,7 +1296,7 @@
       testing = FALSE;
       my12 = 0;
    }
-   else if(!strcmp(commandString, "CAL"))
+   else if(!strcmp(commandString, "RAW"))
    {
       if (running == 1)
       {
@@ -701,7 +1310,7 @@
           menuRedraw(NO_PROMPT);
       }
     }
-   else if(!strcmp(commandString, "UNCAL"))
+   else if(!strcmp(commandString, "COOK"))
    {
       if (running == 1)
       {