This has increased comments and a readme

Dependencies:   mbed mbed-rtos TextLCD

Files at this revision

API Documentation at this revision

Comitter:
JDickson
Date:
Fri Mar 01 21:57:59 2019 +0000
Parent:
26:83550fc299aa
Commit message:
More comments

Changed in this revision

README.txt Show annotated file Show diff for this revision Revisions of this file
SETUP.hpp 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
diff -r 83550fc299aa -r 22d6fd88828e README.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.txt	Fri Mar 01 21:57:59 2019 +0000
@@ -0,0 +1,42 @@
+COILING RIG CODE V10:
+This code is used to operate the Carbon Fibre actuator construction rigs. The buttons on this rig operate as follows:          
+ 
+ - Reset:
+            This button simply reboots the board and restarts the code.
+
+ - Function:
+            This button chooses between the functions of the board
+ 
+ - Select:
+            This selects the part of the function in the interface to be changed 
+  
+ - Up:
+        This increases either the number of coils or annealing time
+ 
+ - Down:
+        This decreases either the number of coils or annealing time
+ 
+ - Start/Stop:
+                
+                
+Useful code information:
+    Function 0 = Turn
+    Function 1 = Anneal
+    Function 2 = Test
+    
+    Black :Reset     : HardWired
+    Red   :Up        : D8
+    Orange:Down      : A1
+    Brown :Start/Stop: D9
+    Green :Select    : A3
+    Yellow:Function  : A4
+    
+    
+    //Led Outputs //check the pin outs.
+    static DigitalOut Led_Select_Left(D2);
+    static DigitalOut Led_Select_Right(D3);
+    static DigitalOut Led_Power(A3);
+  
+    TextLCD lcd(D0,D1,D4,D5,D6,D7); // rs, e, d4-d7
+    TendonPower (PWM) pin is PE_8  one below d0
+    STEPPER_MOTOR STEPPER_MOTOR_1(D15,D14,D13,D12) this is defined in interface.hpp
\ No newline at end of file
diff -r 83550fc299aa -r 22d6fd88828e SETUP.hpp
--- a/SETUP.hpp	Tue Feb 19 14:40:01 2019 +0000
+++ b/SETUP.hpp	Fri Mar 01 21:57:59 2019 +0000
@@ -13,8 +13,6 @@
 
 #define Debounce_Time 100//200 works fine
 INTERFACE INTERFACE;
-//If the code compiles GET IN THE BIN
-
     
 //Digital Outputs
 DigitalOut led1(LED1);
@@ -43,29 +41,4 @@
 //Serial Terminal setup for debugging
 Serial pc(USBTX, USBRX);         //Define serial namespace so the serial comms can be printed to
 
-#endif 
-
-//Useful information
-/*
-    Function 0 = Turn
-    Function 1 = Anneal
-    Function 2 = Test
-    
-    Black :Reset     : HardWired
-    Red   :Up        : D8
-    Orange:Down      : A1
-    Brown :Start/Stop: D9
-    Green :Select    : A3
-    Yellow:Function  : A4
-    
-    
-    //Led Outputs //check the pin outs.
-    static DigitalOut Led_Select_Left(D2);
-    static DigitalOut Led_Select_Right(D3);
-    static DigitalOut Led_Power(A3);
-  
-    TextLCD lcd(D0,D1,D4,D5,D6,D7); // rs, e, d4-d7
-    TendonPower (PWM) pin is PE_8  one below d0
-    STEPPER_MOTOR STEPPER_MOTOR_1(D15,D14,D13,D12) this is defined in interface.hpp
-*/
-    
\ No newline at end of file
+#endif 
\ No newline at end of file
diff -r 83550fc299aa -r 22d6fd88828e main.cpp
--- a/main.cpp	Tue Feb 19 14:40:01 2019 +0000
+++ b/main.cpp	Fri Mar 01 21:57:59 2019 +0000
@@ -1,10 +1,9 @@
 #include "SETUP.hpp"
-void Polling_thread_function()// Polling thread for the buttons
+void Polling_thread_function()// Polling thread to look for button press
 {
     while(1)
     {
-        //printf("In polling\n");//Check the value
-        if(button_up.read() == 0)
+        if(button_up.read() == 0)               //This checks the Up button
         {
             printf("Up button read\n");
             Thread::wait(Debounce_Time);
@@ -14,7 +13,7 @@
                 up_thread.signal_set(1);
             }   
         }
-        if(button_down.read() == 0)
+        if(button_down.read() == 0)               //This checks the Down button
         {
             printf("Down button read\n");
             Thread::wait(Debounce_Time);
@@ -23,7 +22,7 @@
                 down_thread.signal_set(1);
             }  
         }
-        if(button_start.read() == 0)
+        if(button_start.read() == 0)               //This checks the Start/Stop button
         {
             printf("Start/Stop button read\n");
             Thread::wait(Debounce_Time);
@@ -32,7 +31,7 @@
                 start_stop_thread.signal_set(1);
             }   
         }
-        if(button_function.read() == 0)
+        if(button_function.read() == 0)               //This checks the Function button
         {
             printf("Function button read\n");
             Thread::wait(Debounce_Time);
@@ -41,7 +40,7 @@
                 function_thread.signal_set(1);
             }   
         }
-        if(button_select.read() == 0)
+        if(button_select.read() == 0)               //This checks the Select button
         {
             printf("Select button read\n");
             Thread::wait(Debounce_Time);
@@ -53,36 +52,39 @@
         Thread::wait(50);   
     }   
 }
-void LCD_thread()//Output data to the LCD for the interface
+void LCD_thread()   //Output data to the LCD for the interface
+        /*
+            This section of the code decides what data that should be sent to the LCD for each of the modes of the system.
+        */
 {
     while(1)
     {
         lcd.cls();//Clear the LCD screen
-        if(INTERFACE.Get_Function() == 0)//Anneal
+        if(INTERFACE.Get_Function() == 0)//Anneal Mode display
         {
-            lcd.printf("Mode: Anneal\n");
+            lcd.printf("Mode: Anneal\n");      //Top LCD line when the device is annealing
             if(INTERFACE.Get_Select() == 0 || INTERFACE.Get_Select() == 1)
             {
-                lcd.printf("Loop:%d On_t:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_On_Time());
+                lcd.printf("Loop:%d On_t:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_On_Time());   //When the On value is selected
             }
             else if(INTERFACE.Get_Select() == 2)
             {
-               lcd.printf("Loop:%d Offt:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_Off_Time()); 
+               lcd.printf("Loop:%d Offt:%d\n",INTERFACE.Get_Loop(),INTERFACE.Get_Off_Time());   //When the Off value is selected
             }     
         }
-        else if(INTERFACE.Get_Function() == 1)//Test
+        else if(INTERFACE.Get_Function() == 1)//Testing mode display
         {
-            lcd.printf("Mode: Test\n");
+            lcd.printf("Mode: Test\n");      //Top LCD line when the device is Testing
             lcd.printf("Duty: %dTime: %d\n",INTERFACE.Get_Duty_Cycle(),INTERFACE.Get_Power_Time());
         }
         else if(INTERFACE.Get_Function() == 2)//Coil
         {
-            lcd.printf("Mode: Coil\n");
+            lcd.printf("Mode: Coil\n");      //Top LCD line when the device is Coiling
             lcd.printf("Done:%dToDo: %d\n",INTERFACE.Get_Turns_Done(),INTERFACE.Get_Turns_To_Do());
         }
         else if(INTERFACE.Get_Function() == 3)//Twist
         {
-            lcd.printf("Mode: Twist\n");
+            lcd.printf("Mode: Twist\n");      //Top LCD line when the device is Twisting
             lcd.printf("Done:%dToDo: %d\n",INTERFACE.Get_Turns_Done(),INTERFACE.Get_Turns_To_Do());
         }
         Thread::wait(250);//Refresh rate for Lcd
@@ -177,7 +179,7 @@
     Thread::wait(1000);
     pc.printf("Program start\n");//Outputs informtation to the putty terminal
     
-    //Thread Starts
+    //Thread Initialisation
     polling_thread.start(Polling_thread_function);//Start the button polling
     lcd_thread.start(LCD_thread);//Output data to LCD
     led_thread.start(LED_thread);//Blinking led to show CPU running