Preview only show first 10 pages with watermark. For full document please download

Experiment-20

   EMBED


Share

Transcript

Experiment-20 Building an 8086 Based Temperature Meter on Breadboards Read every step of a task and work accordingly. When you finish a step, put Tick Mark ( ) on the step using a wood pencil. Ask Lab Teacher for Help. Task-20.1 Introduction The best way to learn architecture and programming of 8086 microprocessor is to design and develop a small system that can possibly be accommodated on breadboards. To accomplish this purpose, we have presented in this experiment, the design and development procedures of an 8086 based ‘Temperature Meter (Fig-20.1-20.3).’ The control program of the meter has been developed and tested using MicroTalk-8086 Trainer of Fig-20.2. Finally, the program codes and the data are stored into the EPROMs (U6, U7 of Fig-P1.1) using commercial ROM programmer – TOP2005. Figure-20.1: Components Layout Figure-20.2: Developing by MicroTalk-8086 tempM U11 8255 U1 8284 U7 27C256 (Ubank) Y1 U6 AD0832 U12 27C256 (MPDEC) DP0 DP2 DP2 DP3 U8 27C256 (Lbank) U2 8086 +5V Power Supply U9 62256 (Ubank) U3 74LS373 U10 62256 (Lbank) U4 74LS373 U5 74LS373 Figure-20.3: Expanded View of Components on Breadboard Heat NTC +5 TS V Simplified Hardware Block Diagram U6: ADC0832 DO Ch1 DI R2 TOU VDT Ch0 CK 5k T A (22.8 C, 1.64V) CS/ 6 B (25.0 C, 1.80V) 0V Response of TS Temp Sensor Serial ADC +5V R1 10k U11: 8255 PC4 PC2 PC1 20mS U2: 8086 NMI CS/ B B B PC0 B RAM IO Controller U9, U10 MPU U11: 8255 1/10 Task-20.2 B PA7-PA0 8 p,…,a PB3-PB0 B ROM U7, U8 IO Controller DP0 DP1 DP2 DP3 cc0 cc1 cc2 cc3 CC7SDD Figure-20.4: Simplified Hardware Block Diagram for 8086 Based Temperature Meter 87 za Brief Functional Description: The sensor NTC (Negative Temperature Co-efficient) produces a DC signal (VDT = Voltage as DC form for temperature T), which is proportional to ambient temperature, T. VDT is digitized by the serial ADC (U6) and then reaches to the CPU (U2) as V HT ( Voltage as Hex output of ADC for temperature T) via interface controller U11. The CPU computes the gain and offset of the sensor (broadly speaking the input subsystem) from its response curve (Fig-20.5) and applies them on VHT to recover the original decimal value of temperature (say, 25.300C). The CPU converts the BCD digits of the temperature into cc-codes (common cathode codes), which are then displayed onto multiplexed type CC7SDD devices. Temperature Sensor (NTC): It is a semiconductor type sensor with ‘Negative Temperature Coefficient (NTC)’ characteristics. As the ambient temperature increases, the resistance of the device decreases. A simple NTC-R2 network senses the environment temperature and produces a DC voltage VDT. VDT increases as the temperature increases. The sensor is linear and follows the response curve of Fig-P1.4 with definite gain and offset, which are computed from the measured values of the points A (T1, VDT1) = A(22.8 0C, 1.64V) and B(T2, VDT2) = B(25.0 0C, 1.80V). The magnitude of the unknown temperature C (T, VDT) is found by applying gain and offset on VDT. V Actual Response B ( 25 C ,1 . 80 V ) C ( T , V DT ) A ( 22 . 8 C ,1 . 64 V ) gain T T1 T T2 Offset 645cxd Figure-20.5: Response Curve of Temperature Sensor VDT is placed to the serial ADC (U6) via Channel-0 (Ch0). The 8-bit digital signal VHT goes to the microprocessor via interface controller. Here, the temperature T assumes (i) VDT in the decimal domain, and (ii) VHT in the hexadecimal (binary) domain. Both VDT and VHT refer to the same quantity, which is T 0C. The CPU calibrates VHT using the response curve of Fig-P20.5 and transforms VHT back to the decimal value. The BCD digits are converted into their equivalent cc-codes, which are displayed on the cc-type multiplexed display unit (DP0 – DP3) via 8255 IO controller. Response of the temperature sensor refers to (i) the measurement of DC voltages (VDT1, VDT2) of the sensor at two different known temperatures (T1, T2), and (ii) finding the equation of T in terms of the known points A(T1, VDT1) and B(T2, VDT2). T1 and T2 could be measured by a commercial thermometer. VDT1 and VDT2 could also be measured by a DVM. The response equation for T using Fig-P1.4 is: VDT 2  VDT1 VDT  VDT 2  T 2  T1 T  VDT 2  T  m *VDT  c T  T 2  T1 T 2  T1 * VTD  (T 2  V DT 2 * ) VDT 2  VDT1 V DT 2  VDT1 ……………………………………………(1) 88 In Eqn. 1, we have VDT. So, T is in the decimal domain. But after digitization, the CPU has measured the binary value of VDT, which is VHT. Now, we need to transform T from decimal domain into binary (hexadecimal) domain. To do it, we must figure out appropriate multiplication/division factor in the following way: If input analog signal to ADC is: 5V If input analog signal to ADC is: VDT Therefore, VDT = (VHT*5)/255 Output of ADC is 1111 1111B = 255 Output of ADC is = (255/5) * VDT = VHT Now, we can write the following equation for T in the binary domain. VHT * 5 c 255  T  m *VHT * 0.0196  c  T  m* ; m, (5/255) and c must be in their binary (Hex) equivalents From the given values of A (T1, VDT1) = A(22.80C,1.64V) and B(T2, VDT2) = B(250C, 1.80V), we may calculate gain (m) and offset (c) as – m 25.0  22.8 2.2   13.75 1.80  1.64 0.16  c  25.0  1.80 *13.75  25.00  24.75  0.25  T  m *VHT * 0.0196  c  T  13 .75 *VHT * 0.0196  0.25  T  0.2695 *VHT  0.2500  T *10 4  2695 *VHT  2500  T *10 4  0 A87 h *VHT  09 C 4h …………………..……………………………(2) Serial Analog-to-Digital Converter (U6, ADC0832): The ADC has two single-ended channels – Ch0 and Ch1. The temperature signal is acquired by Ch0. The full scale value of the ADC is +5V, which means that the ADC will produce an output signal of 1111 1111b (255) when the input analog signal is +5V. It is a serial ADC and hence the data bits come out bit-by-bit using the DOpin with MS-bit first. The command bits for channel selection enter into the chip bit-by-bit using its DI-pin. The clock pulses needed for clocking out the data bits and clocking in the command bits are artificially generated and are passed to the chip over the CK-pin. Chip select pin (CS/) allows putting more than ADC chips in a system and also brings the ADC into conversion mode. The PC0, PC1, PC2 and PC3 pins of the 8255(U11) controller handles the CS/, CK, DI and DO signals of the ADC. For proper operation of the DO-pin, it requires to be terminated to +5V by a 10k resistor. The Programming Table, Timing Diagram and the Data Read Flow Chart of ADC0832 are given in Table-P1.1, Fig-P1.17 and P1.18 respectively. IO Controller (U11, 8255): The serial ADC chip communicates with the CPU via Port-(C (PC4, PC2 – PC0) of the 8255 controller. The display unit is also interfaced to the microprocessor bus through the IO lines of 8255. 89 CC7SDD (Multiplexed Display Unit, DP0-DP3): In a non-multiplexed display system, every 7segment display device has separate 9-lines to drive its segments and cc-point. Thus, to drive a 4digit display unit, we would require 9x4 = 36 lines. In a multiplexed display system, the similar segment pins of all the display devices are connected together and is driven by just eight lines (instead of 32 lines for 4-digit display). The cc-pins are driven by separate lines. Thus, to drive a 4-digit display unit, we need only 8+4 = 12 lines. The display unit of Fig-P1.3 is an example of a multiplexed display system. In a multiplexed display system, the 8-bit cc-coded data (say, 4F for 3) for a character appears to the segment pins of all the display devices at the same time via Port-A (PAR) register. If we want see this character to be visible only at DP0-position, we need to apply 0V (LL) at cc0-pin and +5V (LH) to the cc-pins of the DP1 and DP3 display devices. Similarly, to see a character A at DP1position, we assert cc-code of A on PAR, LL at cc1-pin and LH at cc0, cc2 and cc3 pins. In a multiplexed display system, we need to continuously refresh the display unit with the respective character data for the display devices. Otherwise, the display unit will remain frozen to a single digit at one of the four display positions. Y1 6 MHz U1: 8284 U2: 8086 (MPU) 1/3Y1 CLK RST RDY K1 +5V 0V RST/ RDY +5V U11: 8255 B B MN-MX/ PAR (3600) CR DP3 Detailed Hardware Block Diagram DP0 Task-20.3 8 0 p,…,a cc0 cc2cc3 C cc0-cc3 (3606) CLK PB0-PB3 (3602) U3-U5 : 3xLS373 T Sensor tempM DI CLK CS/ ADC PC2 PC1 PC0 PIO CSU10/ CSU9/ y0y1 y2 y3 y7 4 CS11/ CSU7/ CSU8/ Even Bank Ch0 B Even Bank DO B ODD Bank TOUT 0V VDT BHE/ A16-A19 A0-A15 ODD Bank Ch1 R2 5k6 Q Q Q U7-U8 U9 - U10 B B (3604) PC4 Decoder +5V CS10/ A16-19 M-IO/ BHE/ A0 R1 10k CK D D D ALE BHE/-S7 A16/S3-A19/S6 AD0-AD15 U11: 8255 A3 A2 A1 A0 Heat +5V U12: 27C256 U6 : ADC0832 NTC CSU7-10/ ROM RAM 27C256 62256 Memory Figure-20.6: Detailed Hardware Block Diagram for 8086 Based Temperature Meter U2 (8086 Microprocessor): The microprocessor has been configured in minimum mode by strapping its MN-MX/ pin to +5V. The 8086 uses multiplexed bus for the composite signals AD0AD15, A16/S3-A19/S6 and BHE//S7. U3-U5 (74LS373 Latch): These latches hold the A0-A15, A16-A19 and BHE/ signals from their respective composite signals of AD0-AD15, A16/S3-A19/S6 and BHE/-S7 at the beginning of a machine cycle. 90 U6 (ADC0832 Serial Analog-to-Digital Converter): It acquires signal from temperature sensor, digitizes it and then sends it to the CPU via 8255. Channel selection command and the necessary clock signals are artificially generated by the IO lines of the 8255. U7-U8 (27C256 EPROM): U7 and U8 are respectively the ODD and EVN bank of ROM space. U9-U10 (62256 RAM): U9 and U10 are respectively the ODD and EVN bank of RAM space. U11 (8255 PIO Controller): It has interfaced the serial ADC and the display unit with the MPU. U12 (27C256 Memory/Port Decoder): It selects one memory/port chips out-of-many. U1 (8284 Clock Chip): It accepts (i) RST/-signal, (ii) crystal, and (iii) ready signal from outside and then produces (i) RST signal, (ii) clock and (iii) ready signal for the MPU. Parts List Sn Type No. Function Quantity 1 2 2 3 4 5 6 7 Circuit Designation U1 (Fig-P1.11) U2 U3-U5 U6 U7-U8 U9-U10 U11 DP0-DP3 8284 8086 74LS373 ADC0832 27C256 62256 8255 CC-type 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 U12 R1-R2 C14-C15 K1 T1 D1-D2 C15 C1-C13 Q1 Y1 R3 LED1 Electronic Cutter Nose Pliers Screw Driver NTC R4 - 27C256 4.7 k 100uF/16V Push 220/6-0-6 IN4004 1000uF/25V 0.1uF/63V 7805 6MHz 2.2K Red - Clock Chip Microprocessor Data Latch Serial ADC EPROM RAM PIO Controller 7-Segment Display Devices EPROM PCB Mountable Switch 600mA Transformer Rectifying Diode Capacitor Ac Decoupling Capacitor +5V Regulator Crystal Resistor Light Emitting Diode Shrinkable Tubing As per Sample As per sample As per Sample Good Quality Breadboards Right Size Jumper Wires Temperature Sensor Resistor Bakelite Board 2-Pin AC Plug for 220V Ac Wire 5.6K` 10” x 6” - 91 Shop 1 1 3 1 2 2 1 4 Approx Unit Price Tk 200/Tk 220/Tk 40/Tk 110/Tk 150/Tk 150/Tk 250/Tk 15/- 1 2 2 1 1 2 1 13 1 1 1 1 1 ft 1 1 1 2 250 gm 1 1 1 1 2 yrds Tk 150/Tk 1/Tk 1/Tk 5/Tk 80/Tk 3/Tk 10/Tk 0.25/Tk 15/Tk 15/Tk 1/Tk 2/Tk 20/Tk 330/Tk 150/Tk 20/Tk 250/Tk 300/Tk 50/Tk 1/Tk 80/Tk 20/Tk 10/- Do Do Do Do Do Do Do Do Do Do Do Do Do Do Do Do Do Do/Dolai Khal Stadium/Patuatully Do Kawran Bazar Electric Shop do Stadium/Patuatully Do Do Do Do Do Do Do Task-20.4 20.4.1 (1) (2) (3) (4) (5) Hardware Building Procedures A: +5V Supply Subsystem Check that you have the following parts placed on the breadboard as per layout of Fig-20.1, 20.3 1. Transformer : T1 220/9-0-9 2. Diode (2) : D1, D2 (IN4003) 3. Capacitor : C16 1000uF/25V 4. +5V Regulator : Q1 (7805) 5. Capacitor : C14 100uF/16V 6. Capacitor : C13 (0.1uF = 104) 7. LED1 : Red One 8. Resistor : R3 2.2k 9. Jumper Wires : as needed Connect the components together using jumper wires as per diagram of Fig-20.7. Apply 220V AC supply Check that LED1 glows. Measure +5V with a DVM. Disconnect 220V supply. 734x 7805 D1 9 0V 220V 1 2 D2 3 +5 C14 100uF /16V + 9 Q1 R3 2.2k C13 0.1uF C16 1000uF/25V LED1 0V Figure-20.7: Schematic of +5V Supply 20.4.2 (1) (2) (3) Temp Signal Acquisition Subsystem (Fig-20.8) Check that you have the following parts placed on the breadboard as per layout of Fig-20.1-20.3. 1. Temp Sensor : NTC 2. ADC : U6 ADC0832 3. Resistor : R2 5.6k 4. Resistor : R1 10k 5. Interface Controller : U11 8255 8. Jumper Wires : as needed Place the components on the breadboard as per circuit diagram of Fig-20.8. Complete only those lines of the following diagram, which have source and destination signals. For example – Pin-6 of U6 has the source signal (DO) and destination signal (PC4). So, these two points (U6-6 and U11-13) must be connected together. Similarly connect other signal lines. NTC +5V R2 5k6 0V NTC TOUT +5V R1 = 10k U6: ADC0832 NC VDT +5V 0V 3 2 6 Ch1 Ch0 8 Vcc 4 GND PC4 17 PC2 16 PC1 15 PC0 Pin Signals Pin Numbers Line Signals (4) (5) (6) (7) (8) U11: 8255 13 DO 5 DI 7 CK 1 CS/ CS/ B NC = No connection za1 Figure-20.8: Schematic of ADC Subsystem Apply 220V AC supply. Measure VTD signal with a DVM and record it in your Project Khata. Use a gas lighter and gently heat up the NTC sensor. Measure VTD and record it. Check that the value has increased compared to the previous value. Disconnect the 220V supply. 92 20.4.3 (1) Multiplexed Display Subsystem (CC7SDD) Check that you have the following parts placed on the breadboard as per circuit of Fig-20.9. 1. CC-type 7SDD (4) : DP0-DP3 CC-type 2. Jumper Wires : as needed Complete only those lines of the following diagram, which have source and destination signals. (2) Figure-20.9: Schematic Diagram for cc-type Multiplexed CC7SDD 20.4.4 (1) EPROM Subsystem Check that you have the following parts placed on the breadboard as per circuit of Fig-20.10. 1. EPROM (2) : U7-U8 27C256 2. Jumper Wires : as needed Complete only those lines of the following diagram, which have source and destination signals. (2) U7 Vcc RD/ CSODDROM A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 1 22 20 27 26 2 23 21 24 25 3 4 5 6 7 8 9 10 27C256 U8 VPP OE CE A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 VCC GND O7 O6 O5 O4 O3 O2 O1 O0 28 14 19 18 17 16 15 13 12 11 Vcc GND AD15 AD14 AD13 AD12 AD11 AD10 AD9 AD8 Vcc RD/ CSEVNROM 1 22 20 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 27 26 2 23 21 24 25 3 4 5 6 7 8 9 10 27C256 VPP OE CE A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 P1.9 Figure-20.10: Schematic Diagram of EPROM Subsystem 93 VCC GND O7 O6 O5 O4 O3 O2 O1 O0 28 14 Vcc GND 19 18 17 16 15 13 12 11 AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 20.4.5 (1) RAM Subsystem Check that you have the following parts placed on the breadboard as per circuit of Fig-20.11. 1. RAM (2) : U9-U10 62256 2. Jumper Wires : as needed Complete only those lines of the following diagram, which have source and destination signals. Connect A1-A14, AD0-AD15 line signals with corresponding line signals of U7-U8 of Fig-20.10. (2) (3) WR/ RD/ CSODDRAM 27 22 20 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 WR/ RD/ CSEVNRAM WE OE CE 1 26 2 23 21 24 25 3 4 5 6 7 8 9 10 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 VCC GND O7 O6 O5 O4 O3 O2 O1 O0 U9 19 18 17 16 15 13 12 11 A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 Vcc GND 28 14 27 22 20 AD15 AD14 AD13 AD12 AD11 AD10 AD9 AD8 1 26 2 23 21 24 25 3 4 5 6 7 8 9 10 62256 WE OE CE A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 VCC GND O7 O6 O5 O4 O3 O2 O1 O0 U10 28 14 Vcc GND 19 18 17 16 15 13 12 11 AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 62256 P1.10 Figure-20.11: Schematic Diagram of RAM Subsystem Y1 6 MHz +5V R4 4k7 K1 16 VCC 11 X2 (2) Clock Subsystem Check that you have the following parts placed on the breadboard as per circuit of Fig-20.12. 1. Clock Chip : U1 (8284) 2. Crystal : Y1 (6 MHz or close) 3. Resistor : R4 (4.7k) 4. Capacitor : C15 (100uF/16V) 5. Switch : K1 (ON/OFF (not Latch) 6. Jumper Wires : as needed Complete only those lines of the following diagram, which have source and destination signals. 17 (1) X1 20.4.6 CLK READY RESET RES 100uF + PCLK C15 +5V 6 3 7 14 1 15 13 4 RDY 2 AEN1 AEN2 EFI CSY NC ASY NC F/C RDY 1 U1 PCLK RESET OSC OSC GND VCC 8 5 10 CLK 1/3Y1 READY 2 12 9 18 GND +5V 8284 1/6Y1 RESET Y1=6 MHz P1.11 Figure-20.12: Schematic Diagram of Clock Subsystem 94 +5V CLK READY RESET 33 19 22 21 MIN-MX CLK READY RESET 1 MIN86 GND 20 U2 GND (2) (3) (4) (5) (6) (7) CPU Subsystem Check that you have the following parts placed on the breadboard as per layout of Fig-20.13. 1. Microprocessor : U2 (8086) 2. Data Latch (3) : U3-U5 (3x74LS373) 3. Jumper Wires : as needed Complete only those lines of the following diagram, which have source and destination signals. Connect line signals REDAY, CLK and RESET with corresponding line signals of U1 (8284). Connect line signals AD0-AD7 with corresponding line signals of U8 (27C256). Connect line signals AD8-AD15 with corresponding line signals of U7 (27C256). Connect line signals A1-A15 with the corresponding line signals of U7 (27C256). Connect line signals RD/ and WR/ with the corresponding line signals of U9 (62256). 40 (1) VCC 20.4.7 INTA M-IO RD WR DT-R DEN ALE 24 28 32 29 27 26 25 M-IO/ RD/ WR/ U5 GND BHE/S7 A19/S6 A18/S5 A17/S4 A16/S3 1 18 17 14 13 8 7 4 3 34 35 36 37 38 OE LE D7 D6 D5 D4 D3 D2 D1 D0 Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 U4 1 23 31 30 TEST AD15 AD14 AD13 AD12 AD11 AD10 AD9 AD8 39 2 3 4 5 6 7 8 AD15 AD14 AD13 AD12 AD11 AD10 AD9 AD8 18 17 14 13 8 7 4 3 HOLD HLDA 17 18 NMI INTR AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 9 10 11 12 13 14 15 16 AD7 AD6 AD5 AD4 AD3 AD2 AD1 AD0 18 17 14 13 8 7 4 3 LE D7 D6 D5 D4 D3 D2 D1 D0 Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 19 16 15 12 9 6 5 2 BHE/ A19 A18 A17 A16 11 19 16 15 12 9 6 5 2 A15 A14 A13 A12 A11 A10 A9A3 A8 74LS373 OE LE D7 D6 D5 D4 D3 D2 D1 D0 Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 Figure-20.13: Schematic Diagram of CPU Subsystem 95 11 74LS373 OE U3 1 74LS373 11 19 16 15 12 9 6 5 2 A7 A6 A5 A4 A3 A2 A1 A0 20.4.8 (1) Memory/Port Decoding Subsystem Check that you have the following parts placed on the breadboard as per layout of Fig-20.14. 1. EPROM : U12 (27C256) 2. Jumper Wires : as needed Complete only those lines of the following diagram, which have source and destination signals. Connect line signals A0, A12-A16, BHE/ with corresponding line signals of U3-U5 (74LS373). Connect line signals M-IO/ with corresponding line signal of U2 (8086). Connect line signals CSEVNRAM, CSODDRAM, CSEVNROM, CSODDROM with corresponding line signals of U7-U8(27C256) and U9-U10(62256). Connect line signals CSPIO with the corresponding line signal of U11 (8255). (2) (3) (4) (5) (6) U12 ` VCC Vcc GND 1 20 22 27 26 2 23 21 24 25 3 4 5 6 7 8 9 10 A19 A18 A17 A16 A15 A14 A13 A12 M-IO/ BHE/ A0 27C256 Vpp CE OE A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 GND VCC O7 O6 O5 O4 O3 O2 O1 O0 GND Vcc 14 28 3000 - 3FFE 19 18 17 16 15 13 12 11 F0001 F0000 00000 00000 - FFFFF FFFFE 0FFFF 0FFFE : : : : ODD EVN ODD EVN ROM ROM RAM RAM CSPIO NC NC NC CSODDROM CSEVNROM CSODDRAM CSEVNRAM Figure-20.14: Schematic Diagram of Memory/Port Decoder 20.4.9 (1) (2) (3) (4) PIO Interface Subsystem Check that you have the following part placed on the breadboard as per layout of Fig-20.15 1. PIO Interface Controller : U11 8255 Complete only those lines of the following diagram, which have source and destination signals. Connect line signals AD0-AD7, RESET, RD/ and WR/ with corresponding line signals of U2 (8086). Connect line signals A1, A2 with corresponding line signal of U3 (74LS373). U11 AD0 AD1 AD2 AD3 AD4 AD5 AD6 AD7 34 33 32 31 30 29 28 27 A1 A2 9 8 RESET RD/ WR/ CS8255 35 5 36 6 Vcc GND 26 7 Port Address PAR:3600h PBR: 3602h 8255 D0 D1 D2 D3 D4 D5 D6 D7 PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0 A0 A1 PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0 RESET RD WR CS VCC GND PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0 25 24 23 22 21 20 19 18 37 38 39 40 1 2 3 4 10 11 12 13 17 16 15 14 NC NC NC NC NC PB2 PB1 PB0 PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA0 PC7 PC6 PC5 PC4 NC NC NC NC PCR: 3604h CR: 3606h Figure-20.15: Schematic Diagram of PIO Subsystem 96 T ask-20.5 Control Program Development Procedures Data Structure for the F0000 BAS DSM (RAM) BAE ESM (RAM) BAD BAC MBA Empty Space Stack Grows 07000 06FFF TS Samples S0-S7 05010 05009 05000 04FFF 04003 04002 04001 04000 03FFF 03012 03011 03010 03002 03001 03000 02FFF 01000 00FFF 00000 Digit Vs CC-codes L1: Initialize Stack L2: ACQCH0 T5 Initialize Others as needed Acquire Temp Signal save in ah L3: T4 BINTEMP Compute Temp As 16-bit Binary L4: CCTEMP DP3 DP2 T3 DP1 DP0 BCDTEMP CCTEMP BCDTEMP BINTEMP For testing Program MB NB LB Compute Temp As 4-digit BCD L5: L6: T2 CCX7SDD MS NB T1 LB CSM (RAM) Compute Temp as 4-byte CC-code Show Temp on CC7SDD L6A: 32 times refresh? N Y IVT[02h] L7: xx xx Figure-20.16 : Data Structure for Control Program 20.5.3 nop L1A: LUT TOS 09000 Filled up 08FFF 08FFE 08FFD 08FFC Flow Chart START: SSM (RAM) FFFF0 jmp F0000h 20.5.2 CSM (EPROM) Control Program FFFFF Startup FFFF:0000 20.5.1 Figure-20.17: Flow Chart for Control Program Develop Assembly Codes in the Form of Subroutines for the Control Program for the Temperature Meter using MicroTalk-8086 of Fig-20.2 ;============================================================================= ; Program name : …\MTK8086\temp86.asm ORG 1000H ASSUME cs:MYCODE START: L1: L1A: nop ;-- stcak init-------------mov ax, 0000h mov ss. ax mov sp, 9000h ;-- init DSM and offset pointer— mov ds, ax mov bx, 3000h ;---------------------------call INIT ; initialize others as needed L2: call ACQCH0 ; read Temp and keep it in ah-register = VTH 97 L3: ;-- compute Temp in Binary and save in locations 03000, 03001, 03002 ; by evaluating expression : T*104 = 0A87h* VTH + 09C4h call BINTEMP ; 24-bit result in DSM L4: ;-- convert BINTEMP into BCDTEMP and save in 03010, 03011, 03012 call BIN2BCD ; active result in <03010, 03011> = = L5: ;-- convert BCDTEMP into CCTEMP and save in 04000 – 04003 call BCD2CC ; (04000) = cc_p, (04001) = cc_q, (04002) = cc_r, (04003) = cc_s L6: L6A: ;-- send CCTEMP onto CC7DD via 8255---------------------------mov cl, 20h ; refresh display for 32 times call CCX7SDD dec cl jnz L6A L7: ;-- again acquire temperature----jmp L2 ;--------------------------------------------------------------------------------------------;Assembly Codes for Subroutines INIT: ;-- init Lookup Table for Digit Vs CC-cods in ESM--mov ax, 0000h mov es, ax mov di, 5000h mov mov mov mov mov WORD PTR es:[di], 063FH WORD PTR es:[di+02h], 4F5Bh WORD PTR es:[di+04h], 6D66h WORD PTR es:[di], 077DH WORD PTR es:[di+02h], 6F7Fh ; cc-codes for 0, 1 ; cc-codes for 2, 3 ; cc-codes for 4, 5 ; cc-codes for 6, 7 ; cc-codes for 8, 9 ;-- init 8255----------mov al, 84h ; PAR, PBR, PC0-PC3 output, PC4-PC7 input mov dx, 3606h ; address of Control Register out dx, al ;-------------------------ret ;------------------------------------------------------------------------------------------------------ACQCH0: ; acquire Temp Sensor signal (VTD) as binary (VTH) and save in ah-register ; copy codes from Section-1.46 ret ;-------------------------------------------------------------------------------------------------------BINTEMP: ;--- Evaluate T*104 = 0A87h* VTH + 09C4h = 0A87h* ah + 09C4h ; input via ah-register ; output BINTEMP via locations (03002) = MB-Byte, (03001) = NS-Byte, (03000) = LS-Byte ;-- compute 0A87h * VTH ; VTH in ah-register mov al, ah mov ah, 00h mov bx, 0A87h mul bx ; result in = dh, dl, ah, al = 00, dl, ah, al = 24-bit active ;----compute + 0009C4h add al, 0C4h adc ah, 09h adc dl, 0Ch adc dh, 00h ; 32-bit BINTEMP in = 00 dl, ah, al = 24-bit active ;-------------------mov WORD PTR ds:[bx], ax 98 mov BYTE PTR ds:[bx+02h], dl ;BINTEMP via (03000)=LB, (03001)=NB, (03002)=MB ;-------------------ret ;---------------------------------------------------------------------------------------------BIN2BCD: ; converting 24-bit BINTEMP into 6-digit BCDTEMP ; input via 03000)=LB, (03001)=NB, (03002)=MB ; output via (03010)=LB, (03011)=NB, (03012)=MB mov cl, 18h ; size of input 24-bit data mov dl, 00h mov bx, 0000h ; IPBCD = Initial Partial BCD = AGNC: ;-- catch carry, evaluate IPBCDx02 + c and update IPBCD ror BYTE PTR ds:[bx], 01h ror BYTE PTR ds:[bx+01h], 01h ror BYTE PTR ds:[bx+02h], 01h ;-----call EVBCDHR ; Evalute BCD by Horner Rule ;-----dec cl jnz AGNC ; again catctch next carry ;-----mov BYTE PTR ds:[bx+12h], dl mov WORD PTR ds:[bx+10h], bx ; BCDTEMP via (03010)=LB, (03011)=NB, (03012)=MB ;----ret ;--------------------------------------------------EVBCDHR: ; Evaluate BCD using Horner Rule ; Evaluating IPBCD * 02 + Cx = 23 to 0 mov al, bl add al, al daa mov bl, al ;-----mov al, bh adc al, al daa mov bh, al ;-----mov al, dl adc al, al daa mov dl, al ;------ret ;---------------------------------------------------------------------------------------------BCD2CC: ; convert 2-byte BCDTEMP into 4-byte cc-code ; copy codes from Section-1.34. ; input via (03011) = MB, (03010) = LB ; output via (04003) = CC_DP3, (04002) = CC_DP2, (04001) = CC_DP1, (04000)-CC_DP0 ;---------------------------------------------------------------------------------------------CCX7SDD: ; transfer 4-byte cc-odes to CC7SDD unit ; copy codes from Section-1.34 ; input via (04003) = CC_DP3, (04002) = CC_DP2, (04001) = CC_DP1, (04000)-CC_DP0 ; output goes to Display Unit ; --------------------------------------------------------------------------------------- 99 ACQCH0: Temperature Signal Acquisition Subroutine (ACQCH0) This SUR selects Ch0 by sending command bits of Table-20.1 into the ADC. Fig–P20.18 describes the pulse/timing system that must be followed to send the command bits of Table-20.1 into the ADC and then to read the digitized data from the ADC bit-by-bit with MS-bit first. Fig-20.19 describes an algorithm, which we may follow to (i) read the digitized data from the ADC with MS-bit first, (ii) convert them into parallel format, and then (iii) putting the data into ah-register. Table-20.1 : Single Ended MUX Mode of ADC0832 Bits over DI-pin (MUX Address) Analog Channel Selection B2 B1 B0 Ch0 Ch1 (START BIT = SB) (SGL/DIF) (ODD/SIGN) 1 1 0 Select (+) 1 1 1 Select (+) CLK(PC1) t1 t2 t3 t5 t6 t4 1 CLK t7 2 CLK t8 3 CLK t9 t10 CK7 CK6 CK5 CK4 CK3 CK2 CK1 CK0 CS/(PC0) DI(PC2) DO(PC4) SB SGL ODD Disable Disable Data Ready : 0 or 1 MUX Settle and Conversion Time > 32uS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Htms2ch.vsd Figure-20.18: Timing Diagram of ADC0832 ADC START: NOP L1: Initialize: Load 00 into ah Load 08h into cl L2: Generate next CLK Pulse at PC1-pin Read Data From PC4 L3: Y PC4=LH ? L4: Data bit=0 L8: Data bit=1 N Load LL into C-bit Load LH into C-bit L5: b7 Rotate left through CF By 1-bit of (ah) CF b0 (ah) L6: N Data Read Done ? L7: Y Halt Serial-data-readx : 11-03-2011 Figure20.19: Data Read Flow Chart of ADC0832 ADC 100 Assembly Codes: ACQCH0: ; Inputs : none. ; Output : 8-bit data in ah-register. ;--- acquiring Ch-0 -------------------------------------------------------mov cl, 08h ; number of clock pulses to acquire 8-bit data from ADC ;-- LL  CK, LH  CS/--mov al, 01h ; 0000 0001 = xxxx DO DI CK CS/ mov dx, PCR ; pointing Port-C out dx, al ;-- start conversion by making CS/-pin Low---------------------------mov al, 00h ; 0000 0000 = xxxx DO DI CK CS/ mov dx, PCR ; pointing Port-C out dx, al ;-- LH  Start Bit (SB) : always High---------------------------------mov al, 04h ; 0000 0100 = xxxx DO DI CK CS/ mov dx, PCR ; pointing Port-C out dx, al ;-- assert CK to clock in SB------mov al, 06h ; 0000 0110 = xxxx DO DI CK CS/ mov dx, PCR ; pointing Port-C out dx, al mov mov out al, 04h dx, PCR dx, al ; 0000 0100 = xxxx DO DI CK CS/ ; pointing Port-C ;-- SGL Bit (logic High)--------------------------------------------------mov al, 04h ; 0000 0100 = xxxx DO DI CK CS/ mov dx, PCR ; pointing Port-C out dx, al ;-- assert CK to clock in SB------mov al, 06h ; 0000 0110 = xxxx DO DI CK CS/ mov dx, PCR ; pointing Port-C out dx, al mov mov out al, 04h dx, PCR dx, al ; 0000 0100 = xxxx DO DI CK CS/ ; pointing Port-C ;-- LL  ODD/Sign Bit (LL)-------------------------------------------mov al, 00h ; 0000 0000 = xxxx DO DI CK CS/ mov dx, PCR ; pointing Port-C out dx, al ;-- assert CK to clock in SB------mov al, 02h ; 0000 0010 = xxxx DO DI CK CS/ mov dx, PCR ; pointing Port-C out dx, al mov al, 00h ; 0000 0000 = xxxx DO DI CK CS/ mov dx, PCR ; pointing Port-C out dx, al ;------------------------------------------------------------------------------call READADC ; read serial data and convert to parallel ;----- deselect ADC by making CS/-pin High-----------------------------mov al, 01h ; 0000 0100 = xxxx DO DI CK CS/ mov dx, PCR ; pointing Port-C out dx, al ;----------------------------------------------------------------------------------- 101 ret ; acquisition done, data (VTH) in ah-register. ;================================================= READADC: mov ah, 00h ; parallel data collector FRQ101: ;--assert clock to read data MS-bit first------mov al, 02h mov dx, 3604h out dx, al mov mov out LX2: FRQ11: al, 00h dx, 3604h dx, al ;----read bit from PC4-----mov dx, 3604h in al, dx and al, 10h sub al, 10h jz LX2 jmp FRQ11 stc rcl ah, 01h jmp FRQ11A clc rcl ah, 01h FRQ11A: dec cl ; cl holds number of clock pulses = 08 jnz FRQ101 ret ;----------------------------------------------------------------------------------------------` BCD Digit to CC-code Conversion Subroutine (BCD2CC) Assume that we have measured the room temperature as 25.300C. The quantity has been kept as 2530 into the memory locations 03000h and 03001h of the DSM of Fig-P1.15. The decimal point is in the mind of the programmer and will be added with digit-5 at the time of showing the temperature on 7SDD unit of Fig-P1.8. To show the digits of the temperature at DP0-DP3 position of the 7SDD unit of Fig-7.8, we need to know the cc-codes of these digits. The cc-codes have been kept in a ‘Lookup Table (LUT)’ of Fig-P1.8. Now, we need a software subroutine (called BCD2CC, Fig-P1.19), which will (i) read a digit from the BCD Table, (ii) consult the LUT to obtain the cc-code for the digit, and (iii) store the cc-code into the CC Table. BCD Table in DSM Location 04FFF BCD Byte CC Table in DSM SUR Display Positions BCD2CC Lookup Table (LUT) in ESM Digit Vs CC-code 05001=0000:5000+01 = Seg (es):off(di) + digit (bp) 04000 03FFF 03011 03010 30 25 DP2 DP3 DP0 DP1 03001 03000 Loc. 05009 05008 05007 05006 05005 05004 05003 05002 05001 05000 Digit 9 8 7 6 5 4 3 2 1 0 CC-code 6F 7F 07 7D 6D 66 4B 5B 06 3F Location 04FFF 04003 04002 04001 04000 03FFF cc-code cc-code cc-code cc-code cc-code of of of of Display Positions 0 3 5 2 DP3 DP2 DP1 DP0 03001 03000 bcd2cc Figure-20.20: Data Structure for BCD2CC Conversion Subroutine Assembly Instructions: 102 ;============================================================================= ; Inputs: BCD byte(s) via locations (03011) MB, (03010) = LB of BCD_Table ;Outputs: The cc-codes via (04003) = CC_DP3, …, (04000) n= CC_DP0 BCD2CC: S1L2A: S1L2B: ;-- extract 2 as 02 from 25 of BCD Table--mov ch, 02h mov bx, 3000h mov al, BYTE PTR ds:[bx] mov cl, 04h shr al, cl ; two byte BCD data to be converted to CC-codes ; al =25 ; al is to be shifted 4-bits to the right ; al = 02 ;--- form address 05002 of LUT to obtain the cc-code of 02----mov dx, 0000h mov es, dx mov di, 5000h mov ah, 00h ; transfer 02 into bp-register as 0002 mov bp, ax ; bp = 0002 mov al, BYTE PTR es:[di+bp] ; ch = 5B = cc-code of 2 ;--- save the cc-code of 2 into CC Table---mov BYTE PTR ds:[bx+1000h], al ;-- get CC-code for the next digit (5) ------mov al, BYTE PTR ds:[bx] and al, 0h mov ah, 00h mov bp, ax mov al, BYTE PTR es:[si+bp] ; cc-code of 2 is saved in 04000h location ; al = 25 ; al = 05 ; ch = 6D = cc-code of 5 ;-- save cc-code of 5 into CC Table----mov BYTE PTR ds:[bx+1001h], al ;== get cc-codes for the remaining digits== dec ch jz S1L2C inc bx inc di jmp S1L2B ; CPU will repeat the conversion process ; check if more conversion is needed ; conversion done ; point next BCD byte in BCD Table ; point next location in CC Table S1L2C: ret ; conversion complete, return to calling program ;============================================================================= Subroutine to Transfer CC-codes to 7SDD (CCX7SD) Let us first note that the display unit is a ‘multiplexed display’. In a multiplexed display system (Fig-P1.8), the cc-type devices (here DP0-DP3) are all connected in parallel and their segments (p,…,a) are driven by Port-A of the 8255 IO controller. Therefore, to prevent the display from being frozen into a single digit, we need to refresh the display unit at regular intervals by sending the respective data to the display devices. The CCX7SDD subroutine works in the following ways: 1. 2. 3. 4. It reads the content of location 04000h of CC-Table and sends it to DP0-position via 8255, It inserts some time delay so that the digit remains visible on the display device, The SUR repeats the above two steps for the display positions DP1 to DP3, The above three steps are repeated. 103 bcd2cc CC Table in DSM cc-code M3: 8255 DP0 DP1 DP2 DP3 Display Positions PA7-PA0 3600h 04003 cc-code of 0 DP3 04002 04001 cc-code of 3 cc-code of 5 DP2 DP1 04000 03FFF cc-code of 2 DP0 SUR CCX7SDD 3602h Location 04FFF 8 p,…,a cc0 cc1 cc2 PB0 PB1 PB2 PB3 CR 3606h 03001 03000 IO Controller CC Table CC7SDD Figure-20.21: Explaining the Working Mechanism of Multiplexed Display Unit Assembly Codes: ;==================================================================== CCX7SDD: ; Inputs: The cc-codes are stored in the indicated memory locations of CC-Table ; Outputs: The BCD data appears on the display S2L1: mov ax, 0000h mov ds, ax mov bx, 3000h ; offset pointer ;--------------------------S2L2: mov dx, CR ; 8255 initialization mov al, Cbyte ; to set direction of IO lines of variable port out dx, al ;---------------------------S2L3: mov al, BYTE PTR ds:[bx+1000h] ; read 1st cc-byte from CC Table mov dx, PAR out dx, al ; 1st cc-byte is written into PAR for DP0 ;-------------mov dx, PBR mov al, 11111110b ; activate only PB0 out dx, al call TDEL ; insert time delay ;----------------------------S2L3: mov al, BYTE PTR ds:[bx+1001h] ; read 2nd cc-byte from CC Table mov dx, PAR out dx, al ; 2nd cc-byte is written into PAR for DP1 ;-------------mov dx, PBR mov al, 11111101b ; activate only PB1 out dx, al call TDEL ; insert time delay ;----------------------------S2L4: mov al, BYTE PTR ds:[bx+1002h] ; read 3rd cc-byte from CC Table 104 cc3 mov dx, PAR out dx, al ; 3rd cc-byte is written into PAR for DP2 ;---------------------------------------------------------------------------------mov dx, PBR mov al, 11111011b ; activate only PB2 out dx, al call TDEL ; insert time delay ;----------------------------S2L5: mov al, BYTE PTR ds:[bx+1000h] ; read 4th cc-byte from CC Table mov dx, PAR out dx, al ; 4th cc-byte is written into PAR for DP3 ;-------------mov dx, PBR mov al, 11110111b ; activate only PB3 out dx, al call TDEL ; insert time delay ;----------------------------S2L6: ret ; return to mainline program and call CCX7SDD again ;----------------------------TDEL: mov cx, 00FFH ; Time Delay subroutine HERE: loop HERE ret ;============================================================================ 20.5.4 Entering Binary Codes of Control Program (temp86.asm) into EPROMs (U7, U8) Procedures: (1) Open the source file …\MTK8086\temp86.asm and change the ORG to 0000h. Use MASM assembler and create temp86.abs (Intel-Hex Format) file from the source file temp86.asm. (2) Use driver program of any commercial Universal ROM Programmer (For example TopWinEn program of TOP2005 ROM Programmer) and open the file temp86.abs file. The file will be converted from Hex format into BINary format and will be displayed in the screen. Save it as temp86.bin. (3) Now use split2.exe program and divide the temp86.bin file into Even (EVN) and ODD (Odd) banks. The resultant files will have the names: temp86.evn and temp86.odd. (4) Again use the TopWinEn program and open the temp86.evn file. Using PageUp and PgaeDn command bring the cursor at the address line : 7FF0. (5) At location 7FF0 enter the code EA, at location 7FF1 enter the code 00, at location 7FF2 enter the code F0. Save the file and program (fuse) it into a 27C256 type EPROM. Label the EPROM as ROMEVN and place it on the breadboard at position of U7. (6) Open the file temp86.odd. Using PageUp and PgaeDn command bring the cursor at the address line : 7FF0. (7) At location 7FF0 enter the code 00, at location 7FF1 enter the code 00. Save the file and program (fuse) it into a 27C256 type EPROM. Label the EPROM as ROMODD and place it on the breadboard at position of U6. 20.5.5 Entering Binary Codes into Memory/Port Decoder (U12) (1) Contact at [email protected] to collect the binary file for the data of the U12. Fuse the codes into the 27C256 EPROM using a commercial ROM program. (2) Place the above programmed EPROM at the appropriate place of the breadboard of the layout of Fig-20.1, 20.3 20.5.6 Operation of the Stand-alone Temperature Meter of Breadboard 105 (1) (2) (3) (3) Apply power to the temperature meter. Press the reset switch K1 (Fig-P1.11). Check that the DP0-DP3 shows the room temperature. Check that for 100% sure the Temperature Meter made on the breadboard is not working. Task-20.6 (1) (2) (3) (4) (5) (6) Task-20.7 (1) (2) (3) (4) (5) (6) (7) (8) 2 3 4 Making a Stand-alone Temperature Meter on PCB Use OrCad package (Capture CIS) and capture the complete schematic diagram of the temperature meter. Use OrCad package (Layout Plus) and make double layer PCB Layout. Contact PCB maker in China or [email protected] and obtain few pieces of double layer PCBs. [email protected] is the email address of Golam Mostafa – author of this Lab Book. Solder the components and the ICs on the PCB. Apply power to the PCB. Press the reset switch. Check that the DP0-DP3 shows ambient temperature. Gently heat up the NTC sensor and check that the temperature of the display unit changes. Task-20.8 1 Operation of Temperature Meter using MicroTalk-8086 Trainer Place the Temperature Sensor (NTC), ADC (ADC0832) and the Display Devices (DP0DP3) on the breadboard of the MicroTalk-8086 Trainer (Fig-P1.2). Make connections among the NTC, ADC, DP0-DP2, and 8255 of the MicroTalk-8086 as per diagrams of Fig-P1.7, P1.8 and P1.14. Assemble the temp86.asm program of Section-1.4.3 and create temp86.abs file. Download the temp86.abs file into the RAM space of MicroTalk-8086 and execute it. Check that the DP0-DP3 shows the room temperature (approximately). Gently, heat up the NTC sensor and check that the display changes. Questions and Answers (Solve as many as you can) Write down the names of components ICs that are needed to build 8086 based Temperature Meter. Temperature Sensor : NTC Analog-to-Digital Converter : ADC0832 PIO Controller : 8255 Microprocessor : 8086 CC-type 7-segment Display : DP0-DP3 Clock Chip : 8284 EPROM : 3x27C256 RAM : 2x62256 Latch : 3x74LS373 Write down the names of the resources that are needed to build 8086 based Temperature Meter. MicroTalk-8086 MASM Assembler TOP2005 OrCad Software Download data sheets of ADC0832 and study its architecture and programming. Reduce the numbers of assembly codes for the READADC (Page-102) subroutine. 106