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:
11:06f6e82b40a8
Parent:
10:8c0696b99692
Child:
12:814a8fdbb6f7
--- a/FPGAcomms.h	Wed Nov 12 20:14:45 2014 +0000
+++ b/FPGAcomms.h	Thu Nov 13 11:59:39 2014 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
-#include "Colour.h"
+//#include "Colour.h"
+#include "colourProcessing.h"
 //Setup pins to FPGA
 DigitalOut startSort(p5);       //A positive edge tells the FPGA to start sorting.
 DigitalIn sortComplete(p16);
@@ -68,12 +69,12 @@
         
         //wait(1); //temporary delay
         while(!dispenseComplete){
-            wait(0.1);
+            wait(0.2);
             log("Waiting for dispense complete");
             printLCD("Waiting for dispense complete");           
         }
         
-        wait(0.1);
+        wait(0.5);
         log("Complete");
         log("Setting start dispense to false");
         startDispense = false;
@@ -117,6 +118,20 @@
                 colourBit3 = false;
                 
             break;
+            case BIN:
+                log("Sort BIN");
+                log("Setting sort bits to 011");
+                colourBit1 = true;
+                colourBit2 = true;
+                colourBit3 = false;
+            break;
+            case RECYCLE:
+                log("Recycle");
+                log("Setting sort bits to 100");
+                colourBit1 = false;
+                colourBit2 = false;
+                colourBit3 = true;
+            break;
         }
         
      
@@ -126,16 +141,16 @@
         
         //wait(1); //temporary delay
         while(!sortComplete){
-            wait(0.1);
+            wait(0.5);
             log("Waiting for sort complete");
             printLCD("Waiting for sort complete");            
         }
         
         
         log("Complete");
-        wait(0.1);
+        wait(0.5);
         log("Setting start sort to false");
-        startSort = false;
+        startSort = false;     
         
         log("Resetting dispense bits to 11");       
         colourBit1 = true;    //reset the dispense select to do nothing