Read Microsoft Word - 8051ProjectReport.doc text version

8051 Project: Automatic Lighting and Visitor Counter

Andrew Herzog Richard Baker December 13, 2007 CMPET 211

Executive Summary The objective of the project was to create a circuit with an 8051 microcontroller that sensed when an object passed through an infrared receiver's receive path to automatically turn on lights and count how many times the receive path was blocked. Discussion To complete the project several smaller circuits were needed to be designed and constructed. The project needed a circuit to pulse an infrared LED at 38 kHz, a circuit to receive the infrared signal, a seven segment LED display circuit, an auto-lighting circuit, and a programming circuit. The project also required code to be written to the 8051 microcontroller to combine all the smaller circuits into an operational system. The 38 kHz generator, Fig. 1-1, was major factor in getting the infrared receiver to operate correctly. A 555 timing chip was used to output a squarewave at 38 kHz for an infrared LED. The generator needed to be completely isolated from the rest of the circuit because it was found that the infrared receiver's output was similar to Fig. 1-2 at a frequency of 38 kHz. The receiver needed to output a high until an object blocked the infrared signal when it would output a low.

Fig. 1-1, 38 kHz Generator

Fig. 1-2, Infrared Receiver Output

The infrared receiver, Fig 1-3, was a very basic component of the project. 5 V was connected to pin three, ground connected to pin two, and the output was on pin one which was connected to pin twelve of the 8051. The receiver output a high as long as nothing was blocking the 38 kHz infrared signal. When an object blocked the signal, the receiver output a low, while being monitored by the 8051.

Fig. 1-3, Infrared Receiver Connections

Fig. 1-4, Infrared Transmitter and Receiver

The seven segment LED display was very similar to the "Interfacing the DS89C430 with a 7-Segment LED Display" lab that was done in the past. A couple problems occurred involving brightness and segments dropping out, those problems will be explained further in "Problems Encountered."

Fig. 1-5, 7 Segment LED Display Connections

The auto-lighting portion of the project, Fig. 1-6, required knowledge learned in EET 210, the use of a transistor, LEDs, and a relay. The transistor had to be used as a switch, so using the rated values from the relay, coil pick-up voltage = 9 V and coil current = 30 mA, and the transistor's hfe of 250, the base resistor of the circuit was found using EQ. 1 and EQ. 2, where hard saturation equals 2 IB.

IB =

I C 30mA = = .12mA h fe 250

EQ. 1, IB

RB =

VB - .7V 5V - .7V = = 17.9k 2I B 2 * .24mA

EQ. 2, RB

A resistor value was also calculated to limit the current in the LEDs. Using the LEDs' current rating, 20 mA, and voltage drop, 1.6 V, the resistance value was calculated to be around 80 using Ohm's Law.

Fig. 1-6, Auto-Lighting Connections

The programming part of the circuit, Fig. 1-7, was the same circuit used all semester to program the 8051.

Fig. 1-7, 8051 Programming

Fig. 1-8, Whole Schematic

Assembly code was written to the 8051 microcontroller so that all the circuits could be combined into one complete system. The code written for the 8051 can be seen in Fig. 1-9.

Fig. 1-9, Project Code ORG 0 TOP: CLR P1.1 CLR P1.3 ACALL DELAY JB P3.2, AGAIN0 MOV P1, #00001010B MOV P2, #01011111B CLR P2.6 SETB P2.6 ACALL DELAY JB P3.2, AGAIN1 MOV P1, #00001010B MOV P2, #01010000B ACALL DELAY JB P3.2, AGAIN2 MOV P1, #00001010B MOV P2, #01101101B ACALL DELAY JB P3.2, AGAIN3 MOV P1, #00001010B MOV P2, #01111001B ACALL DELAY JB P3.2, AGAIN4 MOV P1, #00001010B MOV P2, #01110010B CLR P2.6 SETB P2.6 ACALL DELAY JB P3.2, AGAIN5 MOV P1, #00001010B MOV P2, #01011111B ACALL DELAY JB P3.2, AGAIN6 MOV P1, #00001010B MOV P2, #00111111B ACALL DELAY JB P3.2, AGAIN7 MOV P1, #00001010B MOV P2, #01010001B CLR P2.4 SETB P2.4 ACALL DELAY JB P3.2, AGAIN8 MOV P1, #00001010B MOV P2, #01111111B CLR P2.2 SETB P2.2 ACALL DELAY JB P3.2, AGAIN9 MOV P1, #00001010B MOV P2, #01011111B CLR P2.4 SETB P2.4 ACALL DELAY AGAIN: JB P3.2, AGAIN LJMP TOP

AGAIN0:

DELAY: H1: MOV R4, #100 H2: MOV R3, #100 H3: DJNZ R3, H3 DJNZ R4, H2 DJNZ R5, H1 RET END

AGAIN1:

AGAIN2:

AGAIN3:

AGAIN4:

AGAIN5:

AGAIN6:

AGAIN7:

AGAIN8:

AGAIN9:

First a loop was created to monitor pin twelve of the microcontroller, the output of the infrared receiver, for a low. Once a low was received by the 8051, highs were sent to pin two and pin four to turn on the transistor and the LED display. The proper code for the number to be displayed on the LED display was output on port two; highs corresponded with which segments were to be lit. "CLR P2.6 and SETB P2.6" fixed the problem of the "B" segment not coming on, Fig. 1-10, which will be discussed in detail in the "Problems Encountered" section. This action was also applied to segments "C" and "E" when they would not light.

Fig. 1-10, Segment Fix

AGAIN0: JB P3.2, AGAIN0 MOV P1, #00001010B MOV P2, #01011111B CLR P2.6 SETB P2.6

Problems Encountered Several problems were encountered throughout the course of the project, mostly because the end project isn't the original project that was researched. The infrared sensors that were called for in the original project didn't have part numbers attached to them on the website. Dealing with that, a generic infrared receiver and LED were purchased from Radioshack. From the original project, those sensors along with 555 timer chips were used to detect direction so the counter could increase or decrease. The final project can't do that with only one receiver. If the project were done over, another receiver could've been purchased. Another problem ran into was that the original project called for the auto-lighting to be lamps run by 230 V. To keep things simpler, using only one DC power supply, four LEDs were used. A problem arose when the code was run without a delay after each monitor section where the 8051 would continue down through the code when there was nothing blocking the infrared receiver. Using the oscilloscope, the waveform seen in Fig 1-11 was observed on the infrared receiver's output pin when an object moved through the infrared receive path. A delay was created so that the second low would not be seen by the 8051.

Fig. 1-11, Infrared Receiver Output

A couple of problems were run into with the seven segment LED display. The display was too dim when the same resistors were used from the "Interfacing the DS89C430 with a 7Segment LED Display" were used in the project. 220 resistors instead of 470 resistors were used between the ULN2003A and the display. Also a pull-up resistor of 160 was used on pin 14, VCC, of the display to help with the brightness. Another problem with the display was that when the code was implemented a segment would drop out for certain numbers. It was found that if the wire connecting the ULN2003A was disconnected and reconnected, the segment would light again. To solve the problem, two lines of code, Fig. 1-10, were implemented; clear and set bit commands were issued to the pin of the 8051 associated with the segment.

Conclusion: After a lot of time and effort this project was successful. If there was more time, figuring out a way to decrement the visitor counter using two infrared receivers would be an objective. The code could also be cleaned up a little, which isn't that much of a priority since it doesn't take up that much space. The binary numbers that are output to the LED display could be put in ROM, and a loop could be used to fetch the numbers. The project has real world implications; an example is the automatic lighting in the labs of the REDC. The project doesn't have an automatic turn-off as those lights do, which would also be an objective to complete if there was more time. The project was also a very good learning experience, where material from several EET classes could be applied. The 555 timer chip and LED display was learned in EET 120, transistor theory, diodes, and relays were learned in EET 210, and the 8051 and Assembly was learned in CMPET 211. Learning how the infrared receiver, a special part, operated and interacted with the rest of the circuit was also important.

Information

Microsoft Word - 8051ProjectReport.doc

9 pages

Report File (DMCA)

Our content is added by our users. We aim to remove reported files within 1 working day. Please use this link to notify us:

Report this file as copyright or inappropriate

1262410


You might also be interested in

BETA
Microsoft Word - 8051ProjectReport.doc
Wireless Home Security System
Microsoft Word - The Design And Construction Of An Infrared Activated