![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Diff: serialCommunication.h
- Revision:
- 20:6de191ac7ff3
- Parent:
- 19:78d4b78fa736
- Child:
- 21:3d9556f5508a
--- a/serialCommunication.h Tue Nov 25 12:06:26 2014 +0000 +++ b/serialCommunication.h Tue Nov 25 12:59:11 2014 +0000 @@ -53,70 +53,28 @@ } return valueToChar(value); } -void processState(StateMachine stateMachine){ - switch(stateMachine){ - case INITIALISING: - - break; - case READING_RGB_VALUES: - readChipNumbers(); - break; - case DISPENSE_RED: - dispense(RED); - break; - case DISPENSE_GREEN: - dispense(GREEN); - break; - case DISPENSE_BLUE: - dispense(BLUE); - break; - case SORT_RED: - sort(RED); - break; - case SORT_GREEN: - sort(GREEN); - break; - case SORT_BLUE: - sort(BLUE); - break; - case SORT_BIN: - sort(BIN); - break; - case SORT_RECYCLE: - sort(RECYCLE); - break; - case DISPENSE_ALL: - dispenseAll(); - break; - /* case WAITING_FOR_ACK: - checkSerial(); - break; - case WAITING_FOR_CHAR: - log("About to check serial"); - printLCD("WAITING_FOR_CHAR"); - checkSerial(); - break;*/ - - } -} - - - void processMessage(char c){ switch(c){ case 'a' : //Dispense red + { dispense(RED); sendCharacter('A'); break; + } + { case 'b' : //dispense green dispense(GREEN); sendCharacter('B'); break; + } + { case 'c': //dispense blue dispense(BLUE); sendCharacter('C'); break; + } + { case 'C':// Read card command sendCharacter('R'); //Notify PC that command has been recieved printLCD("Reading Card"); @@ -132,10 +90,14 @@ sendCharacter('C'); //Tells PC that the card has been read printLCD("Card read done"); break; + } + { case 'X': 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"); @@ -146,70 +108,98 @@ //set the FPGA colour inputs to the colour code startSort = true; break; + } + { case 'o': //testServoredBlueLeft maintain(RB_LEFT); sendCharacter('O'); break; + } + { case 'p': maintain(RB_CENTRE); sendCharacter('P'); break; + } + { case 'q': maintain(RB_RIGHT); sendCharacter('O'); break; - + } + { case 's': maintain(GO_UP); sendCharacter('S'); break; - + } + { case 't': maintain(GO_CENTRE); sendCharacter('T'); break; - + } + { case 'u': maintain(GO_DOWN); sendCharacter('U'); break; - + } - + { case 'v': maintain(BR_LEFT); sendCharacter('V'); break; - + } + { case 'w': maintain(BR_LEFT); sendCharacter('O'); break; + } + { case 'j': sort(RED); sendCharacter('J'); break; + } + { case 'k': sort(GREEN); sendCharacter('K'); break; + } + { case 'l': sort(BLUE); sendCharacter('L'); break; + } + { case '0': //Dispense all dispenseAll(); sendCharacter('1'); break; + } + { case '2': maintain(GO_CENTRE); maintain(RB_CENTRE); sendCharacter('3'); break; + } + { + case '4': + lift(); + sendCharacter('5'); + break; + } +