AUTOMATED BLINDS

Prepared for Professor Rashdee EET-344: Microprocessor with Peripherals DeVry University, Fremont

Prepared by Mai Zoua Vang Justin Niel Joshua Quintero

February 13, 2007

CONTENTS Page ABSTRACT..................................................................................................….................1 INTRODUCTION/FEASIBILITY………………………………………………………..1 MATERIALS AND EQUIPMENTS……………………………………………………...5 Basic information of ADC ………………………………………………………..5 Basic information of reversed-bias LED………………………………………....6 Basic information of 3-to-8 line decoder………………………………………....6 Basic information of stepping motor ……………………………………………..7 Basic information of ULN2003 …………………………………………………..7 PROGRAMMING AND INTERFACING APPROACH…..…………………………….8 Flowchart …………………………………………………………………………8 Hardware ………………………………………………………………………...12 SOFTWARE CODE…….……………………………………………………………….14 RESULTS ……………………………………………………………………………….19 CONCLUSION ………………………………………………………………………….19 WORKS CITED ………………………………………………………………………...20 APPENDIX ……………………………………………………………………………...21

ii

Figure 12: Circuit Page 2 2 3 3 4 5 6 7 7 12 13 13 iii . Figure 7: 3-to-8 Decoder Pin out (MM74HC138M) 8. Figure 5: Blinds 6. Figure 1: Light Sensors 2. Figure 10: ADC connection to decoder 11.LIST OF ILLUSTRATIONS Figures 1. Figure 3: Center Sensors 4. Figure 6: ADC Pin out 7. Figure 9: ULN2003 pin out 10. Figure 4: Right Sensor 5. Figure 8: Stepper Motor sequence 9. Figure 11: ULN2003 connection to Stepper Motor 12. Figure 2: Left Sensor 3.

This also can be used on focusing solar cells toward the sun. 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. 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. INTRODUCTION/ FEASABILITY These electronic blinds are the future of the world as we know it. 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. and the output will be sent to our motor to change the position of the blinds. after the comparison is made. Conclusion If you would like to save possibly hundreds of dollars on your electricity bill over the next few years. When there is no sunlight outside to let in. we take in light from four strategic locations and compare their values to locate the position of the sun. but it will also save you money on electricity bill. the blinds will simply close up to retain the heat that is in your home already. 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. we will save you both time and energy. The process is simple. automatic blinds are the answer for you! With our unique power saving techniques of blind management. No longer will we be required to maintain our own household blinds to gain optimal lightning and contain the heat stored in our homes. have devised a solution for all of your troubles. This system will not only be convenient to the average homeowner. 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. .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.

the left sensor will receive the most amount of light.2 There are four light sensors located at different angles. Figure 2: Left Sensor . Figure 1: Light Sensors Light sensors Divider If the sun shines to the left.

Figure 3: Center Sensors If the sun shines more to the right. Figure 4: Right Sensor .3 If the sun shines in the center. the two center sensors will receive the most amount of light. the most right will get most of the sunlight.

Figure 5: Blinds blinds sensor Stepper motor . The motor will turn the blind using the corresponding steps to the position with the most light.4 Whichever location brings in the most light can be considered the location of where the sun is most closely located at. 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.

17 1 Blind $15.69 Resistors $0.98* Part Num.17 5 103 Ceramic capacitor $0.com .01 2 Banana-to-banana cord Total expense $42. Table 1: List of Materials Quantity 4 1 Description Cost Green LEDs $0. general diodes and wires. 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.95 Analog-to-digital 4 ADC0804 converter $7.63 Wires 6 General diodes 1 Triple power supply 1 ULN2003 Current driver $0. *Price does not include power supply.40 Stepping motor $17.96 1 MM74HC138 3-to-8 line decoder $0. Figure 6: ADC Pinout Source: Alldatasheet.5 MATERIALS AND EQUIPMENTS The materials used in the automated blind are listed in Table 1. Basic information of ADC 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.

the energy band inside the atom raises. the more voltage the LED will let pass freely through it. the current will flow freely through the diode at different voltages based upon the amount of light the LED is absorbing. Basic information of reversed-bias LED When a normal Light Emitting Diode is set in reversed bias it will act as a phototransistor. A decoder is used to activate the desired ADC chip. like it usually does. This gives us a point of reference and comparison.50.50. One ADC sensor is located at 22. When the atoms inside the LED absorb the light. The more light focused upon the LED. Only one ADC is actively sending the data to our microprocessor at a time. Then the decoder will send a low state to the ADC’s chip select pin. it releases electrons. Figure 7: 3-to-8 Decoder Pinout (MM74HC138M) Source: Alldatasheet.50. Reversed-bias LEDs are used as phototransistor in the automated blind. and one at 157. Basic information of 3-to-8 line decoder A 3-to-8 line decoder takes in three inputs to select one of eight outputs. The decoder was used in this project to select one of four ADC to send their digital outputs to the microprocessor. Whenever light is focused upon the LED. one at 67. The outputs of the decoder are active-low.6 Four ADC sensors were used to take in the varying sunlight values based upon their locations. When a LED is reversed-bias. The ADC chip select pin is active-low. To do this. The outputs of the decoder can then be used to enable the chips connected to them. the depletion zone widens. the decoder is sent a binary value that signifies the desired ADC chip. one at 112.50.com . This output is taken into a microprocessor which then compares the value with the other ADC 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. But instead of releasing the energy through light.

7 V motor with 1. Figure 8: Stepper Motor Sequence Clockwise Step # Winding A Winding B Winding C Winding D Dec # Counter-clockwise 1 1 0 0 1 9 2 1 1 0 0 C 3 0 1 1 0 6 4 0 0 1 1 3 Basic information of ULN2003 The ULN2003 is the stepper motor’s driver. Figure 9: ULN2003 Pin out Source: Alldatasheet. the following formula was used: Steps = Desired Angle / Angle step (Specified by the motor). This common allows the motor to change the current direction within each of the two coils which changes the polarity of the stator. This stepper motor has a four step sequence as displayed below.7 Table 2: Truth table. 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 Basic information of stepping motor The stepping motor is a four-phase stepper motor. After that.5° angle step. each bit is sent to its own Darlington pair. where the voltage is stepped up to the voltage desired to run the stepper motor. This table shows the value of the inputs of the decoder that select the corresponding ADC chip.com . To determine the required number of steps to turn the rotor to a desired position. This means that the stepper motor has four stator windings with a center-tapped common. The stepper motor used is a 4. It takes in the datas from Port B. The ULN2003 inverses the inputs.

8 PROGRAMMING AND INTERFACING APPROACH Flowchart Initialized char stepper = 0x33H Initialized ADC Initialized blind to position 1 Read values from LEDs Set greater = sensor_1 Set Position = 1 Greater < sensor_2 True Set greater = sensor_2 Set new_position = 2 False Greater < sensor_3 True Set greater = sensor_3 Set new_position = 3 False Greater < sensor_4 False True Set greater = sensor_4 Set new_position = 3 Difference = position – new_position .

-1 2.9 Switch( difference) 0 1. -3 Default Print “position 1” Steps = 120 Print “position 2” Steps = 241 Print “position 3” Steps = 482 Print “position 4” Steps = 723 Print “position 4” Steps = 723 Position = new_position Do while loop While(steps !=0 && difference <=0) True Send stepper value to Port B Rotate value to right once False Steps = steps . -2 3.1 While(steps !=0 && difference >=0) True False .

-1 2.1 False True Do while loop While keyboard is not pressed False Difference = positon .1 Switch( difference) 0 1. -3 Default Steps = 120 Steps = 361 Steps = 600 Steps = 860 Steps = 0 While steps != 0 While loop True False Send stepper value to Port B .10 Send stepper value to Port B Rotate value to the left once Steps = steps . -2 3.

11 Rotate stepper value to the light once While loop Steps = steps .1 False End propram .

Figure 11 shows how the 3-to-8 decoder is connected to each ADC chip select and Port C.47 uF .12 Hardware Figure 10: ADC connection to decoder.47 uF Vref/2 __ CS __ RD ___ WR CLK IN ____ INTR Vin(+) Vin(-) GND Vref/2 20 1 2 3 4 5 6 7 8 9 GND 10 Vcc1 19 18 17 16 15 14 13 12 11 CLK R DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 (MSB) 330 ohm 10 nF 5V 0.47 uF GND Vref/2 __ CS __ RD ___ WR 20 1 2 3 4 5 6 7 8 9 GND 10 ADC0804 Vcc1 19 18 17 16 15 14 13 12 11 CLK R 330 ohm DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 (MSB) PORT C 10 nF Out6 S1 S2 S3 ___ G2A ___ G2B 1 2 MM74HCT138 3 4 5 6 7 GND 8 14 13 12 11 10 9 16 15 Vcc Out0 Out1 Out2 Out3 Out4 Out5 CLK IN ____ INTR Vin(+) Vin(-) GND 5V Vref/2 0.47 uF 012 G1 Out7 0 __ CS __ RD ___ WR CLK IN ____ INTR Vin(+) 20 1 2 3 4 5 6 7 8 9 GND 10 ADC0804 Vcc1 19 18 17 16 15 14 13 12 11 CLK R DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 (MSB) 330 ohm 1 2 3 4 5 6 7 10 nF 5V Vin(-) GND 0. PORT A Data __ CS __ RD ___ WR CLK IN ____ INTR Vin(+) Vin(-) 20 1 2 3 4 5 6 7 8 9 GND 10 ADC0804 Vcc1 19 18 17 16 15 14 13 12 11 CLK R DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7 (MSB) 330 ohm 10nF 5V 0.

Figure 12: Circuit . The ULN2003 is connected to the stepper motor. Figure 11: ULN2003 connection to the stepper motor.13 It shows how Port B is connected to the inputs of the ULN2003.

new_position. // initialized ADC MDEOutPC(0x378. MDEConfigPort(0x378. cout << '3'.h> "mdedriverdll. sensor_4 = 0.14 SOFTWARE CODE #include #include #include #include #include <windows. 0x00). 0x90). Sleep(6000). // delay // initialize driver // send the value // delay // send the value // send the value // send the value . sensor_3 = 0. void main() { int iwork. cout << setiosflags(ios::unitbuf). MDEOutPC(0x378. MDEOutPC(0x378. unsigned char stepper = 0x33. Sleep(6000). iwork = MDEOpenLPTPort(0x378). This Porstion initializes the ports.h> <iomanip.h> <conio. MDEOutPC(0x378. cout << '2'. cout << '1'. greater = 0.h> <iostream. This portion enters the main then initializes all the variables used in our program. Sleep(6000). 0x01).h" // header for Sleep This portion links the necessary header files to our project. unsigned char sensor_1 = 0. Sleep(6000). 0x02). 0x03). cout << '4'. sensor_2 = 0. difference. int position = 1. steps = 120.

Sleep(50).0x00). MDEOutPC(0x378. One of the stepper motor values 33(in hex) is sent to port B. Sleep(10).al } steps = steps . MDEOutPB(0x378. MDEOutPC(0x378. do { //cout << '1'.0x00). sensor_2 = MDEInPA(0x378). 0x01). Sleep(50). MDEOutPB(0x378. Sleep(50). // initialized blind to position 1. This portion initializes the ADC and clears the screen afterwards.5 degree MDEOutPB(0x378.1. Sleep(10). sensor_3 = MDEInPA(0x378).stepper). cout << '3'. Sleep(10). Then we rotated the value and it became 99(in hex). 0x00). Sleep(50).1 mov stepper. } This portion initializes the blinds to position 1(or 22. sensor_1 = MDEInPA(0x378). _asm{ mov al. MDEOutPB(0x378.22. while(steps !=0){ MDEOutPB(0x378. MDEOutPC(0x378. 0xff). stepper ROR al. 0x02). Sleep(100). // send the value // send the value // send the value // delay // .15 // clear screen system ("cls"). Sleep(10).stepper). // cout << '2'.5 degree).

greater = sensor_1. } else if(greater < sensor_3){ greater = sensor_3. case 1: case -1: steps = 241. //cin >> new_position. new_position = 2.16 Sleep(50). cout << "position 2\n". break. 0x03). MDEOutPC(0x378. This portion checks what position the stepper motor should be in. break. switch( difference){ case 0: cout << "position 1\n". // cout << '4'. // delay // send the value This portion takes in the data from the ADC converters. Sleep(50). Sleep( 50). case 2: case -2: steps = 482. if(greater < sensor_2){ greater = sensor_2. } //cout << "Enter value ". new_position = 3. sensor_4 = MDEInPA(0x378). new_position = 1. } else if(greater < sensor_4){ greater = sensor_4.new_position. new_position = 4. cout << "position 3\n". break. . difference = position .

al } //end asm steps = steps .0x00). cout << "position 4\n".1 mov stepper. Sleep(10). _asm{ mov al. } //end switch This portion assigns the actual value of steps the stepper motor should receive. MDEOutPB(0x378.al } //end asm steps = steps . break.1 mov stepper. Sleep(10).0x00). } //end while while(steps !=0 && difference >= 0){ MDEOutPB(0x378. stepper ROL al. while(steps !=0 && difference <= 0){ MDEOutPB(0x378. Sleep(10). position = new_position.stepper). MDEOutPB(0x378. stepper ROR al.17 case 3: case -3: steps = 723. default: steps = 0.1. . This portion moves the stepper motor to the right location.1. Sleep(10). _asm{ mov al. break.stepper).

Sleep(10). } // close the driver This portions closes the port and ends the program.1. case 3: case -3: steps = 860.18 } //end while } while (!kbhit()). break. switch( difference){ case 0: steps = 120. break. stepper ROL al. _asm{ mov al. . } //end switch while( steps != 0){ MDEOutPB(0x378.al } steps = steps .0x00). } //end while MDECloseDriver(). Sleep(10).1 mov stepper. case 1: case -1: steps = 361.1. break. This portion moves the motor to the closed position(0 degrees) when the keyboard is hit. break. default: steps = 0. case 2: case -2: steps = 600. //end while (!kbhit()) // closed blind completely difference = position . MDEOutPB(0x378.stepper). break.

19 RESULTS The results we got were as proposed. Among those devices includes the use of a strong stepper motor. This experience helped strengthen our knowledge of the curriculum covered in this course. This process would then enable the blinds to move to the desired position and repeat the process above. the group. The lights sensors would send the value through the ADC to the microprocessor. The initial proposal as initially proposed. which in fact was more sensitive compared to the other photodiodes that we obtained. The Microprocessor would then interpret these values and determine which sensor is absorbing the most light. . will now be able to walk away with a strong knowledge in the design of electronic circuits using microprocessors and interfacing various devices. except we decided to replace the photodiodes with a reversed bias LED. Then the microprocessor would output the values to the ULN2003 which would then output to the stepper motor. The microprocessor would then send determine the amount of steps required to reach the desired point. We. CONCLUSION From this project we learned many important and pertinent facts concerning electronic devices and microprocessor.

html.html.html .alldatasheet.20 Work Cited “ADC0804 : 8-Bit. http://pdf1.” Fairchild Semiconductor Coporation. 1999.com/datasheetpdf/view/25575/STMICROELECTRONICS/ULN2003.com/datasheet-pdf/view/66283/INTERSIL/ADC0804.” STMICROELECTRONICS. Microprocessor.alldatasheet. “MM74HCT138N : 3-to-8 Line Decoder.alldatasheet. A/D Converters.com/datasheet-pdf/view/53791/FAIRCHILD/MM74HCT138N. http://pdf1. “ULN2003 : SEVEN DARLINGTON. 1999.” Intersil Corporation. http://pdf1. 2002.Compatible.

21 APPENDIX .

Sign up to vote on this title
UsefulNot useful