Full Text 01
Full Text 01
o
l
Neel Kabirpanthi
1. Introduction .......................................................................................................................... 3
2. Description ............................................................................................................................ 4
a) The RGB Color Room.................................................................................................... 4
3. Different Measures............................................................................................................... 6
a) Measures with different distance to the object............................................................... 6
b) Measures with different angel of the sensor................................................................... 7
c) Temperatures measurement............................................................................................ 8
d) Temperatures measurement of the monitor diode.......................................................... 9
2/28
1. Introduction
The task of the project was to develop a device which can detect different colors by using the
sensor... of the company. The target group of the device are blind persons or persons who can
not detect different colors. There are already different systems on the market, but they are
very expensive and not useful for affordable.
The new device should be a compact, simple and a cheap solution.
3/28
2. Description
The sensor consists of three LED (red, green, blue) two Pin Diodes and a Monitor Diode.
Consecutively on Led will be turned on and then the Pin Diodes are measuring the reflection
of the light. Each color has a different reflection for the three LED. When the reflection is
high the Pin Diodes have a small resistor, is there a little reflection the resistor is high. This
value of resistance we transform into a voltage. So we get for each LED a value of voltage
which will be converting into the RGB Values. This value were compared with the reference
color (a collection of selected colors), and so the device get the right color. The name of the
color is given back by a speaker.
To get an idea how it works to detect the color, we give a short explain of the RGB
Color Room.
The RGB Color Room is an additive Model. This means that the three fundamental
colors (Red, Green, and Blue) can be added to white. Nearly each color can be
described with these three fundamental colors.
In the graph we see the RGB Color Room. On the x-Axes is the color Red, on the y-
Axes is the color Blue and on the z-Axes is the color Green.
On the diagonal of the color room we find the grey scale. In the graph we can see that
each color is a combination of the three fundamental colors.
The measurements were made, to get an idea, which are the important factors to detect
the right color. For the measurements we used a System which contains a Lab VIEW-
Program, DAC-Card and the sensor. As Colors we used the „Digital ColorChecker
SG“of the company Gretagmacbeth, which consists of the standard colors and much
more colors.
In the following table are the colors of the color Checker which we used for our
measurements.
4/28
Index Koordinaten
1 2-E
2 2-F
3 2-G
4 2-H
5 2-I
6 2-J
7 3-E
8 3-F
9 3-G
10 3-H
11 3-I
12 3-J
13 4-E
14 4-F
15 4-G
16 4-H
17 4-I
18 4-J
19 5-E
20 5-F
21 5-G
22 5-H
23 5-I
24 5-J
5/28
3. Different Measures
The following measurements were made to detect the influence to the RGB-values, by
different distances between sensor and the color.
The distance which was normally 2mm we increased to 4mm.
300,000
250,000
values of the colors
200,000
RED-Led(2mm)
150,000
RED-Led(4mm)
100,000
50,000
0,000
0 20 40 60 80 100 120
Different Colors
250,000
200,000
values of colors
150,000
Green-LED(2mm)
Green-LED(4mm)
100,000
50,000
0,000
0 20 40 60 80 100 120
Differnet colors
6/28
Difference Blue-LED
300,000
250,000
values of the colors
200,000
Blue-LED(2mm)
150,000
Blue-LED (4mm)
100,000
50,000
0,000
0 20 40 60 80 100 120
Differenc colores
The graphs are showing the results by 2mm distance and by 4mm distance for each
LED. On the x axes are the 24 standard colors, but for each color we took 5
measurements.
In this diagrams we can see, that the distance to the color, which we want to measure
is important, because the values of the three LED are changing because of the
distance.
The following measurements were made to detect the influence to the RGB-values, by
different Angle between sensor and object. We had fixed the sensor, with an auxiliary
construction, in three different angels (85°- / 85°+ / 90°). The following graphs
descript the 24 measured colors.
Difference angle between the sensor and the object for the Red-LED
260,000
210,000
value of color
160,000
90°
85° +
85° -
110,000
60,000
10,000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
different colors
7/28
Difference angle between the sensor and the object for the Green-LED
250,000
200,000
value of the color
150,000
90°
85° +
85° -
100,000
50,000
0,000
1 6 11 16 21
different colors
Difference angle between the sensor and the object for the Blue-LED
300,000
250,000
200,000
value of the colors
90°
150,000 85° +
85° -
100,000
50,000
0,000
1 6 11 16 21
different colors
The curve 85° + describes the measurements, when the blue LED is in the origin and
the curve 85° - describe the measurements, when the red-LED is in the origin. The
curve 90° describes the measurements, when the sensor is justified on the color.
We think, for correct measurement it is important that the angle between the sensor
and the object (color) is always the same. So we must show, that the angel is nearly
90°, because it is easier to holt the sensor with a angel of 90° then with 85°+ or 85°-.
c) Temperatures measurement
8/28
1000 measurements without break
250,000
245,000
240,000
value of the colors
235,000
230,000 Red-LED
Green-LED
225,000 Blue-LED
220,000
215,000
210,000
205,000
0 100 200 300 400 500 600 700 800 900 1000
counter of measures
On this point we can not say that the changing of the values is an effect of the
temperature. So we made new measurements.
At first we made 30 measurements and between the measurements we turned all three
Leds on for 2 minutes. On the graph below are the results of this measurement.
240,000
235,000
230,000
v a lu e o f h te c o lo rs
225,000
Red-LED
220,000 Green-LED
Blue-LED
215,000
210,000
205,000
200,000
0 5 10 15 20 25 30
counte r of me asure s
The brake of two minutes causes that the sensor can cool down. The values are nearly
constant, so the temperature has an influence to the values rather to the Pin Diodes.
After a consultation with the producer of the sensor we get an idea how we can solve
the problem with the temperature. The sensor has inside a Monitor Diode.
9/28
With this Monitor Diode we can measure the temperature, and we can adjust the RGB
values.
In the next graphs we made different measurements including the measurements with
the Monitor Diode (temperature).
215,000
210,000
value of the colors
205,000
Red
200,000 Green
Blue
195,000
190,000
185,000
1 6 11 16 21 26 31 36 41 46 51 56 61 66 71 76
qua ntity of m e a sure s
3,578
3,577
3,576
3,575
values of the colors
3,574
3,573
3,572
3,571
3,57
3,569
1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77
quantity of m e as ur e s
10/28
RGB-values of the third measurement
210,000
205,000
value of the color
200,000
Red
Green
Blue
195,000
190,000
185,000
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29
quantity of measures
11/28
Monitor Diode of the third measurement
3,58
3,578
value of the color
3,576
Reihe1
3,574
3,572
3,57
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29
quantity of measures
The voltage of the monitor diode depends on the temperature of the sensor.
12/28
4. Researches of methods for color identification
An important point is to give out the right color, but at first we have to detect it. To find the
right color we use a table with the RGB values of the 24 most important colors.
To explain the methods for detecting the color we take random values for the measured RGB
values.
For example:
R G B
measured value 35 100 70
This example shows you the color bluish green with the index 6. The next step is to calculate
the difference between the measured values and the reference values which is pictured below.
13/28
a) First method
+
Now we take the 12 minimum values of the red-LED and accept the two other values
form the two other colors.
In the second step, we pick out the 6 Minimum values of the green-LED from the table
on the top.
In the third step, we pick out the 3 minimum values of the blue-LED from the table
above.
Now we made the sum of all values of each index. The result is:
The result with the first method is the color blue sky with the index 3.
14/28
b) Second method
In the second method we used an allowance for the research, in this we choose index
10. This means, that the measured values can have only a difference of +/-10 to the
reference value.
In the first step we pick out the values from each LED, where the difference is lower
+/- 10 and made the sum of all values of each index
Green-LED
Index R G B
6 14,265 1,815 28,120 44,200
Blue-LED
Index R G B
17 139,562 72,142 8,173 219,876
13 24,740 90,151 9,661 124,552
The result with the second method is the color bluish green with the index 6.
c) Third method
The third method is nearly the same like the second method. The difference is only,
that we don’t make the sum of all differences. We make a weighting of all values from
each index.
15/28
This will need surely at most
computing power, because of
Depend on the allowance, the smaller it is, the smaller is the weighting of all values from
3 the storage requirement. each index.
As a conclusion, we can say, all the three methods have a possibility, to get the false
color-name. So we have found an easier and exacting method to find the correct color.
The method which we are using to detect the color is a mathematical method. With
Red, Green and Blue we can create a RGB - Color room, in this room counts the same
mathematical rules like in other vector rooms.
To detect the color we calculate the smallest vector to the reference colors. This is a
normal vector calculation.
Calculation: smallest vector…v
Reference red value …rv
Reference green value. …gv
Reference blue value …bv
Measured red value …mrv
Measured green value …mgv
Measured blue value …mbv
v = ( rv − mrv ) 2 + ( gv − mgv ) 2 + (bv − mbv ) 2
For every reference color we get a result, but the smallest value gives as the correct
color.
16/28
5. Selection of the construction units - Hardware
a) Introduction
b) Power supply
A 3 Volt Battery is used for the power supply. The Microcontroller and the Speech
Chip needs 5 Volt, so the 3 Volt is not enough. The MAX756 is a step up converter
which converts an input voltage between 1.7 Volt to 5 Volt up to 3 Volt or to 5 Volt.
This Chip detects also when the battery is low. With 5 Volt output voltage it is
possible to get an output current up to 200 mA.
c) Sensor
The Sensor consists of a Red LED, Green LED, Blue LED, two Photo Diodes, and a
Monitor Diode. There is also a connected ground and a reference Voltage for the
Photo Diodes.
The Red LED needs a voltage around 1.91 Volt and a current of 14mA, so the resister
between microcontroller and the LED must be 22K. The blue LED needs a voltage of
3.75 Volt and a current of 7mA so the resister must be 180Ohms. The Green LED
takes 5 Volt and a current of 32mA, but the microcontroller has an output current of a
maximum of 25mA. So the current is given by a transistor. The basis of this transistor
is connected to the microcontroller and the emitter is connected to the green LED. If
17/28
the output port of the microcontroller is set low the transistor locks. If the output port
is high the green LED gets the current.
The Photo Diodes are used for detecting the light intensity. The resistor or the
conductivity of the Photo Diodes is changing when the light intensity is changing.
The Monitor Diode is used for detecting the temperature in the sensor. It is also
changing the resistor when the temperature is changing.
d) The Amplifier
e) Microcontroller
We use the PIC18F2455 from microchip. More information about the microcontroller
please visit the datasheet
(http://www.microchip.com/downloads/en/DeviceDoc/39632c.pdf).
The Voltage of the Pin Diode1 is connected with the Pin 2 (Port A0), and the Pin
Diode 2 is connected with Pin 3 (Port A1). On the Pin3 we find the Monitor Diode. On
the Pins 11, 12, 13 are connected the Leds (Blue, Red, Green). It is possible to detect
the low battery with the Port RC5 (Pin16). On Pin 18 (Port RC7) is the bush bottom to
start a measurement. The Pins 21, 22, 23, 24, 25 (Port B0…B4) are the address lines
for the Speech Chip. With Pin 27 (Port B6) we can detect when a played message is
finish. To start playing a message we give the signal on Pin 28 (Port B7).
18/28
f) Speech chip
We are using the speech chip to give out the name of the color by a speaker. After
researches we have decided to use an ISD chip, because it was the only chip which is
able to give out an analog signal.
For us it was important because the digital output of a voice is very hard to
understand.
We are using the ISD 1420, which can store 20 seconds. The following graph shows
the protective circuit.
This circuit was important to record the different messages (color names). The
addresses A0-A7 we are using to select the position of the message with a binary code.
The buttons PLAYL / PLAYE / REC are to play or store the messages. The AGC
input is for amplify of the input signal. The input signal can be transmitted by two
different ways. The first way we are using is a Microphone and the second way we set
the output “ANA OUT” after the capacitor at Ground. Then we connect an analog
signal (PC/ MP3-player …) on the “ANA IN”.
For the output we are using an 8 Ohm speaker.
19/28
g) Schematic
h) Board
20/28
Top:
Bottom:
21/28
6. The design
22/28
7. Introduction of Software Development
The goal of this report is to development of software for microcontroller to develop the
embedded system of the color detection project. The basic idea of the software is to
communicate with two modules of the embedded system sensor and speech chip.
First of all, Ports configuration done of microcontroller. After that it turns on each LED of the
sensor in sequence and when the Led is turning on, Pin diodes of the sensor measures the
reflection of Led light and it was simply done by calling analog to digital function (ADC).
Then some mathematical operations are come in the picture, which are applied on result of
ADC to make it comparable with universal RGB values (stored in arrays).
Next step is to compare this measured and calculated RGB values with universal RGB values
and here, software finds the minimum distance between measured and universal RGB values.
At the end, after finding minimum distance it is ready to send 5 bits address to speech chip
where the colours are stored and after receiving this message speech chip is responsible to
speak the matching color.
The microcontroller used was PIC18F2455 from microchip. The programmer tools were
MPLAB and PICSTART Plus from Microchip. All the programming development was made
in ANSI C using Microchip C18 compiler.
23/28
a) The Program
#include <stdio.h>
#include <math.h>
#include <adc.h>
#include <delays.h>
#include <p18f2455.h>
//Function declaration
void color_detection(int, int, int);
void play(void);
int adc_1(void);
int adc_2(void);
//Global arrays
unsigned long red[] = {43 , 147, 36, 27, 71, 49, 148, 23, 35, 164, 10, 24, 167, 194, 175, 19, 235, 47, 8};
unsigned long green[]= {26, 75, 40, 34, 50, 102, 87, 22, 13, 133, 10, 58, 15, 177, 28, 30, 234, 49,8};
unsigned long blue[]={16, 55, 85, 16, 110, 98, 14, 102, 36, 17, 80, 17, 12,15,78, 90, 226, 50, 8};
unsigned long new[19], search=0;
OpenADC(ADC_FOSC_32 & ADC_LEFT_JUST , ADC_CH0 & ADC_CH1 & ADC_16_TAD & ADC_INT_OFF &
ADC_VREFPLUS_VDD & ADC_VREFMINUS_VSS , 13);//Initialize analog to digital converter
while(1)
{
voltage_r2=adc_2();
}
voltager=(unsigned int)((voltage_r1+voltage_r2)/2);
//Next two instructions converts the result(Red LED) into RGB form
voltage1= (voltager-180)*(-1);
voltage_r = (voltage1*3);
i=0;
for(i=0;i<delay;i++)//Turn off Red LED and wait for short time
{
PORTC=0x00;
}i=0;
24/28
for(i=0;i<1000;i++)//Turn on Blue LED for short time
{
PORTC=0x01;
voltage_b1=adc_1();// Store the result of Analog to Digital conversion(Blue LED)
voltage_b2=adc_2();
}i=0;
voltageb=(unsigned int)((voltage_b1+voltage_b2)/2);
//Next two instructions converts the result(Blue LED) into RGB form
voltage3= (voltageb-180)*(-1);
voltage_b = (voltage3*4);
for(i=0;i<delay;i++)//Turn off Blue LED and wait for short time
{
PORTC=0x00;
}i=0;
//This function is responsible for detecting the color and sending the message to Speech chip
void color_detection(int voltage_r, int voltage_g, int voltage_b)
{
unsigned long nred=0, ngreen=0, nblue=0,i=0;
//This loop finds the distances between measured colors result and universal RGB color values
for(i=0;i<=18;i++)
{
nred= (unsigned long)((red[i]-voltage_r)*(red[i]-voltage_r));
ngreen= (unsigned long)((green[i] - voltage_g)*(green[i] - voltage_g));
nblue= (unsigned long)((blue[i] - voltage_b)*(blue[i] - voltage_b));
new[i]= (unsigned long) (nred + ngreen + nblue);
}
i=0;
search=(unsigned long)new[0];
//This loop search for minimum distance
for(i=0;i<18;i++)
{
if(search>new[i+1])
{
search=new[i+1];//printf("%lu\n",search);
}
}
//This loop compares the minimum distance with alredy stored distances and also pass the suitable 5 bits message to
Speech chip.
if(new[0]==search)
{
PORTBbits.RB0=0;
PORTBbits.RB1=0;
PORTBbits.RB2=0;
PORTBbits.RB3=0;
PORTBbits.RB4=0;
play();// Call the function play
}
else if(new[1]==search)
{
PORTBbits.RB0=1;
PORTBbits.RB1=0;
PORTBbits.RB2=0;
PORTBbits.RB3=0;
PORTBbits.RB4=0;
play();
}
else if(new[2]==search)
{
PORTBbits.RB0=0;
PORTBbits.RB1=1;
PORTBbits.RB2=0;
PORTBbits.RB3=0;
PORTBbits.RB4=0;
play();
}
else if(new[3]==search)
25/28
{
PORTBbits.RB0=1;
PORTBbits.RB1=1;
PORTBbits.RB2=0;
PORTBbits.RB3=0;
PORTBbits.RB4=0;
play();
}
else if(new[4]==search)
{
PORTBbits.RB0=0;
PORTBbits.RB1=0;
PORTBbits.RB2=1;
PORTBbits.RB3=0;
PORTBbits.RB4=0;
play();
}
else if(new[5]==search)
{
PORTBbits.RB0=1;
PORTBbits.RB1=0;
PORTBbits.RB2=1;
PORTBbits.RB3=0;
PORTBbits.RB4=0;
play();
}
else if(new[6]==search)
{
PORTBbits.RB0=0;
PORTBbits.RB1=1;
PORTBbits.RB2=1;
PORTBbits.RB3=0;
PORTBbits.RB4=0;
play();
}
else if(new[7]==search)
{
PORTBbits.RB0=1;
PORTBbits.RB1=1;
PORTBbits.RB2=1;
PORTBbits.RB3=0;
PORTBbits.RB4=0;
play();
}
else if(new[8]==search)
{
PORTBbits.RB0=0;
PORTBbits.RB1=0;
PORTBbits.RB2=0;
PORTBbits.RB3=1;
PORTBbits.RB4=0;
play();
}
else if(new[9]==search)
{
PORTBbits.RB0=1;
PORTBbits.RB1=0;
PORTBbits.RB2=0;
PORTBbits.RB3=1;
PORTBbits.RB4=0;
play();
}
else if(new[10]==search)
{
PORTBbits.RB0=0;
PORTBbits.RB1=1;
PORTBbits.RB2=0;
PORTBbits.RB3=1;
PORTBbits.RB4=0;
play();
}
else if(new[11]==search)
{
PORTBbits.RB0=1;
PORTBbits.RB1=1;
PORTBbits.RB2=0;
PORTBbits.RB3=1;
26/28
PORTBbits.RB4=0;
play();
}
else if(new[12]==search)
{
PORTBbits.RB0=0;
PORTBbits.RB1=0;
PORTBbits.RB2=1;
PORTBbits.RB3=1;
PORTBbits.RB4=0;
play();
}
else if(new[13]==search)
{
PORTBbits.RB0=1;
PORTBbits.RB1=0;
PORTBbits.RB2=1;
PORTBbits.RB3=1;
PORTBbits.RB4=0;
play();
}
else if(new[14]==search)
{
PORTBbits.RB0=0;
PORTBbits.RB1=1;
PORTBbits.RB2=1;
PORTBbits.RB3=1;
PORTBbits.RB4=0;
play();
}
else if(new[15]==search)
{
PORTBbits.RB0=1;
PORTBbits.RB1=1;
PORTBbits.RB2=1;
PORTBbits.RB3=1;
PORTBbits.RB4=0;
play();
}
else if(new[16]==search)
{
PORTBbits.RB0=0;
PORTBbits.RB1=0;
PORTBbits.RB2=0;
PORTBbits.RB3=0;
PORTBbits.RB4=1;
play();
}
else if(new[17]==search)
{
PORTBbits.RB0=1;
PORTBbits.RB1=0;
PORTBbits.RB2=0;
PORTBbits.RB3=0;
PORTBbits.RB4=1;
play();
}
else if(new[18]==search)
{
PORTBbits.RB0=0;
PORTBbits.RB1=1;
PORTBbits.RB2=0;
PORTBbits.RB3=0;
PORTBbits.RB4=1;
play();
}
}
27/28
result = ADRESH;//Store the 8 bits result
return(result);
}
int adc_2(void)
{
int result;
SetChanADC(ADC_CH1);
Delay10TCYx(5);//Wait for 50 instruction cycle
ConvertADC();//Start A/D converter
while(BusyADC());//wait until ADC is busy
ReadADC();//Read analog to digital conversion
result = ADRESH;//Store the 8 bits result
return(result);
}
//This function is set digital output PORTB<7> to low to play the sound from speech chip
void play(void)
{
int i=0;
for(i=0;i<2;i++)
{
PORTBbits.RB7=0;
}
PORTBbits.RB7=1;
}
28/28