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:
Mon Nov 10 15:03:20 2014 +0000
Revision:
7:6ba00694f9cd
Parent:
6:e64796f1f384
Child:
8:b7771391adc9
Started state machine

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