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

Committer:
IonSystems
Date:
Fri Nov 07 20:16:23 2014 +0000
Revision:
6:e64796f1f384
Parent:
5:644bca33c1ca
Child:
7:6ba00694f9cd
Recovered from the attack of Euan

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IonSystems 0:8d54ffcf256e 1 #include "mbed.h"
IonSystems 6:e64796f1f384 2 #include <sstream>
IonSystems 6:e64796f1f384 3 #include "lcdCommands.h"
IonSystems 6:e64796f1f384 4 #include "mbedStorage.h"
IonSystems 6:e64796f1f384 5 #include "rgbLED.h"
IonSystems 6:e64796f1f384 6 #include "mbedLCD.h"
IonSystems 5:644bca33c1ca 7
IonSystems 0:8d54ffcf256e 8
IonSystems 6:e64796f1f384 9 Serial pc(USBTX, USBRX);
IonSystems 3:97668a4cd69d 10
IonSystems 3:97668a4cd69d 11
IonSystems 6:e64796f1f384 12 //Boolean values to easily enable and disable certain features for individual testing
IonSystems 6:e64796f1f384 13 bool colourSensor = true;
IonSystems 6:e64796f1f384 14 bool cardReader = true;
IonSystems 6:e64796f1f384 15 bool sorter = true;
IonSystems 6:e64796f1f384 16 bool dispensor = true;
IonSystems 6:e64796f1f384 17
IonSystems 6:e64796f1f384 18 bool cardDataAcquired = false;
IonSystems 6:e64796f1f384 19 bool colourDataAcquired = false;
IonSystems 6:e64796f1f384 20 bool chipDetected = false;
IonSystems 6:e64796f1f384 21 bool operationMode = true; //the MBED starts in operation mode.
IonSystems 3:97668a4cd69d 22
IonSystems 5:644bca33c1ca 23
IonSystems 6:e64796f1f384 24
IonSystems 6:e64796f1f384 25 int main() {
IonSystems 6:e64796f1f384 26 writeFile(2,6,22);
IonSystems 6:e64796f1f384 27 readChipNumbers();
IonSystems 6:e64796f1f384 28 setupLCD();
IonSystems 6:e64796f1f384 29 printLCD("Welcome to the Chipin Sorter");
IonSystems 6:e64796f1f384 30 wait(1);
IonSystems 6:e64796f1f384 31 printStoredChipValues();
IonSystems 6:e64796f1f384 32 /*
IonSystems 0:8d54ffcf256e 33 while(1){
IonSystems 3:97668a4cd69d 34 if(par_port->read_bit(11)) resetForNextCustomer();
IonSystems 3:97668a4cd69d 35 // char c = pc.getc(); //wait for a serial character to be recieved.
IonSystems 3:97668a4cd69d 36 // processMessage(c); //Do something, based on the character recieved.
IonSystems 3:97668a4cd69d 37 if(cardDetect & !cardDataAcquired) cardAcquisition();
IonSystems 3:97668a4cd69d 38 setLEDs();
IonSystems 3:97668a4cd69d 39 readButtons();
IonSystems 3:97668a4cd69d 40
IonSystems 4:f3be545b3826 41 if(chipDetected & !colourDataAcquired){
IonSystems 4:f3be545b3826 42 Colour colour = readColourSensor();
IonSystems 4:f3be545b3826 43 sendColourSignal(colour);
IonSystems 4:f3be545b3826 44 }
IonSystems 4:f3be545b3826 45
IonSystems 5:644bca33c1ca 46 writeFile(redQueue, greenQueue, blueQueue);
IonSystems 4:f3be545b3826 47 readFile();
IonSystems 4:f3be545b3826 48 wait(2);
IonSystems 4:f3be545b3826 49
IonSystems 0:8d54ffcf256e 50 }
IonSystems 6:e64796f1f384 51 */
IonSystems 6:e64796f1f384 52
IonSystems 6:e64796f1f384 53 setLEDcolour(255,0,0);
IonSystems 6:e64796f1f384 54 wait(0.1);
IonSystems 6:e64796f1f384 55 setLEDcolour(0,255,0);
IonSystems 6:e64796f1f384 56 wait(0.1);
IonSystems 6:e64796f1f384 57 setLEDcolour(0,0,255);
IonSystems 6:e64796f1f384 58 wait(0.1);
IonSystems 6:e64796f1f384 59
IonSystems 6:e64796f1f384 60 displayOperationMode();
IonSystems 3:97668a4cd69d 61
IonSystems 6:e64796f1f384 62 }