8051 Hardware Tutorials

March 25, 2018 | Author: Herlene | Category: Analog To Digital Converter, Microcontroller, Sensor, Embedded System, Read Only Memory


Comments



Description

Tutorial 1OBJECTIVE: To test the 8051 system and its ports. REFERENCE: Mazidi and Mazidi, “The 8051 Microcontroller and Embedded Systems,” Chapter 4, Appendix B, and Appendix C.2. MATERIALS: 8051 trainer Logic probe DIP switches with pull-up resistors 8051 Assembler You can either buy a pre-built 8051 trainer or wire-wrap your own trainer. Details on wire-wrapping an 8051 trainer are given in Appendix B of the textbook. We will use such a trainer in all subsequent labs. ACTIVITY 1 Test the operation of the ports of your 8051 trainer as follows. Assemble and run the test program given in Appendix B. The test program toggles the ports of the 8051. Use a logic probe or the LEDs of your digital trainer to watch the bits of the ports toggle on and off. Make sure that the time delay in between the "on" and "off" states is long enough that you can observe each state clearly. ACTIVITY 2 Test the 8051's ports for input operation as follows. Connect each bit of P1 (P1.0 P1.7) of the 8051 to DIP switches of your digital trainer. Make sure that the switches have either pull-up resistors or are buffered as shown in Appendix C.2. Read Appendix C.2 very carefully to make sure that you do not damage the port. Then write and run a program to get data from P1 and send it to P2. Any change of status of the switches connected to P1 will be instantly reflected on LEDs connected to P2. The testing program could look like this. MOV MOV MOV MOV SJMP A,#0FF P1,A A,P1 P2,A HERE ;A=FFH ;make P1 an input port ;get data from P1 ;send it to P2 ;keep doing this HERE: 1 Name: Date: Class: 1. Upon reset, all ports of the 8051 are configured as _____________ (output, input). 2. Which ports of the 8051 have internal pull-up resistors? 3. Which ports of the 8051 require the connection of external pull-up resistors in order to be used for I/O? Show the drawing for the connection. 4. In the 8051, explain why we must write "1" to a port in order for it to be used for input. 5. Explain why we need to buffer the switches used as input in order to avoid damaging the 8051 port. 2 ACTIVITY 2 Repeat Activity 1 while also putting the year you graduated from high school on the second line. Then write and run a program to display your name on line 1 of the LCD (first name followed by last name with a space in between). Note: If you are not monitoring the busy flag of the LCD. Dot Matrix LCD Module: Character-type DMC Series User's Manual by Optrex Corp. When you run your program. Both should be in the middle of the line. or a compatible one. To interface and program an LCD.Tutorial 2 OBJECTIVES: To understand the operation modes of an LCD. See the discussion in Chapter 12. the LCD should show (for example): Alex Young Graduated in 1978 ACTIVITY 3 Write an LCD program to display your last name on the first line and the current year on the second line. put a few milliseconds delay in your program. MATERIALS: 8051 Assembler 8051 Trainer 20x2 LCD DMC20261 from Optrex DMC series.1 of the textbook. “The 8051 Microcontroller and Embedded Systems. ACTIVITY 1 Connect the LCD to your 8051 trainer as shown in Section 12. REFERENCES: Mazidi and Mazidi. 3 .” Chapter 12. 3. 4. To send letter 'A' to be displayed on the LCD. What is the purpose of the E line? Is it an input or an output as far as the LCD is concerned? 5. When is the information (code or data) on the LCD pin latched into the LCD? 4 .Name: Date: Class: 1. To send the instruction code 01 to clear the display. we must make RS = ____. How does the LCD distinguish data from instruction codes when receiving information at its data pin? 2. we must make RS = ___. For the clock source of the ADC804 you have two more options beside the RC circuit: (1) use an external clock source (square wave TTL). Look for the ADC804 data sheet in The National Semiconductor Corp. set up the circuit shown in Figure 12-5 of the textbook.national. ACTIVITY Connect the ADC804 to the 8051 as shown in Figure 12-7 or 12-8 in the textbook. make sure that you use at least three or four D flip-flops to bring down the frequency. Notice that the ADC output is between 0 to FFH. REFERENCES: Mazidi and Mazidi. However.” Chapter 12. we use a potentiometer to apply a 0-to-5 V analog voltage to the input Vin (+) of the ADC804 and the binary outputs are monitored on the LEDs of the digital trainer. C=150 pF You can test the ADC804 before you connect it to the 8051. the output should change. Then assemble and run a program to display the data on the LCD or send it to a PC screen through the serial port of the 8051. On the breadboard.Tutorial 3 OBJECTIVE: To interface an ADC to the 8051. according to National Semiconductor's databook "the WR and INTR node should be momentarily forced to low following a power-up cycle to guarantee operation. this must be converted to decimal and then to ASCII in order to be displayed on the LCD. use the voltmeter to measure the POT voltage and verify the result. It must be noted that in free running test mode the CS input is grounded and the WR input is connected to the INTR output. 5 . “The 8051 Microcontroller and Embedded Systems. indicating the value of the analog input.com/catalog/AnalogDataAcquisition.html MATERIALS: 8051 trainer 8051 assembler ADC804 R=10 K ohms. However. or (2) use the XTAL frequency from the 8051 trainer as shown in Chapter 12 for the ADC804. In each case. This setup is called free running test mode and is recommended by the manufacturer. In that figure. As you change the potentiometers. The next lab will build upon the connections you have made in this lab. where FFH is for a full-scale input. web site: www." Set the potentiometer at different points and see the digital binary output of the ADC indicated on the LEDs. If you use the XTAL frequency from the 8051. D0 values if Vin = 1. Assume that Vref/2 is connected to 1. To get step size of 2 mV.1. RD. (a) step size (b) maximum range for Vin (c) D7 . Indicate the direction of pins WR. 3. State the status of the CS.D0 = 10011100 4.28 V.D0 = 11011101 5. Find the following. what is the value for Vref/2? 6 .D0 values if Vin = 2. The ADC804 is a(n) ____-bit converter. Give the three steps for converting data and getting the data out of the ADC804.D0 = 11111111 (e) Vin if D7 .9 V. 6. (a) step size (b) maximum range for Vin (c) D7 .2 V (d) Vin if D7 . Find the following. and INTR from the point of view of the 8051. INTR.D0 = 11111111 (e) Vin if D7 . and WR pins in each step. RD. 2.7 V (d) Vin if D7 . Assume that Vref/2 is connected to 1. ACTIVITY In place of a potentiometer. see National Semiconductor’s web site: www. Then write a program to display the temperature on the LCD (or PC monitor) continuously.5K. 1. REFERENCES: Mazidi and Mazidi. use the LM34 sensor and set up the circuit shown in Figure 12-10 of the textbook.com MATERIALS: 8051 trainer 8051 assembler LM35 (or LM34) ADC804 LM336-2.5 10K POT 1K. “The 8051 Microcontroller and Embedded Systems. For the sensor's data sheet.Tutorial 4 OBJECTIVE: To interface an LM35 (or LM34) temperature sensor to the 8051 trainer. 7 .national. Heat up or cool down the sensor and observe the temperature.” Chapter 12. and 10K resistors You need to complete Lab 3 to experiment with the temperature sensors before performing this lab. What is the form of the transducer output? 3. Explain signal conditioning and its role in data acquisition. Discuss the advantages of linear devices and of nonlinear devices. What is preprocessing of transducer signals to be fed into an ADC called? 4. 5.Name: Date: Class: 1. What is a transducer? 2. The LM35/LM34 is a ____________ (linear. The LM35 and LM34 produce a _______ mV output for every degree of change in temperature. 8 . 6. nonlinear) device. Modify the count value to make sure that the frequency is exactly 1 kHz. ACTIVITY 2 Write a program using timer 1 to generate a 1 kHz square wave frequency on one of the pins of P1.” Chapter 9. Then examine the frequency using the oscilloscope. Then examine the frequency using the oscilloscope. 9 . Modify the count value to make sure that the frequency is exactly 500 Hz.Tutorial 5 OBJECTIVES: To program the 8051 timer. MATERIALS: 8051 trainer 8051 assembler Oscilloscope ACTIVITY 1 Write a program using timer 0 to generate a 500 Hz square wave frequency on one of the pins of P1. To generate a square wave using the 8051 timer. REFERENCE: Mazidi and Mazidi. “The 8051 Microcontroller and Embedded Systems. 4. In mode 2. What is the lowest frequency that can be generated using Mode 1 if the crystal frequency is 11. What is the maximum frequency that can be generated using Mode 1 if the crystal frequency is 11. 3.0592 MHz? Show your calculation.Name: Date: Class: 1.0592 MHz? Show your calculation. when is TFx set to high? 6. What is the lowest frequency that can be generated using Mode 1 if the crystal frequency is 11.0592 MHz? Show your calculation.0592 MHz? Show your calculation. 5. 2. In mode 1. What is the maximum frequency that can be generated using Mode 2 if the crystal frequency is 11. when is TFx set to high? 10 . com MATERIALS: 8051 trainer 8051 assembler MAX233 (or MAX232) DB-9 RS232 connector with serial cable IBM PC/compatible computer with COM2 port ACTIVITY 1 After connecting (wire wrapping) the MAX233 to the 8051 as shown in Figure 10-8 in the textbook. Change the "Flow Control" to NONE or Xon/Xoff and click OK (definitely do not choose the hardware option). We use COM2 since COM1 is normally used by the mouse. ACTIVITY 2 After making sure that Activity 1 works properly. connect your 8051 system to the PC's COM 2 port. 4. “The 8051 Microcontroller and Embedded Systems. The characters displayed on LEDs are in ASCII (binary). choose "NO"). Type a dummy name. write a program to get data from the PC and display it on an LCD. and click OK. REFERENCES: Mazidi and Mazidi. Here are the steps to set up Hyperterminal: 1. Pick 9600 (or whatever baud rate you programmed the 8051). ACTIVITY 3 Modify and run the program in Activity 1 to transfer the data at the rate of 56K.Tutorial 6 OBJECTIVES: To interface the MAX233 (or MAX232) to the 8051. 5.” Chapter 10. click on Hyperterminal (if you get a modem installation option. 2. www. As you press a key on the PC's keyboard. 11 . After running your 8051 serial program. In Windows Accessory.maxim-ic. For "Connect Using" select COM2 and click OK. 8 bit data. and 1 stop bit. connect P1 to LEDs of your digital trainer and observe the incoming characters (or use a logic probe). Then write a program to transfer your last name to the PC continuously. To write a program to receive data from a PC serially. On the PC side you need to use the Hyperterminal program (or Terminal in Windows 3. If you do not have an LCD connected to the 8051. no parity bit. the character is sent to the 8051 serially and is displayed on LEDs. you should see your last name fill the PC screen. To write a program to transfer data to a PC serially.x) which comes with MS Windows 95 and 98. 3. 7. In this lab.0592 MHz. 5. True or false. 12 . what are the absolute minimum signals needed between the 8051 and the PC? Give their names. The 8051 TxD and RxD signals ________ (are.Name: Date: Class: 1. 2. The 8051 can transfer data in full-duplex. With XTAL=11. are not) TTL-compatible. For full duplex. what is the maximum baud rate for the 8051? 4. what is the role of the MAX233 (MAX232) chip? 3. Show how to achieve the maximum baud rate in Question 3. What is the role of TI and RI? 6. Tutorial 7 OBJECTIVE: To interface an ADC809 to the 8051. www. Each channel can be connected to separate potentiometers to examine the data displayed. As you change the potentiometers. 2. Connect the ADC808/809 to the 8051 and write a program to display data input from at least two of the channels. Notice that the ADC output is between 0 to FFH where FFH is for a full-scale input. Make sure that you use at least three or four D flip-flops to bring down the frequency. (c) Poll EOC for high. you can either use an external clock source (square wave TTL). Read about this chip in Chapter 12 and also download the data sheets from the www. These 8 inputs are called channels and each is selected by an address. indicating the value of the analog input. (b) Activate START (200 µsec). or use the XTAL frequency from the 8051 XTAL as shown in Chapter 12 for the ADC804. which is preferable. Thank you to John Maddux for his input on this lab. “The 8051 Microcontroller and Embedded Systems. 3. The minimum pulse width for ALE = 200 µsec and OE = 250 µsec. The ADC808/809 clock frequency is between 10 kHz and 1250 kHz and must be a minimum of 3V peak. Notice the following points when interfacing the 8051 to the ADC808/809. the output should change.com web site. (d) Send low to OE (for a minimum of 250 µsec). REFERENCES: Mazidi and Mazidi. (a) Select the channel.national.” Chapter 12.html MATERIALS: 8051 assembler and trainer ADC808/809 TTL square wave and TTL square wave clock source ACTIVITY 1 In many applications we need to have multiple analog-to-digital converters. Read data from the ADC808/809 and follow these steps. 13 . However. 1.national.com/catalog/AnalogDataAquisition. (e) Read the data from the data pin. The ADC808/809 is a single chip that can accommodate up to 8 analog inputs. For the clock source of the ADC808/809. this must be converted to decimal and then to ASCII in order to be displayed on the LCD. 14 . Give the steps for converting data and getting the data out of the ADC809. and C in selecting the ADC channel. (a) step size (b) maximum range for Vin (c) D7 .Name: Date: Class: 1.D0 values if Vin = 2. Give the role of signals ALE. 3.D0 = 11111111 (e) Vin if D7 . B. EOC. EOC. and OE from the point of view of the ADC808/809. indicate the direction of pins ALE.7 V (d) Vin if D7 . 2. (a) step size (b) maximum range for Vin (c) D7 . In the ADC809 assume that Vref is connected to 5V.2 V (d) Vin if D7 .56 V. Find the following. 4.D0 = 10011100 5. SC. A. Find the following.D0 values if Vin = 1. State the status of the SC and EOC pins in each step. and OE from the point of view of the 8051. Indicate the direction of pins ALE.D0 = 11111111 (e) Vin if D7 – D0 = 11011101 6. In the ADC809 assume that Vref is connected to 2. SC. In connecting ADC808/809 to an 8051. www. To generate a sine wave on the scope using the DAC.Tutorial 8 OBJECTIVES: To interface a DAC to the 8051. Write and run a program to create the sine wave on the oscilloscope. Also in your circuit.html MATERIALS: 8051 assembler and trainer DAC0808 from National Semiconductor (or its equivalent MC1408 from Motorola) 100 pF capacitor Resistors: 2 of 1K.” Chapter 13. REFERENCES: Mazidi and Mazidi. Change the delay values and state your conclusions. Put a delay in between each outputting of values to DAC and observe the sine wave on the scope. change the POT value and monitor the output sine wave on the scope. 2 of 1.com/catalog/AnalogDataAcquisition. Then set up a circuit like the one shown in Figure 13-7.national. 15 .5K 5 K potentiometer ACTIVITY First generate (calculate) a table similar to Table 13-5 of the textbook for sine values of 4-degree increments. “The 8051 Microcontroller and Embedded Systems. Define the following terminology in DAC. In Figure 13-7 of the textbook.Name: Date: Class: 1. find Vout for the following inputs. (a) 11001100 (b) 10001111 3. assume that R = 2. (a) 11000010 (b) 01000001 (c) 00101100 (d) 11111111 16 . (a) resolution (b) full-scale voltage output (c) settling time 2. For your circuit. we need DAC with ________ (more. To get a smaller step size.5 K ohms. less) data bit inputs. 4. Calculate Vout for the following binary inputs. 2 and send it to P1. ACTIVITY 2 Write an 8051 program to get data from a single bit of P1. To program the hardware interrupt of the 8051. MATERIALS: 8051 trainer 8051 assembler Square wave generator ACTIVITY 1 Write an 8051 program to get data from one port and send it to another port continuously while an interrupt will do the following: One of the timers will toggle the PX.” Chapter 11.2) and any time a H-to-L pulse comes in a single LED is turned on. a single LED is turned on. (Either connect LEDs to this port to examine the data coming in or display the received data on an LCD). In this activity you can also use INT1 17 . ACTIVITY 3 Write an 8051 program to get data from one port and send it to another port continuously while an interrupt can do the following: Connect the INT0 (or INT1) pin to a normally high debounce SW and any time the switch is pressed.7 continuously while an interrupt will do the following: A serial interrupt service routine will receive data from a PC and display it on one of the ports.Tutorial 9 OBJECTIVES: To program the timer interrupt of the 8051. REFERENCE: Mazidi and Mazidi. To program the serial interrupt of the 8051. ACTIVITY 4 Write an 8051 program to get data from one port and send it to another port continuously while an interrupt will do the following: A square wave is connected to the INT0 (pin 3. The rate of "On" and "Off" is the rate of the square wave. “The 8051 Microcontroller and Embedded Systems.Y bit every 100 microseconds. In timer mode 1. In timer mode 2. True or False. INT0 (and INT1) are _________ (edge. Name all of the interrupts in the 8051 and their vector table addresses. which interrupt has the highest priority? 6. 2. There is only a single interrupt for the serial data transfer. 3. 18 . indicate when TF0 causes the interrupt. level) triggered. 4. On reset. indicate when TF0 causes the interrupt. 5. On reset.Name: Date: Class: 1. plus Figure C-20.” Chapter 15. Use the ASCII code OA (hex) for line feed and OD (hex) for carriage return to make sure that each line is printed on a separate line. “The 8051 Microcontroller and Embedded Systems. Make sure you have buffered the signals with 74LS244 chips. Write and run a program to print the message.Tutorial 10 OBJECTIVES: To interface a Centronics printer to the 8051.0DH 19 . "OK IT WORKS !" ACTIVITY 2 Make the following modifications in the program of Activity 1. To gain an understanding of printer handshaking signals. In the code section put the following data: Last name. as shown below: MYDATA: ORG 200 DB "Smart Alex". First name Date Course number Each of the above must be printed on a separate line. Connect the data bus and handshaking signals of the printer to your 8051 as shown in Figure C-20. MATERIALS: 8051 assembler and trainer Centronics printer 74LS244 ACTIVITY 1 Examine the Centronics cable pins and their description in Chapter 15 of the textbook.OAH. REFERENCE: Mazidi and Mazidi. Signal Direction D0-D7 STROBE ACK 2. In monitoring the busy signal. low) before issuing the next byte of data to the printer. 20 . For each of the following signals. Indicate the direction of the following signals from the 8051's point of view. the strobe pins needs a ______________ (H-to-L. the 8051 looks for _______ (high. L-to-H) signal. 5. To make the printer latch in data at its data pins. Indicate the direction of the following signals from the printer's point of view. Printer's Handshake Signal Normal State Active State Strobe ACK 4. Direction Signal D0-D7 STROBE ACK 3.Name: Date: Class: 1. Explain the role of the strobe and busy signals in the handshaking between the 8051 and the printer. indicate its normal status (high or low) and the activation level for each (active low or active high). 6. make sure that the crystal and reset circuits are also included in your design.” Chapter 14 and Appendix B. 21 . The test program simply toggles P1 continuously with a delay in between the "on" and "off" states. In the following activities you can also use any of the 8051 chips. study the basics of wire wrapping in Appendix B. Then wire wrap the 8031 connection to a ROM chip according to Figure 14-11. The size of the ROM chip (UV-EPROM or EEPROM) should be 8K or higher. ACTIVITY 1 First. test the system by running a test program burned into the ROM. MATERIALS: 8031 microcontroller 27XX UV_EPROM (or 28XX EEPROM) 74LS373 Wire wrapping tools Study Chapter 14 and examine the 8031 connection to external memory. See Chapter 4 for the crystal and reset connection.Tutorial 11 OBJECTIVE: To interface an 8031 to external ROM.1 if you have never done any wire wrapping. ORG 0 MOV A. REFERENCES: Mazidi and Mazidi.A ACALL DELAY CPL A SJMP BACK BACK: For the delay subroutine see Chapter 3. “The 8051 Microcontroller and Embedded Systems. That is important since some people try to use the unused portion of P2 for I/O. ACTIVITY 2 After the wire wrapping is done in Activity 1. Notice that in connecting the 8031(8051) to external memory we cannot use P2 for I/O ports. Since this ROM chip is for code. The following test program can be burned into the ROM.#55H MOV P1. In connecting the 8031 to an external memory. explain the role of the following: P0 P2 74LS373 6.5 are used. In connecting the 8031/51 to external ROM.7 for I/O? 22 . can we use P2. In Question 7.6 and P2. What is the role of the PSEN pin in the 8031/51 connection to external ROM? 4. explain the difference between the RD and PSEN signals and where each one is used.P2. Capacity: Number of address pins: Organization: Number data pins: 2. 5. In connecting the 8031/51 to external ROM.Name: Date: Class: 1. What is the size of this external memory? 8. In the 8031/51.0 . how do we make sure that program code is fetched from external ROM? 3. Give the following information for the ROM used in this experiment. What is the maximum external memory that can be connected to the 8031? For code space: For data space: 7. only P2. The test program simply toggles ports A. B. Appendix B. ACTIVITY 2 After wire wrapping the circuit in Activity 1.1. “The 8051 Microcontroller and Embedded Systems.1. In the following activities you can also use any of the 8051 chips. test the 8255. ACTIVITY 1 If you have not done any wire wrapping before. study Appendix B.” Chapter 15. connect the CS (chip select) pin to ground. REFERENCES: Mazidi and Mazidi. 23 . The toggle program is given in Chapter 15. Wire wrap the 8031 connection to an 8255 chip according to Figure 15-4 of the textbook. If you do not want to use an inverter.Tutorial 12 OBJECTIVE: To interface an 8031 to the 8255. MATERIALS: 8031(or 8051) microcontroller 8255 74LS373 Wire wrapping tools Study Chapter 15 and examine the 8031/51 connection to the 8255 chip. and C of the 8255 continuously with a delay in between the "on" and "off" states. explain the role of the following and indicate if its use is optional. In connecting the 8031/51 to the 8255. PA PB PC CR Port 2.Name: Date: Class: 1. explain the role of the RD and WR signals. In connecting the 8031/51 to the 8255. Write a program to get data from PA and send it to both PB and PC." Is the 8255 connection in this experiment a memory mapped I/O? 24 . Explain the term "memory mapped I/O. 5. 4. Why do we use the "MOVX" instruction to access the 8255 in this experiment? 3. Give the addresses assigned to each of the following ports in this experiment. P0 P2 74LS373 6.
Copyright © 2024 DOKUMEN.SITE Inc.