Professional Documents
Culture Documents
Prepared for
Professor Rashdee
EET-344: Microprocessor with Peripherals
DeVry University, Fremont
Prepared by
Mai Zoua Vang
Justin Niel
Joshua Quintero
Page
ABSTRACT..................................................................................................….................1
INTRODUCTION/FEASIBILITY………………………………………………………..1
SOFTWARE CODE…….……………………………………………………………….14
RESULTS ……………………………………………………………………………….19
CONCLUSION ………………………………………………………………………….19
APPENDIX ……………………………………………………………………………...21
ii
LIST OF ILLUSTRATIONS
Figures Page
5. Figure 5: Blinds 4
iii
1
ABSTRACT
Background
Have you ever had trouble with your blinds letting out too much heat at night when you forget to
close them? Or would you like your blinds to be open, letting in sunlight and heat as soon as you
get up in the morning? Well we are here to help! We at Solar Blind Systems Inc. have devised a
solution for all of your troubles. It is automatic blinds! These specially designed blinds will
allow the shutters to follow the sunlight in order to let in an optimal amount of heat for your
home and close up when not in use.
Results
We found that we can create blinds that will follow light using light sensors and a simple
program in C++ that will compare the inputs, after the comparison is made, and the output will
be sent to our motor to change the position of the blinds. When there is no sunlight outside to let
in, the blinds will simply close up to retain the heat that is in your home already. This system
will not only be convenient to the average homeowner, but it will also save you money on
electricity bill.
Conclusion
If you would like to save possibly hundreds of dollars on your electricity bill over the next few
years, automatic blinds are the answer for you! With our unique power saving techniques of
blind management, we will save you both time and energy.
INTRODUCTION/ FEASABILITY
These electronic blinds are the future of the world as we know it. No longer will we be required
to maintain our own household blinds to gain optimal lightning and contain the heat stored in our
homes. The natural heating provided by the sun will be sufficient to allow the owner to use less
natural gas and/or electricity to heat their home. The homeowners will also benefit from the
optimal lightning procedures of the system to enable the users to be able to worry less about
using indoor lights. This also can be used on focusing solar cells toward the sun.
The process is simple; we take in light from four strategic locations and compare their values to
locate the position of the sun.
2
Light sensors
Divider
If the sun shines to the left, the left sensor will receive the most amount of light.
Figure 2: Left Sensor
3
If the sun shines in the center, the two center sensors will receive the most amount of light.
Figure 3: Center Sensors
If the sun shines more to the right, the most right will get most of the sunlight.
Figure 4: Right Sensor
4
Whichever location brings in the most light can be considered the location of where the sun is
most closely located at. The motor will turn the blind using the corresponding steps to the
position with the most light. The whole process of taking and comparing the values from the four
sensors repeat over again; closing if there is no longer enough light to bring in.
Figure 5: Blinds
blinds
sensor
Stepper motor
5
*Price does not include power supply, general diodes and wires.
The ADC (Analog-to-Digital Converter) converts a single analog signal into a digital signal
based upon the percentage of a reference voltage that the output is. Thus we can take the input
voltage, divide it by the reference voltage and multiply it by 256 (eight outputs) to receive the
digital output in increments of 1/256.
Source: Alldatasheet.com
6
Four ADC sensors were used to take in the varying sunlight values based upon their locations.
One ADC sensor is located at 22.50; one at 67.50; one at 112.50; and one at 157.50. Only one
ADC is actively sending the data to our microprocessor at a time. A decoder is used to activate
the desired ADC chip. This output is taken into a microprocessor which then compares the value
with the other ADC outputs.
When a normal Light Emitting Diode is set in reversed bias it will act as a phototransistor.
Whenever light is focused upon the LED, the current will flow freely through the diode at
different voltages based upon the amount of light the LED is absorbing. The more light focused
upon the LED, the more voltage the LED will let pass freely through it. This gives us a point of
reference and comparison. Reversed-bias LEDs are used as phototransistor in the automated
blind. When a LED is reversed-bias, the depletion zone widens. When the atoms inside the LED
absorb the light, the energy band inside the atom raises. But instead of releasing the energy
through light, like it usually does, it releases electrons.
A 3-to-8 line decoder takes in three inputs to select one of eight outputs. The three inputs are
binary values (0 and 1) which would result in a value from 0 through 7 which then selects the
corresponding output (output 0 – output 7) to be set at a low state. The outputs of the decoder
are active-low. The outputs of the decoder can then be used to enable the chips connected to
them.
The decoder was used in this project to select one of four ADC to send their digital outputs to the
microprocessor. To do this, the decoder is sent a binary value that signifies the desired ADC
chip. Then the decoder will send a low state to the ADC’s chip select pin. The ADC chip select
pin is active-low.
Source: Alldatasheet.com
7
Table 2: Truth table. This table shows the value of the inputs of the decoder that select the corresponding ADC
chip.
S0 S1 S2 Y0(ADC1) Y1(ADC2) Y2(ADC3) Y3(ADC4)
0 0 0 0 1 1 1
0 0 1 1 0 1 1
0 1 0 1 1 0 1
0 1 1 1 1 1 0
The stepping motor is a four-phase stepper motor. This means that the stepper motor has four
stator windings with a center-tapped common. This common allows the motor to change the
current direction within each of the two coils which changes the polarity of the stator.
The stepper motor used is a 4.7 V motor with 1.5° angle step. To determine the required number
of steps to turn the rotor to a desired position, the following formula was used:
Steps = Desired Angle / Angle step (Specified by the motor).
The ULN2003 is the stepper motor’s driver. It takes in the datas from Port B. The ULN2003
inverses the inputs. After that, each bit is sent to its own Darlington pair, where the voltage is
stepped up to the voltage desired to run the stepper motor.
Figure 9: ULN2003 Pin out
Source: Alldatasheet.com
8
Flowchart
True
True
Switch( difference)
0 1, -1 2, -2 3, -3 Default
Print “position 1” Print “position 2” Print “position 3” Print “position 4” Print “position 4”
Steps = 120 Steps = 241 Steps = 482 Steps = 723 Steps = 723
Position = new_position
Do while loop
True
False
Steps = steps - 1
True False
10
Steps = steps - 1
False
True
Do while loop While keyboard is not
pressed
False
Difference = positon - 1
Switch( difference)
0 1, -1 2, -2 3, -3 Default
While steps != 0
True False
While loop
While loop
Steps = steps - 1
False
End propram
12
Hardware
Figure 10: ADC connection to decoder. Figure 11 shows how the 3-to-8 decoder is connected to each
ADC chip select and Port C.
PORT A
Data
__ 20
CS CLK R
__ 1 Vcc1 19
330 ohm
RD DB0
___ 2 18
WR DB1
3 17
CLK IN DB2
____ 4 16
INTR DB3
10nF 5 ADC0804 15
Vin(+) DB4
6 14
Vin(-) DB5
7 13
5V GND DB6
8 12
Vref/2 DB7 (MSB)
9 GND 11
0.47 uF 10
__ 20
CS CLK R
__ 1 Vcc1 19 330 ohm
RD DB0
___ 2 18
WR DB1
3 17
PORT C CLK IN DB2
____ 4 16
INTR DB3
5 ADC0804 15
10 nF Vin(+) DB4
6 14
Out6
S1 Vcc Vin(-) DB5
1 9 16 7 13
S2 Out0 GND DB6
2 15 8 12
S3 MM74HCT138 Out1 5V Vref/2 DB7 (MSB)
3 14 9 GND 11
___ 0.47 uF
G2A Out2 10
___ 4 13
G2B Out3
5 12
012 G1
6 11
Out4
Out7 Out5
7 GND 10
8 0 1 2 3 4 5 6 7
__ 20
CS CLK R
__ 1 Vcc1 19
330 ohm
RD DB0
___ 2 18
WR DB1
3 17
CLK IN DB2
____ 4 16
10 nF INTR DB3
5 ADC0804 15
Vin(+) DB4
6 14
5V Vin(-) DB5
7 13
GND DB6
8 12
Vref/2 DB7 (MSB)
0.47 uF 9 GND 11
10
__ 20
CS CLK R
__ 1 Vcc1 19
330 ohm
RD DB0
___ 2 18
WR DB1
3 17
CLK IN DB2
____ 4 16
INTR DB3
10 nF 5 15
Vin(+) DB4
6 14
Vin(-) DB5
5V 7 13
GND DB6
8 12
Vref/2 DB7 (MSB)
9 GND 11
0.47 uF
10
13
SOFTWARE CODE
void main()
{
int iwork;
unsigned char sensor_1 = 0, sensor_2 = 0, sensor_3 = 0, sensor_4 = 0,
greater = 0;
int position = 1, new_position, difference, steps = 120;
unsigned char stepper = 0x33;
This portion enters the main then initializes all the variables used in our
program.
// initialized ADC
MDEOutPC(0x378, 0x00); // send the value
cout << '1';
Sleep(6000); // delay
MDEOutPC(0x378, 0x01);
cout << '2';
Sleep(6000);
// send the value
MDEOutPC(0x378, 0x02); // send the value
cout << '3';
Sleep(6000);
// clear screen
system ("cls");
This portion initializes the ADC and clears the screen afterwards.
MDEOutPB(0x378,stepper);
Sleep(10);
MDEOutPB(0x378,0x00);
Sleep(10);
while(steps !=0){
MDEOutPB(0x378,stepper);
Sleep(10);
MDEOutPB(0x378,0x00);
Sleep(10);
_asm{
mov al, stepper
ROR al,1
mov stepper,al
steps = steps - 1;
}
This portion initializes the blinds to position 1(or 22.5 degree). One of the
stepper motor values 33(in hex) is sent to port B. Then we rotated the value
and it became 99(in hex).
do
{
Sleep(50);
greater = sensor_1;
new_position = 1;
This portion checks what position the stepper motor should be in.
switch( difference){
case 0:
cout << "position 1\n";
break;
case 1:
case -1:
steps = 241;
cout << "position 2\n";
break;
case 2:
case -2:
steps = 482;
cout << "position 3\n";
break;
17
case 3:
case -3:
steps = 723;
cout << "position 4\n";
break;
default:
steps = 0;
break;
} //end switch
This portion assigns the actual value of steps the stepper motor should
receive.
position = new_position;
MDEOutPB(0x378,stepper);
Sleep(10);
MDEOutPB(0x378,0x00);
Sleep(10);
_asm{
mov al, stepper
ROR al,1
mov stepper,al
} //end asm
steps = steps - 1;
} //end while
MDEOutPB(0x378,stepper);
Sleep(10);
MDEOutPB(0x378,0x00);
Sleep(10);
_asm{
mov al, stepper
ROL al,1
mov stepper,al
} //end asm
steps = steps - 1;
} //end while
} while (!kbhit()); //end while (!kbhit())
switch( difference){
case 0:
steps = 120;
break;
case 1:
case -1:
steps = 361;
break;
case 2:
case -2:
steps = 600;
break;
case 3:
case -3:
steps = 860;
break;
default:
steps = 0;
break;
} //end switch
_asm{
mov al, stepper
ROL al,1
mov stepper,al
}
steps = steps - 1;
This portion moves the motor to the closed position(0 degrees) when the
keyboard is hit.
} //end while
RESULTS
The results we got were as proposed. The lights sensors would send the value through the ADC
to the microprocessor. The Microprocessor would then interpret these values and determine
which sensor is absorbing the most light. The microprocessor would then send determine the
amount of steps required to reach the desired point. Then the microprocessor would output the
values to the ULN2003 which would then output to the stepper motor. This process would then
enable the blinds to move to the desired position and repeat the process above.
The initial proposal as initially proposed, except we decided to replace the photodiodes with a
reversed bias LED, which in fact was more sensitive compared to the other photodiodes that we
obtained.
CONCLUSION
From this project we learned many important and pertinent facts concerning electronic devices
and microprocessor. This experience helped strengthen our knowledge of the curriculum covered
in this course. We, the group, will now be able to walk away with a strong knowledge in the
design of electronic circuits using microprocessors and interfacing various devices. Among
those devices includes the use of a strong stepper motor.
20
Work Cited
APPENDIX