A twist to the computer that landed man on the moon. More information can be found at http://hackaday.io/project/294-Open-Source-DSKY

Dependencies:   DS1302 keypad mbed

Hardware

Files at this revision

API Documentation at this revision

Comitter:
VivaPenguinos
Date:
Fri Aug 15 20:27:26 2014 +0000
Parent:
4:99535d368a9f
Child:
6:3019f2f7e9d4
Commit message:
Contains P00, P01, P02, R1_Component; Edited R_GET() Function for indicator lights; Edited GET_Config(); Added Indicator Lights; Added R1_Component

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Jul 21 23:28:22 2014 +0000
+++ b/main.cpp	Fri Aug 15 20:27:26 2014 +0000
@@ -1,25 +1,22 @@
 /* Introduction
 MBED DSKY
 This is a personal project used developed by penguinos to mix old school technology with a modern twist.
-Version 0.04: July. 5 2014
-    - DS1302 Added
-    - Shift Register Variable has been added
-    - void Button_Sort(int sort); is now int Button_Sort(int sort);
-        Button sort has 90% of all the variables in there.
-    - Void shifting out no longer takes 8 bits but rather 4 bits. (Makes things easier to compute)
-    - Added Concatenation Functionality
-    - Added NO_Lights Functionality
-    - Added R_GET Functionality
-    - Test Light Program working
-    - GET Program Working
-    - GET Configuration Working
-    
+Version 0.05: July. 24 2014
+    - Indicator lights added
+        - Included Comp ACTY light
+        - Added all indicator lights into Blink all. (Doesn't follow format correctly yet)
+    - R_GET() function now includes the Positive and negative indicator lights for the R rows. (Function has yet to be tested)
+    - GET_Config function during value checking now checks whether the indicator lights for Positive are on or off. (Has yet to be tested also)
+    - P00 - Idling Program Completed
+    - P01 - PreLaunch Initialization Program Completed
+    - P02 - PreLaunch Gyrocompassing Program Completed
+        - Prelaunch_Gyrocompassing_Configure Completed
+    - R1_Component Added
     
 Notable Credits:
 NASA! - Release of technical documentations regarding the AGC and DSKY
 Ron Burkley and Contributers of "Virtual AGC — AGS — LVDC — Gemini" - Providing Technical documentations, Source Code, explanations,
     and refrences on other sites to make this project successful
-
 Warning: This may contain author's crude language, and random thoughts.
 
 Pin Usage:
@@ -41,6 +38,24 @@
     Latch   PTC6
     Clock   PTC10
     Data    PTC11
+Statues Indicator
+    Uplink ACTY     PTE5
+    NO ATT          PTE4
+    STBY            PTE3
+    KEY REL         PTE2
+    OPP ERR         PTB11
+    TEMP            PTB10
+    GIMBAL LOCK     PTB9
+    PROG            PTB8
+    RESTART         PTC12
+    TRACKER         PTC13
+    R1+             PTC16
+    R2+             PTC17
+    R3+             PTA16
+    R1-             PTA17
+    R2-             PTE31
+    R3-             PTC6
+    COMP ACTY       PTC7
     
 Shift Registers Data:
 Because the project contains 11 shift registers, All data must be properly formatted before shifting out. each shift register controls 2 7 segments.
@@ -118,12 +133,15 @@
 int P_A = 0x0f;
 int P_B = 0x0f;
 
-// For GET use. Refer to R3_GET, R2_GET, and R1_GET
+// For R use.
+int R_Pos = 0;
+int R_Neg = 0;
 int RA = 0;
 int RB = 0;
 int RC = 0;
 int RD = 0;
 int RE = 0;
+int RP = 0;
 int RVA = 0x0f;
 int RVB = 0x0f;
 int RVC = 0x0f;
@@ -135,6 +153,18 @@
 int R3_Position = 1;
 int GET_Config_Time = 0;
 
+// For N Use.
+int NA = 0x0f;
+int NB = 0x0f;
+int N_Position = 1;
+
+// PC Variables (Future use)
+int IMUPWR = 1;
+
+// DSKY Variables
+int LAUNCHAZ = 0; // LAUNCH AZIMUTH
+int R1_COMP;
+
 // Keypad
 char Keytable[] = { '1', '2', '3', '+', // R0
                     '4', '5', '6', '-', // R1
@@ -152,28 +182,54 @@
 int     State;
 
 // Function Declaration
+void Interruption();
 void Verb_Button();
 void Noun_Button();
 void Enter_Button();
 void compare();
-int Button_Sort(int sort); // Function that sorts Verb Values
 void blinkAll(int amount, int delay);// Function that Blinks all LED
 void Shift(); // Function that shifts all data
-void R_GET(int R); // Grab inputs for the Rows
+void R_GET(int R);  // Grab inputs for Rows
+void N_GET();       // Grab inputs for Noun
+void NO_Light(int L); // Configures shift registers to 0
+void PreLaunch_Gyrocompassing_Configure(); // For the inputs of the PreLaunch_Gyrocompassing
+int Button_Sort(int sort); // Function that sorts Verb Values
 int R_Concatenate(int C); // Used for concatenating information
-void NO_Light(int L); // Configures shift registers to 0
 //void ShiftingOut(char myDataOut);
 
 // Program Names
-void Ground_Elapse_Time();  // Ground Elapse Time
-void Test_Lights();         // Test Lights
-void GET_Config();          // Configures Ground Elapse Time
+void Ground_Elapse_Time();          // Ground Elapse Time
+void Test_Lights();                 // Test Lights
+void GET_Config();                  // Configures Ground Elapse Time
+void CMC_Idle();                    // P00 - CMC Idling Program
+void PreLaunch_Initialization();    // P01 - Prelaunch - Initialization Program
+void PreLaunch_Gyrocompassing();    // P02 - Prelaunch - Gyrocompassing Program
+int R1_Component();                // Load Component into R1
 
 // Pin modes for each pins
 DigitalOut LatchPin(PTC6); //Pin for ST_CP of 74HC595 Pin # 12
 DigitalOut ClockPin(PTC10); //Pin for SH_CP of 74HC595 Pin # 11
 DigitalOut DataPin(PTC11);  //Pin for to DS of 74HC595 Pin # 14
 
+// Indicator Lights
+DigitalOut UPLINK_ACTY(PTE5); 
+DigitalOut NO_ATT(PTE4);
+DigitalOut STBY(PTE3);
+DigitalOut KEY_REL(PTE2);
+DigitalOut OPP_ERR(PTB11);
+DigitalOut TEMP(PTB10);
+DigitalOut GIMBAL_LOCK(PTB9);
+DigitalOut PROG(PTB8);
+DigitalOut RESTART(PTC12);
+DigitalOut TRACKER(PTC13);
+DigitalOut R1_POS(PTC16);
+DigitalOut R2_POS(PTC17);
+DigitalOut R3_POS(PTA16);
+DigitalOut R1_NEG(PTA17);
+DigitalOut R2_NEG(PTE31);
+DigitalOut R3_NEG(PTD6);
+DigitalOut COMP_ACTY(PTD7);
+
 DigitalOut myled(LED1);
 Serial pc(USBTX, USBRX); // tx, rx Serial Output to PC Enabling this WILL consume resources. Use only for debug
 
@@ -232,6 +288,22 @@
     }
 }
 
+void Interruption()
+{
+    pc.printf("Interrupted");
+    pc.printf("Index:%d => Key:%c\r\n", Index, Keytable[Index]);
+    if (Index == 12) { // Index 12 = Verb Button
+        Verb_Button(); // Goes to Verb_Button
+    }
+    if (Index == 14) { // Index 14 = Noun Button
+        Noun_Button(); // Goes to Noun_Button
+    }
+    if (Index == 11) { // Index 11 = Enter Button
+        Enter_Button(); // Goes to Enter_Button
+    }
+    Index = -1;
+}
+
 /* This function is used when the Verb Button has been pressed. Take the inputs of the button twice and determine if the buttons are integers.
 If other buttons are pressed send it to their perspective locations.
 */
@@ -292,7 +364,7 @@
 {
     Enterz:
     pc.printf("Checking Whether there is a variable stored in Noun or Verb 35\n");
-    if (Noun_Number1 == 0 && Noun_Number2 == 0 && Verb_Number1 != 2 && Verb_Number2 != 5){
+    if (Noun_Number1 == 0 && Noun_Number2 == 0 && Verb_Number1 != 2 && Verb_Number2 != 5){ // N00V35 // Test Lights
         pc.printf("Please enter a Enter Number");
         __wfi();
         Enter_Number1 = Index;
@@ -306,6 +378,56 @@
         Enter_Number2 = Index;
         Button_Sort(Enter_Number2);
     }
+    // This is for P01
+    else if(Noun_Number1 == 0 && Noun_Number2 == 0 && Verb_Number1 == 2 && Verb_Number2 == 8){ //N00V37
+        pc.printf("This is the P01\n");
+        pc.printf("Please enter a Enter Number\n");
+        //Noun_Number1 = 0x0f;
+        //Noun_Number2 = 0x0f;
+        NO_Light(5);
+        Index = -1;
+        do {
+            N_GET();
+            V_A = 0x03;
+            V_B = 0x07;
+            N_GET();
+            Shift();
+            wait(.5);
+            N_GET();
+            NO_Light(4); // No Light Verb
+            NO_Light(5);
+            N_GET();
+            NO_Light(5);
+            Shift();
+            wait(.5);
+        } while (N_Position != 3);
+        V_A = 3;
+        V_B = 7;
+        N_A = Enter_Number1;
+        N_B = Enter_Number2;
+        Shift();
+        compare();
+        pc.printf("Out of P01, Waiting for Orders\n");
+        // pc.printf("V1 %d \n", Verb_Number1);
+        // pc.printf("V2 %d \n", Verb_Number2);
+        // pc.printf("N1 %d \n", Noun_Number1);
+        // pc.printf("N2 %d \n", Noun_Number2);
+        // pc.printf("E1 %d \n", Enter_Number1);
+        // pc.printf("E2 %d \n", Enter_Number2);
+        N_Position = 1;
+        __wfi();
+        if (Index == 11) { // 11 = Enter Button
+            pc.printf("Compare\n");
+            compare();
+            }
+        else if (Index == 14) {
+            Noun_Button();
+            }
+        else if (Index == 12) {
+            Verb_Button();
+            }
+        Index = -1;
+    }
     else {// (Noun_Number1 != 0 && Noun_Number2 != 0){ 
         pc.printf("Check completed, Executing");
         Index = -1;
@@ -328,6 +450,7 @@
         }
     else if (Sort == 3) { // Index 3 - Char + comparing the array number NOT what value in the array it is. Actual Array value is +
         pc.printf("+");
+        return 0x10;
         }
     else if (Sort == 4) { // Index 4 - Char 4
         return 0x04;
@@ -340,6 +463,7 @@
         }
     else if (Sort == 7) { // Index 7 - Char - comparing the array number NOT what value in the array it is. Actual Array value is -
         pc.printf("-");
+        return 0x11;
         }
     else if (Sort == 8) { // Index 8 - Char 7
         return 0x07;
@@ -380,8 +504,18 @@
         // GET COnfiguration
         pc.printf("GET configuration");
         GET_Config();
-    } else if (Verb == 37 && Enter == 00) {
-        // Idle Program
+    } else if (Verb_Number1 == 2 && Verb_Number2 == 8 && Noun_Number1 == 0 && Noun_Number2 == 0 && Enter_Number1 == 0 && Enter_Number2 == 0) { // Verb 37, Noun 00, Enter 00
+        // CMC Idling Program
+        pc.printf("CMC Idling Program");
+        CMC_Idle();
+    } else if (Verb_Number1 == 2 && Verb_Number2 == 8 && Noun_Number1 == 0 && Noun_Number2 == 0 && Enter_Number1 == 0 && Enter_Number2 == 1) { // Verb 37, Noun 00, Enter 01
+        pc.printf("Prelaunch or Service - Initialization Program");
+        PreLaunch_Initialization();
+    } //else if (Verb_Number1 == 1 && Verb_Number2 == 0 && Noun_Number1 == 0 && Noun_Number2 == 0 && Enter_Number1 == 0 && Enter_Number2 == 0) { // Verb 21, Noun 00, Enter 00
+    //    R1_Component();
+    //}
+     else {
+        pc.printf("Failed");
     }
 }
 
@@ -461,13 +595,47 @@
         for (int s = 0; s < 22; s++) 
         {
             ShiftingOut(0x08);
+            UPLINK_ACTY     = 1;
+            NO_ATT          = 1;
+            STBY            = 1;
+            KEY_REL         = 1;
+            OPP_ERR         = 1;
+            TEMP            = 1;
+            GIMBAL_LOCK     = 1;
+            PROG            = 1;
+            RESTART         = 1;
+            TRACKER         = 1;
+            R1_POS          = 1;
+            R2_POS          = 1;
+            R3_POS          = 1;
+            R1_NEG          = 1;
+            R2_NEG          = 1;
+            R3_NEG          = 1;
+            COMP_ACTY       = 1;
         }
         LatchPin = 1;
         wait(delay);
         LatchPin = 0;
             for (int s = 0; s < 22; s++)
             {
-            ShiftingOut(0xf);
+            ShiftingOut(0x0f);
+            UPLINK_ACTY     = 0;
+            NO_ATT          = 0;
+            STBY            = 0;
+            KEY_REL         = 0;
+            OPP_ERR         = 0;
+            TEMP            = 0;
+            GIMBAL_LOCK     = 0;
+            PROG            = 0;
+            RESTART         = 0;
+            TRACKER         = 0;
+            R1_POS          = 0;
+            R2_POS          = 0;
+            R3_POS          = 0;
+            R1_NEG          = 0;
+            R2_NEG          = 0;
+            R3_NEG          = 0;
+            COMP_ACTY       = 0;
             }
         LatchPin = 1;
         wait(delay);
@@ -696,7 +864,7 @@
         R_GET(3);
         Shift();
         wait(.5);
-    } while (R3_Position != 6);
+    } while (R3_Position != 7);
     R_Position = 1;
     RVA = 0x0f;
     RVB = 0x0f;
@@ -721,7 +889,7 @@
         R_GET(2);
         Shift();
         wait(.5);
-    } while(R2_Position != 6);
+    } while(R2_Position != 7);
     R_Position = 1;
     RVA = 0x0f;
     RVB = 0x0f;
@@ -746,7 +914,7 @@
         R_GET(1);
         Shift();
         wait(.5);
-    } while(R1_Position != 6);
+    } while(R1_Position != 7);
     R_Position = 1;
     RVA = 0x0f;
     RVB = 0x0f;
@@ -760,8 +928,8 @@
     GET_Minute  = R_Concatenate(2);
     GET_Seconds = R_Concatenate(1);
     
-    // Checks if value exceeds the Hours, Minute, and Seconds
-    if (GET_Hours > 750 or GET_Minute > 60 or GET_Seconds > 60) {
+    // Checks if value exceeds the Hours, Minute, and Seconds and verifies if Rows are in Positive
+    if (GET_Hours > 750 or GET_Minute > 60 or GET_Seconds > 60 or R1_POS != 1 or R2_POS != 1 or R3_POS != 1) {
         pc.printf("Error! Check your Hours, Minute, and Seconds Value");
         R3_Position = 1;
         GET_Config();
@@ -784,6 +952,204 @@
     //pc.printf("%d\n", GET_Seconds);
     Ground_Elapse_Time();
  }
+
+// This is the CMC Idling Program Page CM-39
+// This portion of code just turns off all of the display. Originally used to save power consumption.
+// Process:
+// Display PROG 00
+// Verb 37 Enter 00
+// Verb 06 Noun  38
+// Optional Display:
+// Verb 06 Noun 38 - 
+//      Time of State Vector being Integrated
+//          00xxx   hours
+//          000xx   minutes
+//          0xx.xx  seconds
+void CMC_Idle()
+{
+    NO_Light(7);
+    P_A = 0x00;
+    P_B = 0x00;
+    Shift();
+    while(1) {
+        __wfi();
+        if (Index >-1) {
+            Interruption();
+            break;
+        }
+            
+    }
+    
+}
+
+/*
+P01 - Prelaunch or Service - Initialization Program CM-39
+Purpose:
+    1. To intialize the platform for the prelaunch programs.
+    2. To provide an initial stable member orientation for Gyrocompassing (P02)
+Assumptions:
+    Erasble location has been Properly initialized.
+        Azimuth,    +1
+        Latitude,   +1
+        LaunchAZ    +1
+        IMU compenstaion parameters
+*/
+void PreLaunch_Initialization()
+{
+    P_A = 0x00;
+    P_B = 0x01;
+    Shift();
+
+    if (IMUPWR == 1) {
+        NO_ATT = 0;
+        wait(9);
+        pc.printf("Course Align IMU\n");
+        NO_ATT = 1;
+        wait(10);
+        pc.printf("Course Align IMU complete\n");
+        NO_ATT = 0;
+        wait(2);
+        PreLaunch_Gyrocompassing();
+    } else {
+        // NO_ATT is off for 8 seconds, with one COMP_ACTY light.
+        PROG        = 1;
+        wait(6);
+        COMP_ACTY   = 1;
+        wait(0.5);
+        COMP_ACTY   = 0;
+        wait(1.5);
+        // NO_ATT is on for 6 seconds, No COMP_ACTY light.
+        NO_ATT      = 1;
+        wait(6);
+        NO_ATT      = 0;
+        P_A = 0x0f;
+        P_B = 0x0f;
+        Shift();
+    }
+}
+
+/*
+P02 - Prelaunch or Service - Gyrocompassing Program CM-39
+Purpose:
+    1. Provide proper stable member orientation for launch
+Assumptions:
+    1. Program may be interuppted to perform the prelaunch or service - optical verification of gyrocompassing program (P03)
+    2. V75 will be keyed in and displaed during this program to permit crew backup of the liftoff discrete.
+    3. Program is automatically selected by the Initialization Program (P01).
+    4. This program has capability (Via V78E) to change the luanch azimuth of the stable memeber while gyrocompassing.
+Process:
+    1. After P01 is completed
+    2. Display P02
+    3. Flashing V06 N29 / Display LAUNCHAZ in R3
+    4. User input V21E
+    5. Flash V21N29                                     This is R1_Component May be for future use.
+    6. User inputs values for LAUNCHAZ
+    7. Flash V06 N29 / Display LAUNCHAZ in R3
+    8. Input Pro
+    9. Pulses Gyros
+Programming Notes:
+    Void PreLaunch_Gyrocomapssing() and PreLaunch_Gyrocompassing_Configure() are tied together
+
+*/
+void PreLaunch_Gyrocompassing ()
+{
+    // Process 1
+    // Process 2
+    NO_Light(7);
+    P_A = 0x00;
+    P_B = 0x02;
+    Shift();
+    Index = -1;
+    R3_E = LAUNCHAZ%10;
+    R3_D = (LAUNCHAZ/10)%10;
+    R3_C = (LAUNCHAZ/100)%10;
+    R3_B = (LAUNCHAZ/1000)%10;
+    R3_A = (LAUNCHAZ/10000)%10;
+    Shift();
+    while(1) {
+        // Process 3;
+        PreLaunch_Gyrocompassing_Configure();
+        COMP_ACTY = 1;
+        PreLaunch_Gyrocompassing_Configure();
+        wait(0.5);
+        PreLaunch_Gyrocompassing_Configure();
+        COMP_ACTY = 0;
+        PreLaunch_Gyrocompassing_Configure();
+        wait(0.5);
+        pc.printf("spam\n");
+        pc.printf("Index %d\n", Index);
+    } // While 1
+} // prelaunch configuration
+
+// This is used for the configuration of PreLaunch_Gyrocompassing();
+// This has to be used since it awaits for the input of the astronauts.
+void PreLaunch_Gyrocompassing_Configure()
+{
+    int Azimuth;
+    while(1){
+    if (Index >-1) {
+        if (Index == 12) {
+            Verb_Button(); //For V21 use
+        }
+        if (Index == 11) {
+            if (Verb_Number1 == 1 && Verb_Number2 == 0 && Noun_Number1 == 0 && Noun_Number2 == 0 && Enter_Number1 == 0 && Enter_Number2 == 0) { // Verb 21, Noun 00, Enter 00
+                //Flash V21N29 and Get user inputs under R3
+                // Process 5 and 6
+                Azimuth = R1_Component(); // Goes to R1 Component
+                if(Azimuth < 90000 && R3_POS == 1 && R1_NEG == 0) { // Error Checking Checks if it's over 90000 or 90 degrees and that R3_POS is lit and not R3_NEG
+                    // If it passes
+                    LAUNCHAZ = Azimuth;
+                    PreLaunch_Gyrocompassing();// This is suppose to go to PreLaunch_Gyrocompassing
+                }// if Azimuth = R1
+                else{
+                    pc.printf("Failed");
+                } // Error checking
+            } // V21 N00 E00
+        } // Enter BUtton
+        if (Index == 99){ // This is Prog Button
+        // Error checks just in case
+            if (LAUNCHAZ > 0 && R3_POS == 1){
+                // Because there are no Phsyical Gyro's present, This section of code is just going to simulate gyros pulsing
+                for (int x = 0; x > 21; x++){
+                    pc.printf("Pulsing Gyros...\n");
+                    COMP_ACTY = 1;
+                    wait(.5);
+                    COMP_ACTY = 0;
+                    wait(.5);
+                }// Pulsing Gyro simulation
+                pc.printf("Done!");
+            }// Prog Error checking
+        }// Prog Button
+    } // Index > -1
+    } // While(1)
+} // PreLaunh_Gyrocompassing_Configure(); 
+
+
+// Load Component 1 into R1
+int R1_Component()
+{
+    R1_POS = 0;
+    R1_NEG = 0;
+    Index = -1;
+    do {
+        R_GET(3);
+        V_A = 0x02;
+        V_B = 0x01;
+        N_A = 0x02;
+        N_B = 0x09;
+        R_GET(3);
+        Shift();
+        wait(.5);
+        R_GET(3);
+        NO_Light(4);
+        NO_Light(5);
+        R_GET(3);
+        wait(.5);
+    } while (R3_Position != 7);
+    R_Position = 1;
+
+    return R_Concatenate(3);
+}
  
  // This is used to concatenate Row 3, Useful for when verifying inputs.
  int R_Concatenate(int C) {
@@ -848,6 +1214,8 @@
 void R_GET(int R)
 {
     if (R == 3) {
+        R3_POS = R_Pos;
+        R3_NEG = R_Neg;
         R3_A = RVA;
         R3_B = RVB;
         R3_C = RVC;
@@ -856,6 +1224,8 @@
         R3_Position = R_Position;
     }
     if (R == 2) {
+        R2_POS = R_Pos;
+        R2_NEG = R_Neg;
         R2_A = RVA;
         R2_B = RVB;
         R2_C = RVC;
@@ -864,6 +1234,8 @@
         R2_Position = R_Position;
     }
     if (R == 1) {
+        R1_POS = R_Pos;
+        R1_NEG = R_Neg;
         R1_A = RVA;
         R1_B = RVB;
         R1_C = RVC;
@@ -872,54 +1244,95 @@
         R1_Position = R_Position;
     }
     
-    switch (R_Position){
+    switch (R_Position) {
         case 1:
             if (Index >-1) {
+                pc.printf("Plus-Minus\n");
+                RP = Button_Sort(Index);
+                if (RP == 0x10) {
+                    R_Pos = 1;
+                    pc.printf("+");
+                } else if (RP == 0x11) {
+                    R_Neg = 1;
+                }
+                Index = -1;
+                R_Position = 2;
+            }
+                    
+        case 2:
+            if (Index >-1) {
                 pc.printf("RA\n");
                 RA = Button_Sort(Index);
                 RVA = RA;
                 Shift();
                 Index = -1;
-                R_Position = 2;
+                R_Position = 3;
             }
-        case 2:
+        case 3:
             if (Index >-1) {
                 pc.printf("RB\n");
                 RB = Button_Sort(Index);
                 RVB = RB;
                 Shift();
                 Index = -1;
-                R_Position = 3;
+                R_Position = 4;
             }
-        case 3:
+        case 4:
             if (Index >-1) {
                 pc.printf("RC\n");
                 RC = Button_Sort(Index);
                 RVC = RC;
                 Shift();
                 Index = -1;
-                R_Position = 4;
+                R_Position = 5;
             }
-        case 4:
+        case 5:
             if (Index >-1) {
                 pc.printf("RD\n");
                 RD = Button_Sort(Index);
                 RVD = RD;
                 Shift();
                 Index = -1;
-                R_Position = 5;
+                R_Position = 6;
             }
-        case 5:
+        case 6:
             if (Index >-1) {
                 pc.printf("RE\n");
                 RE = Button_Sort(Index);
                 RVE = RE;
                 Shift();
                 Index = -1;
-                R_Position = 6;
+                R_Position = 7;
+            }
+    }            
+}
+
+// When a value is required for Enter, The output is displayed via the Noun display Hence the Name N_GET not E_GET
+void N_GET()
+{
+    N_A = NA;
+    N_B = NB;
+    
+    switch (N_Position) {
+        case 1:
+            if (Index > -1) {
+                pc.printf("NA\n");
+                NA = Button_Sort(Index);
+                Enter_Number1 = NA;
+                Shift();
+                Index = -1;
+                N_Position = 2;
+            }
+        case 2:
+            if (Index > -1) {
+                pc.printf("NB\n");
+                NB = Button_Sort(Index);
+                Enter_Number2 = NB;
+                Shift();
+                Index = -1;
+                N_Position = 3;
             }
     }
                 
-
 }
      
\ No newline at end of file