![](/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: colourProcessing.h
- Revision:
- 17:6a0bb0ad5bb4
- Parent:
- 15:0c5f20e15b6a
- Child:
- 22:8f11d1c178ab
--- a/colourProcessing.h Sun Nov 23 18:45:52 2014 +0000 +++ b/colourProcessing.h Mon Nov 24 14:00:46 2014 +0000 @@ -4,12 +4,12 @@ TCS3472_I2C rgb_sensor(p28,p27); //p28 =sda, p27=scl -int rgb_readings[1000][4]; +int rgb_readings[100][4]; int rgb_average[4] = {0,0,0,0}; double rMax = 9244; double gMax = 3194; double bMax = 3590; - +int tubeSize = 33; //thresholds are in the RGB format. /* Values for black casing @@ -20,12 +20,12 @@ int blueLT [3]= {25,47,47}; int blueUT [3]= {28,52,52};*/ //values for blue backing -int redLT [3] = {280,50,50}; -int redUT [3]= {420,180,260}; -int greenLT [3] = {60,190,106}; -int greenUT [3]= {180,270,226}; -int blueLT [3]= {59,68,85}; -int blueUT [3]= {169,188,205}; +int redLT [3] = {308,84,162}; +int redUT [3]= {352,124,204}; +int greenLT [3] = {91,180,142}; +int greenUT [3]= {132,220,184}; +int blueLT [3]= {79,95,117}; +int blueUT [3]= {117,139,157}; int noneLT [3] = {0,0,0}; int noneUT [3] = {80,80,80}; @@ -35,20 +35,21 @@ } Colour readColourSensor(){ + wait(0.1); lcd->cls(); // clear display lcd->locate(0,0); lcd->printf("Reading Sensor"); - for(int i = 0; i < 1000; i++){ + for(int i = 0; i < 100; i++){ rgb_sensor.getAllColors(rgb_readings[i]); - wait(0.0025); + wait(0.001); } - for(int i = 0; i < 1000; i++){ + for(int i = 0; i < 100; i++){ for(int j = 0; j < 4; j++){ rgb_average[j] += rgb_readings[i][j]; } } for(int i = 0; i < 4; i++){ - rgb_average[i] = rgb_average[i] / 1000; + rgb_average[i] = rgb_average[i] / 100; } double redd = (rgb_average[1] /gMax) * 255; double greend = (rgb_average[2] /bMax) * 255;