The MBED firmware used on the Chipin sorter, developed over 12 weeks for a 3rd year university systems project. Chipin is a token sorter, it sorts tokens by colours and dispenses them to order through an online booking system and card reader. This program interfaces with an FPGA, PC and LCD screen to control the sorter. The sorter has an operation mode where it can process orders when a card is entered into the machine. There is also a maintenance mode where the device responds to maintenance instructions such as 'dispense all'. More information at http://www.ionsystems.uk/

Dependencies:   MCP23017 TCS3472_I2C WattBob_TextLCD mbed-rtos mbed

Revision:
2:168850019d5a
Parent:
1:a8a01df48d1a
Child:
3:97668a4cd69d
--- a/main.cpp	Wed Oct 29 09:39:09 2014 +0000
+++ b/main.cpp	Wed Oct 29 11:11:02 2014 +0000
@@ -172,6 +172,16 @@
                 sendCharacter('X'); //Notify the PC that this is an MBED
                 printLCD("Connected to PC");
             break;
+            case 'd':   //Dispense a chip
+                sendCharacter("D");
+                printLCD("Dispensing chip");
+              
+                //read from color sensor
+                //convert readings to colour
+                //convert colour to 3-bit colour code
+                //set the FPGA colour inputs to the colour code
+                sortStart = true; 
+            break;
         }
         }
         else if (operation){
@@ -188,6 +198,9 @@
                     wait(0.1);
                     startDispense = false;
                 break;
+                case 'p':   //
+                    sendCharacter('P');
+                break;
                 }
             }
 }
@@ -232,11 +245,11 @@
     lcd->locate(1,0);   //Going to new line
     lcd->printf("Chipin Sorter");
     wait(1);            //Wait 1 second
-    lcd->reset();       //Clear LCD
+    //lcd->reset();       //Clear LCD
 
     while(1){
-        char c = pc.getc();
-        processMessage(c);
+        char c = pc.getc(); //wait for a serial character to be recieved.
+        processMessage(c);  //Do something, based on the character recieved.
         }