PH 320 Laboratory Manual Contents Instructions to students
03
Expt. #1:
Universality of NOR gate & De Morgan’s laws
04
Expt. #2:
Half Adder, Half Subtractor, Full Adder, Multiplexer and Demultiplexer
06
Expt. #3:
NAND latch, J-K Flip-flop, shift register and ripple counter
09
Expt. #4.
Comparator, encoder and decoder circuits
13
Expt. #5.
4-bit adder/subtractor and Static RAM
17
Expt. #6.
Programming exercises using 8085A P trainer kit
20
Expt. #7.
Simple interfacing exercises using 8085A P trainer kit
22
Expt. #8.
Interfacing of 8-bit A/D and D/A cards with 8085A P kit
28
Expt. #9.
Interfacing and control of a stepper motor with 8085A P kit
32
Appendix
35
Department of Physics Indian Institute of Technology Guwahati July - November 2010 Instructors:
A. Srinivasan (Course Coordinator) Sidananda Sarma
Technical Staff: Basab Bijoy Purkayastha Jyoti Prasad Bora
Instructions to students This manual contains instructions for performing nine sets of experiments in digital electronics. The class is split into two groups and each group has been allotted a three-hour slot every week to perform each of these nine experiments. All experiments have to be performed independently by each student. Each experiment has two sections. In the first part, circuits and procedures are provided for the students to achieve the aims specified. This compulsory part is to be performed as instructed. At the end of this section, some exercises are given, which are within the scope of the knowledge of the students of this course. The students have to make their own circuits (for which any standard text book can be referred) and test these exercises. The students are expected to come prepared to the lab with the relevant background reading. Devote a file folder for the lab reports. Your preparation for the experiment (prior to entering the lab) includes a write-up containing the title, objective(s), diagram(s), truth table, Boolean expressions related to the entire experiment including the exercises. Once inside the lab, you are expected to wire up the circuits, generate the relevant truth table and get them endorsed by the instructor. You should then proceed to experiment with the exercises provided (for which you should have come prepared with circuit diagrams) and demonstrate those experiments to the instructor. The lab report of each experiment (including the exercises) is to be completed and submitted by the end of each session. During the 8th week of this course, each student has to propose a mini project based on the knowledge and experience acquired during the earlier laboratory classes. The proposal consisting of the basic idea behind the circuit, its use along with the relevant circuit diagram and component list has to be submitted latest by the 8th week of the semester. Components/instruments available with the department would be provided for this work if specified in the proposal. Ensure the availability of the components before submitting the proposal. The students should complete and demonstrate their mini-project during the last lab session. This would be followed by an end-semester exam. Assessment of PH 320 is based on your (i) preparation for the lab class, your performance in the laboratory class including the exercises, (ii) mini project work, and (iii) performance in the end-semester practical examination. Contact any of the instructors if you have any doubts about this course. Hope you enjoy the course. Course Coordinator – PH 320 (July-November 2010). --------
2
AIM :
a) b)
To verify the universality of NOR gate. Verify De’ Morgan’s Laws.
APPARATUS /COMPONENTS REQUIRED: Power Supply (1 No.), Multimeter (1 No.), NOT (IC 7404), OR (IC 7432), NOR (IC 7402) AND (IC 7408) and NAND (IC 7400) one each. a) CIRCUIT DIAGRAM: 7402
7402
A
Y
7402
7402
Y
A
7402
Y
7402 7402
7402
A
7402
7402
Y
7402
b) CIRCUIT DIAGRAM: 7404
De’ Morgan’s laws:
A
(i) A . B = A + B (ii) A + B = A . B A B
A B
7432
Y = A+ B
7400
Y = A.B B
7404
A
7402
7404
Y = A+ B
7404
B 3
7408
Y = A.B
TYPICAL TRUTH TABLE: INPUT A B 0 0 0 1 1 0 1 1
OUTPUT (Y) VOLT LOGIC
PROCEDURE: • • •
Wire up the circuits (for pin diagram of the ICs, refer the Appendix-B of this manual). Apply inputs A & B. And generate the truth table for each of the circuits (0 Volts ‘0’, 5 Volts ‘1’ ).
EXERCISE: 1. Verify that NAND gate is a universal Gate. 2. Design a simple n-bit parity checker.
*****
4
AIM :
Design and testing of Half Adder, Half Subtractor, Full Adder, 2-to-1 Multiplexer and 1-to-2 Demultiplexer.
APPARATUS /COMPONENTS REQUIRED: Power Supply (1 No.), Multimeter (1 No.), NOT (IC 7404), XOR (IC 7486), AND (IC 7408), OR (IC 7432) two each, NOR (IC 7402) and LEDs.
PROCEDURE: • • •
Wire up the circuits (for pin diagram of the ICs, refer the Appendix-B of this manual). Apply inputs A & B. And generate the truth table for each of the circuits [0 Volts ‘0 ’, 5 Volts ‘1’].
a) CIRCUIT DIAGRAM: HALF ADDER
TRUTH TABLE: INPUT A B 0 0 1 1
OUTPUT (Y) CARRY SUM VOLT LOGIC VOLT LOGIC
0 1 0 1
5
b) CIRCUIT DIAGRAM: HALF SUBTRACTOR
TRUTH TABLE:
INPUT A B 0 0 1 1
OUTPUT (Y) BORROW DIFFERENCE VOLT LOGIC VOLT LOGIC
0 1 0 1
c) CIRCUIT DIAGRAM: FULL ADDER
TRUTH TABLE:
INPUT A B C 0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1
OUTPUT (Y) CARRY SUM VOLT LOGIC VOLT LOGIC
0 1 0 1 0 1 0 1 6
d) CIRCUIT DIAGRAM: 2 TO 1 MULTIPLEXER
e) CIRCUIT DIAGRAM: 1 TO 2 DEMULTIPLEXER
EXERCISE: 1. Full Substractor. 2. Adder cum Substractor. ***** 7
AIM :
Design and test a NAND latch and JK flip-flop and use the latter to construct 4-segment shift register and ripple counter.
APPARATUS /COMPONENTS REQUIRED: Power Supply (1 No.), Multimeter (1 No.), NAND (IC 7400), JK Flip Flop (IC 7476), NOT (IC 7404), LED (4 No.), 1 K Resistance (4 No.), Digital Storage Oscilloscope (DSO), switches PART A.: BASIC LATCH CIRCUIT USING NAND GATE. PROCEDURE : • • • • • • •
Analyze the circuit and make the truth table. Wire up the circuits as shown in Fig 3.1. Test the out put (LED) by using all possible combinations of inputs for P and R. Replace the power supply with a function generator (and a NOT gate if required) for generation of all possible combinations of inputs P and R. Remove LED and connect both the outputs on different channels of the Digital Storage Oscilloscope (DSO). Display both the inputs and outputs on DSO. Record the wave shape for all the possible combinations. 7400
Fig.3.1: Basic latch using NAND gate (IC 7400)
PART B: J-K FLIP FLOP: PROCEDURE: • •
Assemble the circuit as shown in Fig 3.2 . Initially set clock pulse at ‘0’ level and check the out put for i. C at 1 and P at 0 and ii. C at 0 and P at 1.
8
• • • •
•
Momentarily disconnect the SW2 (so as to ensure clock=0) and then release it (making Clock=1) to enable the flip-flop. Verify the truth table for enabled condition of the flip-flop (of step 1 and 2). Repeat step 3 for all possible combinations of input J and K to generate the truth table. Replace power supplies V1 and V2 with the signal from the function generator. For clock frequency use TTL signal from the function generator. Set the frequency to ~10 KHz. Display J and K inputs and the output on the DSO. For various combinations of inputs (all the rows of the truth table) you may be required to use a NOT gate. Record the output for all the combinations. Trace the wave forms or record the data.
Fig 3.2: J-K flip flop
PART C: DESIGN AN ASYNCHRONOUS COUNTER: RIPPLE DOWN COUNTER PROCEDURE: • • • • •
Assemble the circuit as shown below in Fig. 3.3. Enable the circuit as done in the previous part. Apply an input clock from the function generator (TTL pulse) at low frequency (1 Hz10 Hz). Observe the ON-OFF sequence of the LEDs and verify the truth table. Remove the LEDs and record the waveform using the DSO. Measure the delay in subsequent signals and discuss the results. 9
Fig 3.3.
PART D: DESIGN A 4 BIT SERIAL IN PARALLEL OUT SHIFT REGISTER PROCEDURE: 1. Assemble the circuit of Fig 3.4. Connect the out put of all the flip-flops to LEDs via 1 kΩ resistances. 2. Set the Function Generator for square waveform with period of 10 (or 5) second. Connect function generator output to clock input of the Shift Register Circuit. 3. Enable the circuit. 4. Manually apply an input of “logic 1” into the first flip-flop when clock is in high state. Circuit will take input only when High to Low transition of clock state takes place (as in the previous experiment). This can be observed by displaying the clock pulse simultaneously on DSO and observing the ON-OFF sequence of the first LED. 5. Once the circuit takes the input as “logic 1”, bring the input to “logic 0”. Then check the serial shift of this bit through the shift register for each High to Low transition of clock state by observing the LEDs and verify this circuit’s behavior. 6. Display the three Shift Resister output & the Clock on the DSO and repeat step 4 above 7. You may also repeat step 4 and 6 above by displaying the output of all four shift register on the DSO.
10
Fig. 3.4
EXERCISE: 1. MOD counters. 2. Up-Down counter *****
11
AIM :
Design and test comparator, encoder and decoder circuits.
APPARATUS /COMPONENTS REQUIRED: NOT (IC 7404-3 Nos), XOR (IC 7486-2 Nos), OR (IC 7432 -4 Nos), AND (IC 7408-2 Nos), 3-i/p NAND (IC 7410 -2 Nos), LED (10 No.), 1 K Resistance (4 No.).
PART A.: DESIGN AND TEST OF 2-BIT MAGNITUDE COMPARATOR .PROCEDURE : • Analyze the circuit and derive the appropriate Boolean expression for each of the outputs. • Wire up the circuit as shown in the fig 4.1 below. • Logical inputs are given in the truth table 4.1. • Test the out put (using LED and multi-meter) by using all possible combinations of inputs.
LOGIC DIAGRAM: 2 BIT MAGNITUDE COMPARATOR
Fig. 4.1 12
TRUTH TABLE 4.1:
A1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
INPUT A0 B1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
B0
A>B VOLT LOGIC
OUTPUT A=B VOLT LOGIC
A
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
PART B: DESIGN AND IMPLEMENTATION OF ENCODER PROCEDURE : • •
Analyze and wire up the circuits as shown in the circuit diagram (Fig. 4.2). Test the Out put (using LED and multi-meter) by using all the possible combinations of inputs by connecting a 5 V power supply with the help of switches.
13
LOGIC DIAGRAM: ENCODER
Fig. 4.2
TRUTH TABLE 4.2: INPUT
OUTPUT
Y1 Y2 Y3 Y4 Y5 Y6 Y7
A
B
C
VOLT LOGIC VOLT LOGIC VOLT LOGIC 1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
14
PART B: DESIGN AND IMPLEMENTATION OF DECODER PROCEDURE : • Analyze and wire up the circuits as shown in the figure below. • Test the out put (using LED and multi-meter) by using all the possible combinations of inputs. LOGIC DIAGRAM: DECODER
Fig. 4.3
TRUTH TABLE 4.3:
INPUT E
A
B
D0 VOLT
1
0
0
0
0
0
0
0
1
0
1
0
0
1
1
OUTPUT D1
LOGIC
VOLT
D2
LOGIC
VOLT
EXERCISE: Design and demonstrate a sequence generator circuit. ***** 15
LOGIC
D3 VOLT
LOGIC
AIM : Perform addition / subtraction, using 4-bit adder, store the result in static RAM and retrieve the stored result from the RAM.
APPARATUS/COMPONENTS REQUIRED: Power Supply (1 No.), Multimeter (1 No.), 4-bit parallel adder (IC 7483 – 2Nos), 4-bit static 4K RAM (IC 2114 – 1 Nos), LEDs
PROCEDURE: • •
For functional description of 4-bit static 4K RAM (IC2214) and 4-bit parallel adder (IC 7483), refer to the data sheets. Give the two 4-bit inputs (A and B) to the adder circuit and store the result in static RAM. The following steps will explain the procedure to store and retrieve data in/from the RAM.
TO STORE A RESULT IN STATIC RAM: • • • •
Draw the circuit to store output of IC 7483 in IC 2114 (Static RAM). For writing data, make both WE and CS input low in IC 2114. Select any address input from A0 to A9, (say A3 A2 A1 A0) and connect the data inputs to I/O4 - I/O1. By performing the last two steps, data can be stored in the memory location specified by you.
TO RETREIVE DATA FROM STATIC RAM: • • •
Disconnect the data inputs I/O4 - I/O1 from input lines and connect them to output lines to read the data. For reading data, make WE pin high and CS input low. Give address inputs of the data you have stored and observe the outputs I/O4 - I/O1.
1. Store any 10 consecutive adder results in 10 consecutive locations in static RAM. Then retrieve the data by reading the 10 locations. 2. Modify the adder circuit to a subtractor circuit using IC 7483 adder. Repeat the process for storing and retrieving 10 results.
16
PIN DIAGRAMS:
Fig 5.1: 4-bit Adder Circuit
Fig 5.2: 4-bit Subtractor Circuit 17
PIN & LOGIC DIAGRAMS:
EXERCISE: 1. Perform other arithmetic operations and store in/ retrieve from static RAM. ***** 18
AIM :
Programming exercises using a 8085A microprocessor trainer kit.
APPARATUS /COMPONENTS REQUIRED: Dyna85 Trainer kit ( P8085), Power Supply (SMPS) BACKGROUND: A microprocessor (µP) trainer kit consists of basic units required for a simple computer, namely, a microprocessor chip (CPU), memory (EPROM, and RAM), input device (Hex keypad and cassette tape) and output device(seven segment display unit- four address fields followed by two data fields). Programmable peripheral chips such as 8155 and 8255 provide the necessary interface between the µP and the external circuitry. These physical units constitute the basic hardware of the system. Software in the form of a set of instructions written using the 8085 instruction set makes the µP perform a set of desired operations. It has to keep in mind that the instructions should be converted into the hexadecimal form before entry in this kit. A system program (commonly called the operating system) resides in the EPROM and gets loaded whenever the kit is switched ON. The MICROFRIEND DYNA-85 kit given in the laboratory is based on the INTEL 8085 chip. The CPU operates at 3 MHz (system clock). The RAM locations (C000)16 to (FFFF)16 are available for the user to enter any desired program. The following single-key system commands are provided in the trainer kit for facilitating easy operation of the kits. Does hardware reset. The word “FriEnd” appears in the display when pressed Decrements memory address presently displayed Increments memory address presently displayed Starts execution of command Used for modifying contents of RAM locations reserved for the user Used for loading the memory address of the beginning of the program For executing program in single step or break-point mode Keys let you examine or modify the CPU registers To use these commands press and press one A, B, C, D, E, F, 8 or 9 for choosing the registers A, B, C, D, E, Flag H or L respectively. The flag register bits are S Z X
AC X P X C
where S is the sign flag, Z is the zero flag, AC is the auxiliary carry flag, P is the plus flag and C is the carry flag (X means don’t care). 19
To enter a program, follow the following sequence: C000 XX ! first hex instruction is entered in the place of XX ! this command increments address to C001 . ! enter the entire program by keying one 8 bit no. in hex . in each location and moving to next by pressing 76 ! last instruction in the program To execute the entered program, use the following commands: C000 ! load program which starts at address C000 ! execute the loaded program It is usually desired that the result of a computation is readily available after the execution of the program. The subroutine called MODIDT which resides in the EPROM at the address (036E)16 can be used to display the contents of register A (Accumulator) to the data fields of the display units. In order to use this to display the result of any computation use following sequence instructions: CALL MODIDT ! Key in the address 03 6E in the place of MODIDT It should be remembered that the CALL MODIDT commands changes the state of all CPU registers and all flags and hence be careful & use this only towards the end of the program.
PROGRAMS TO BE ENTERED AND TESTED: 1. 2. 3. 4.
Multiplication of two 8-bit numbers by successive addition method. Multiplication of two 8- bit numbers by shift left & add method. Divide the given numbers and display quotient in display fields. Divide the indivisible numbers and display the quotient in display field and store reminder in location some memory location. 5. Load ten 8-bit numbers in ten memory locations and sort them in ascending order.
EXERCISE: 1. Program to implement BCD to BINARY conversion. 2. Program to simulate THROW OF A DICE. ***** 20
AIM :
Simple Interfacing exercises using 8085A microprocessor trainer kit.
APPARATUS /COMPONENTS REQUIRED: Multimeter – 1 Nos , Dyna85 Trainer kit ( P8085-– 1 Nos), Power Supply (SMPS – 1 Nos), Flat Ribbon Cable (FRC) – 1 Nos, 7-Segment LED (MAN-74A- – 2 Nos) , BCD-to-SevenSegment Decoder (74LS48P – 1 Nos), LEDs -10 Nos
PREREQUISITE: Knowledge of interfacing peripherals 8155A and 8255A (Ref: Appendix –C & E) which are parts of the 8085 Microprocessor kit.
PART A: To generate binary equivalent of sequence of decimal numbers from 0 to 15 and display the binary numbers by activating 8 LEDs using 8155A interfacing peripherals. DIAGRAM:
Fig.7.1
CONNECTION TABLE 7.1: Pin Number 1 2 3 4 6 7 8 9 26
Signal Name PA3 PA2 PA1 PA0 PA7 PA6 PA5 PA4 GND
Bit position represented by LED 2-5th bit 2-6th bit 2-7th bit LSB (2-8th bit) MSB (2-1th bit) 2-2th bit 2-3th bit 2-4th bit Sort cathode of all the LEDs together and connect to GND
21
FOR 8155A ADDRESS OF PORT A=09H, ADDRESS OF PORT B=0AH, ADDRESS OF PORT C=0BH, ADDRESS OF CONTROL REGISTER=08H, PORT A SPECIFICATION = OUTPORT, MODE 0, PORT B SPECIFICATION= OUTPORT , MODE 0 MEMORY MACHINE MNEMONICS COMMENTS ADDRESS CODE
C000
3E, 03
MVI A, 03H
C002
D3, 08
OUT 08H
C004
3E, 06
MVI A, 06H
C006 C008
D3, 09 76
OUT 09H HALT
Control word to initialize I/O PORTs of 8155: Ports A and B are configured as output and Port C as input port. Writing Control Word to control register of 8155, whose address is 08 in Dyana85 P kit. Get 01 into accumulator as we want to display binary equivalent of 06. Send 05 to Port A whose address is 09H Stop
PROCEDURE: 1. For learning about interfacing peripherals 8255 & 8155, refer the Appendix-C. 2. Understand the given program and load it in the specified memory locations. Here the control word of 8155A is set in such a way that PORT-A is configured as OUTPUT port (in memory location C000 to C003). 3. Connect the 26-Pin FRC to J2 connector of the P kit and the 8 LEDs as specified in the table 7.1 and in Fig. 7.1. 4. Run the program and observe the LED status. 5. Change the program to display various sequences of number from 0H-FH (in C005 memory location) and observe the output.
PART B: To activate a 7-Segment LED and display any decimal number from 0 to 8 using 8155A.
BACKGROUND: 7-Segment LED: The 7–segment LED display is a multiple segment LED display module. It can display all decimal digits and some letters by activate appropriate LED segments. Each of the 7 LED segments can be controlled separately. To display a digit or letter, the desired segments are made ON as described in the figure below. Two types of 7–segment LEDs available in the market are called ‘common cathode’ and ‘common anode’ 7-segment LEDs. Common Cathode: In this type, all the 7 cathodes of LEDs are tied together to the ground. When a +5V signal is applied to any segment, corresponding diode emits light. Thus, applying logic ‘1’ i.e, positive logic, to desired segments, the desired letter or decimal number can be displayed. Common Anode: In this type, all the 7 anodes of LEDs are tied together and connected to a +5 V supply. A particular segment will emit light when ‘0’ logic is applied to it. 22
PIN DIAGRAM:
Fig.7.2a
Fig.7.2b To display digit 1 using this common cathode seven –segment LED, the segment b and c should be turned on. Corresponding binary code should be:
CONNECTION TABLE 7.2: Data Lines : Bits Segment
PA7 X NC
PA6 0 g
PA5 0 f
PA4 0 e
PA3 0 d
PA2 1 c
PA1 1 b
PA0 0 a
Similarly, by changing the content of the data lines we can display different digits.
23
=06H
FOR 8155A ADDRESS OF PORT A=09H, ADDRESS OF PORT B=0AH, ADDRESS OF PORT C=0BH, ADDRESS OF CONTROL REGISTER=08H, PORT A SPECIFICATION = OUTPORT, MODE 0, PORT B SPECIFICATION= OUTPORT , MODE 0 MEMORY MACHINE MNEMONICS COMMENTS ADDRESS CODE
C000
3E 03
MVI A, 03H
C002
D3 08
OUT 08H
C004 C006 C008
3E 06 D3 09 76
MVI A, 07H OUT 09H HLT
Control word to initialize I/O PORTs of 8155: Ports A and Port B are configured as output and Port C as input modes. Writing Control Word to control resister of 8155, whose address is 08 in Dyna85 P kit Get 06 in accumulator as we want to display 1. Send 06 to Port A whose address is 09H Stop
PROCEDURE: 1. Understand the given program and load it in the specified memory locations. Here the control word of 8155A is set in such a way that PORT-A is configured as OUTPUT port (in memory location C000 to C003). 2. Connect the 26-Pin FRC to J2 connector of the P kit and the 8 LEDs as specified in the table 7.2 and in Fig 7.2. 3. Run the program and observe the LED status. 4. Change the program to display various sequences of number from 0H-FH (in C005 memory location) and observe the output. PART C: To activate a 7-Segment LED to display any decimal number from 0 to 8 using BCD-to-SevenSegment Decoder (74LS48P) and 8255A. BACKGROUND: BCD-to-Seven-Segment Decoder (74LS48P) aspects a 4 digit BCD input and decodes it to a 7 digits output, which is usually used for 7-Segment LED display.
Fig.7.3 24
CONNECTION TABLE 7.3: Pin Number 74LS48P 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Connected to Signal
Remark
PB1 Signal from 8255A PB2 Signal from 8255A NC NC NC PB3 Signal from 8255A PB0 Signal from 8255A GND Signal from 8255A Pin 1 of Seven Segment LED Pin 2 of Seven Segment LED Pin 4 of Seven Segment LED Pin 6 of Seven Segment LED Pin 7 of Seven Segment LED Pin 10 of Seven Segment LED Pin 9 of Seven Segment LED +5V D.C
Pin No 19 of FRC Cable Pin No 20 of FRC Cable
Pin No 21 of FRC Cable Pin No 18 of FRC Cable Pin No 26 of FRC Cable e d c b a g f
FOR 8255A ADDRESS OF PORT A=10H, ADDRESS OF PORT B=11H, ADDRESS OF PORT C=12H, ADDRESS OF CONTROL REGISTER=13H, PORT A SPECIFICATION = INPORT, MODE 0, PORT B SPECIFICATION= OUTPORT , MODE 0 MEMORY MACHINE MNEMONICS COMMENTS ADDRESS CODE C000
3E 98
MVI A, 98H
C002
D3 13
OUT 13H
C004 C006 C008
3E 05 D3 11 76
MVI A, 05H OUT 11H HLT
Control word to initialize I/O PORTs of 8255 : PORT A as an Input PORT & Mode 0, PORT B as an Output PORT & Mode 0 PORT Cupper as an input PORT and PORT Clower as an output PORT Writing Control Word to control resister of 8255, whose address is 13 in Dyana85 Microprocessor Kit Get 05 in accumulator as we want to display 5. Send 05 to Port B whose address is 11H Stop
PROCEDURE: 1. Connect the 26-Pin FRC to J3 connector of the P kit, decoder (74LS48P) and the seven segments LED as specified in the table 7.3 and in Fig 7.3 by using a bread board as shown in Fig.7.3. 2. Understand the given program and load the same in the specified memory locations. 3. Run the program and observe the 7 Segment LED display status. 4. Change the program to display various number from 0- 8 and observe the output. EXERCISE: 1. Fabricate a display with two 7-segment display units (each capable of displaying hexadecimal numbers. 2. Propose a scheme for displaying two digit numbers using two seven-segment display units ***** 25
AIM :
Interfacing of 8-bit Analog to Digital and Digital to Analog cards with 8085A microprocessor kit.
APPARATUS /COMPONENTS REQUIRED: Dyna85 Trainer kit ( P8085 – 1 No), ADC Card (Dynalog ADC-08 – 1 No ), DAC Card (Dynalog DAC-01 – 1 No), Flat Ribbon Cable (FRC) – 2 Nos, Power Supply (SMPS – 2 Nos), LEDs – 10 Nos
PART A: To convert an analog signal to digital signal by interfacing ADC card with the 8085 microprocessor kit, store the data in accumulator and then reproduce the same analog signal by using DAC card.
BACKGROUND: In this experiment, you will learn to connect ADC & DAC cards to 8085 P through PPI devices 8255 and 8155. The input analog signal will be applied to Channel 0 of ADC card and the necessary control signal will be supplied by the P. The digital output will be temporarily stored in the Accumulator and then will be applied to the digital Inputs of DAC card. Finally, the analog output will be displayed in the DSO and compared with the original input. The ADC 08 card plugs into the 8255 IC via 26 Pin FRC Connector. Information’s on 8255 IC interface is given in the Appendix. Ports B and Cupper are defined as input and Ports A and Clower in the output ports. Port A‘s PA0, PA1, PA2 are used to multiplex channel select. PB0 –
26
PB7 are used for 8-bit digital output from ADC card. PC1, PC2 are used as Start of Conversion, Enable & output enable signals. PC4 is used end of conversion signal. The DAC card is plugs into the 8155 IC via 26 Pin FRC Connector. Ports A and Port B are configured as output port and Ports C as input port. Port B’s PB0 signal gives the allow data flow signal to the DAC. Port A’s PA0 – PA7 are used for 8-bit digital input to the DAC card. ADDRESS of PORTS in DYNA85 Microprocessor Kit 8255 IC 8155 IC Control Register 13H Control Register 08H Port A 10H Port A 09H Port B 11H Port B 0AH Port C 12H Port C 0BH
PROCEDURE: 1. For details of ADC card, 26 pin Flat Ribbon Cable (FRC) Pin details, interfacing 8255 & 8155 etc., refer the Appendix –C , -D & -E of this manual. 2. Before switching on the power supply, check the direction of 26 pin flat cable connector at both ends. All supply connections +5V, +12V and -12V must be applied simultaneously to the ADC & DAC cards. 3. Load the program in the P in the specified memory locations. 4. The value in the DE register pair (in location C02D and C02E in the program) will define the sampling rate by producing a delay. This register pair can be 0000H–FFFFH. 5. Input a sinusoidal signal with peak to peak voltage less then 5V and frequency less then 30 Hz from function generator. Sample it with various sampling frequency (as described in the previous point). [A table containing information of various values of DE resister pair and corresponding sampling frequency will be provided to you]. 6. Trace both the original input analog signal and the re-constructed signal from DAC output in the two channel of DSO. 7. Use a signal of a particular frequency (> 30Hz) and re-construct it for three set of different sampling frequencies. 8. Compare the fast Fourier transform (FFT) of the input signal and the reconstructed signal for different sampling frequency. Analyse the effect of sampling frequency. 27
PROGRAM TO DRIVE ADC AND DAC CARDS DATA
MNEMONIC
COMMENT
C000
3E 8A
MVI A, 8AH
C002
D3 13
OUT 13H
C004
3E 03
MVI A 03H
Control word to initialize I/O PORTs of 8255: Ports B and Cupper are defined as input mode and Ports A and Clower in the output mode Writing Control Word to control register of 8255, whose address is 13 in Dyana85 Microprocessor Kit Control word to initialize I/O PORTs of 8155: Ports A and Port B are configured as output mode and Ports C in input mode.
C006
D3 08
OUT 08H
C008 C00A
3E 01 D3 0A
MVI A 01H OUT 0AH
3E 00
MVI A 00H
D3 10
OUT 10H
ADDRESS
C00C C00D C00E C00F
LEBEL
LOOP1
Loading first Accumulator with ' 00'and then PORT A whose address is 10. These instruction does two jobs : 1. Sets SOC PIN of 0809 to Low state. 2. Sets Pins 23, 24, 25 of 0809 to Low state. (By setting
these three pins low or high or combination of low and high state, one can select different multiplexed channels (Ch- 0 to Ch-7) of the ADC. By setting all three pins to low Ch-0 is selected (as in this case).
C010 C012
3E 06 D3 12
MVI A, 06H OUT 12H
C014 C016
3E 04 D3 12
MVI A, 04H OUT 12H
DB 12 E6 10 FE 10 C2 18 C0
IN 12H ANI 10H CPI 10H JNZ LOOP
C018 C01A C01C C01E
Writing Control Word to control resister of 8155, whose address is 08 in Dyana85 Microprocessor Kit PB0 high signal gives the allow data flow signal to the D/A Converter
LOOP
C021 C023 C025
3E 0B D3 12 DB 11
MVI A, 0BH OUT 12H IN 11H
C027
D3 09
OUT 09
Loading Accumulator with ' 06'and then sending it to PORT C. These instructions direct 0809 to start conversion by making SOC and ALE PINs of 0809 to High state Loading Accumulator with ' 04'and then sending it to PORT C. These instructions direct 0809 to start conversion by making SOC and ALE PINs of 0809 to Low state. Check for End-of-Conversion Pin status. If Conversion is over then status of SOC Pin of 0809 will be High. If conversion is over then IN instruction changes MSB of Accumulator to 1 otherwise 0. If conversion is over then RAL instruction sets the CARRY flag. If CARRY flag is not set then JNZ instruction takes program control to previous IN instruction i.e. to C018 for further checking and it continues until the EOC pin is high. If conversion is over i.e. EOC pin is high, then program proceeds ahead. Enable output This instruction scans for the contents of PORT B and loads it in Accumulator. This instruction sends the contents of Accumulator to Port A of 8155.
28
C029
CD 6E 03
CALL MODIDT
C02C
11 FF FF
LXID FFFFH
C02F
CD F1 05
C032 C035
C3 0C C0 76
CALL DELAY JMP LOOP1 HLT
Calling the Monitor Program stored at location 036E . This instruction will display the contents of Accumulator in system’s LED monitor. Load FFFFH in DE register pair. The content of DE register pair decides the scanning rate. Calling the delay sub-routine in location 05F1. Jump to C00C Stop
PART B: To generate a square wave signal of any frequency between 1 Hz to 10 Hz using DAC Card.
PROCEDURE: 1. With the experience of driving the DAC card in the previous experiment, write a program to generate square wave of any frequency between 1Hz to 10 Hz using a DAC card. 2. Before switching on the power supply, check the direction of 26 pin flat cable connector at both ends. All voltages (+5, +12 and -12 V) must be applied simultaneously to the DAC. 3. Load the program in Microprocessor in the specified memory locations. 4. Connect the output of DAC card to Digital Storage Oscilloscope (DSO). 5. Trace the signal from the DSO.
EXERCISE: 1 2
Write a program to generate triangular wave of any frequency between 1Hz to 10 Hz using DAC Card. Write a general program to convert any input signal (square, triangular) with frequency in the range of 1 Hz to 10 Hz into digital signal. ******
29
AIM :
Interfacing a stepper motor with 8085A microprocessor kit and its control.
APPARATUS /COMPONENTS REQUIRED: Dyna85 trainer kit (8085 P - 1 No), stepper motor controller card (STP-PIO – 1 No) , stepper motor ( 1 No) , power supply (SMPS - 1 Nos) PROCEDURE 1. 2.
3.
To understand the working of the stepper motor controller card / 26 pin FRC pin details / interfacing details of 8255 or 8155 to the P etc., refer the Appendix-C, -D, -E & -F. Feed and run the given program using 8085 P kit. You can write your own program to run the stepper motor in free running and step wise mode. Try to run the stepper motor in continuous mode/ step mode with variable rpm. Perform following operations: activate the motor at desired rpm value, make it rotate in both directions, interrupt while in motion and restart, set it for desired no. of revolutions.
Programming the stepper motor: Program for free running mode: ADDRESS
OPCODE
D000
06 04
D002
21 E0 C1
D005 D006 D008 D00B D00E D00F D010 D013 D016 D019 D01A
7E D3 10 11 05 05 CD F1 05 23 05 C2 05 D0 CD 1A D0 C3 00 D0 FF 3E 80
LABEL UP5:
MNEMONIC S MVI B, 04 LXI H, C1EO
UP3:
UP4 30
MOV A, M OUT 10 LXI D, 0505 CALL 05F1 INX H DCR B JNZ UP3 CALL UP4 JMP UP5 RST 7 MVI A 80
COMMENTS ADDRESS ‘ C1EO ‘ FOR CLOCKWISE ADDRESS ‘ C0EO ‘ FOR ANTI CLOCKWISE
D01C D01E D020 D022 D024 D026
D3 13 3E FF D3 10 3E FF D3 12 C9
OUT 13 MVI A FF OUT 10 MVI A FF OUT 12 RET
These inputs to be entered at the following memory locations. These are step variables
COEO C1EO
06 0A 09 05 00
For Clockwise movement For Anti Clockwise movement
05 09 0A 06 00
• Load the program in the above mentioned memory locations and execute the program. Change the direction of movement by changing the program at the memory location D003. Program for stepwise mode: Here the direction and speed of rotation, number of steps to move can be programmed. The following parameters have to input in specified memory locations. Memory Location C230 C231 C232 C233 Program ADDRESS
Reserved for
Value
Result
Direction of Rotation Number of Steps
00 01 00 - FF
Speed for Clockwise rotation Speed for Anti Clockwise rotation
00 - FF
Clock-wise rotation Anti clock-wise rotation The no. of steps the motor will rotate This number will define the speed of rotation. Bigger the number, lesser will be the speed.
OPCODE
00 - FF
LABEL DN2:
MNEMONICS
E000
3E 80
E002
D3 13
OUT 13
E004
3E FF
MVI A, FF
E006
D3 12
OUT 12
E008
3A 31 C2
LDA C231
E00B
57
MOV D, A
E00C
3A 30 C2
LDA C230
E00F
FE 00
CPI A, 00
E011
CA 43 E0
JZ DN3
31
COMMENTS
MVI A 80
Program for stepwise running
E014
21 E0 C0
E017
E5
UP6:
PUSH H
E018
7E
UP1:
MOV A, M
E019
D3 10
OUT 10
E01B
3A 32 C2
LDA C232
E01E
4F
MOV C, A
E01F
3A 33 C2
LDA C233
E022
47
MOV B, A
E023
CD 60 E0
CALL DELAY
E026
23
INX H
E027
7D
MOV A, L
E028
FE E4
CPI E4
E02A
C2 3B E0
JNZ DN4
E02D
3A 30 C2
LDA C230
E030
FE 00
CPI 00
E032
CA 49 E0
JZ DN5
E035
21 E0 C0
LXI H, C0E0
E038
C3 3B E0
JMP DN4
E03B
15
E03C
C2 18 E0
JNZ UP1
E03F
00 00 00
NOP
E042
76
HLT
E043
21 E0 C1
E046
C3 17 E0
E049
21 EO C1
E04C Delay routine : E060
C3 3B E0
E061
78
MOV A, B
E062
B1
ORA C
E063
C2 60 E0
JNZ UP
E066
C9
RET
0B
LXI H, C0E0
DN4:
DN3:
Call delay
DCR D
LXI H, C1E0 JMP UP6
DN5:
LXI H, C1EO JMP DN4
UP:
DCX B
• Load the program in the above mentioned memory locations and execute the program. EXERCISE: Design of a Clock using 8085 µP kit and the stepper motor. ***** 32
BREAD BOARD The breadboard consists of two terminal strips and two bus strips (often broken in the centre). Each bus strip has two rows of contacts. Each of the two rows of contacts is a node. That is, each contact along a row on a bus strip is connected together (inside the breadboard). Bus strips are used primarily for power supply connections, but are also used for any node requiring a large number of connections. Each terminal strip has 60 rows and 5 columns of contacts on each side of the centre gap. Each row of 5 contacts is a node. You will build your circuits on the terminal strips by inserting the leads of circuit components into the contact receptacles and making connections with 22-26 gauge wire. There are wire cutter/strippers and a spool of wire in the lab. It is a good practice to wire +5V and 0V power supply connections to separate bus strips.
Fig. A-1 : Schematic diagram of a breadboard. The lines indicate connected holes.
33
34
35
36
PROGRAMMABLE PERIPHERAL INTERFACE
8255 Programmable Peripheral Interface Intel 8255 is a programmable peripheral interface (PPI). It has three 8-bit ports namely Port A, Port B and Port C. The Port C further divided into two 4-bit ports, namely, Port C upper (Cupper) and Port C lower (Clower). Thus a total 4 ports are available, two 8-bit ports and two 4bit ports. Each port can be programmed either as an input port or output port sending control word signal from microprocessor. In our experiment we will configure the ports of 8255 as per following status: Port A as an input port and Mode of the Port A – Mode 0 Port B as an output port and Mode of the Port B – Mode 0 Port Cupper as an input port Port Clower as an output port The control word bits for the above definition of the ports are shown in the following figure:
Fig : Control word bits for 8255 in our experiment
37
8155 Programmable Peripheral Interface: Intel 8155 is a programmable peripheral interface (PPI). It has two 8-bit ports namely Port A, Port B and one 6-bit port namely Port C upper (Cupper). Each port can be programmed either as an input port or output port sending control word signal from microprocessor.
The control word =98 H Bit No. 0 is set to 0, as the Port Clower is an output port Bit No. 1 is set to 0, as the Port B is an output port Bit No 2 is set to 0 , as the Port B has to operate in Mode 0. Bit No 3 is set to 1 , as the Port Cupper is an input port Bit No. 4 is set to 1, as the Port A is an input port Bit No. 5 and 6 are set to 00, as the Port A has to operate in Mode 0. Bit No. 6 is set to 1, as the Ports A , B and C are used as simple input/output port Thus the control word is 98H.
38
ADC0809 & DAC0800
ADC 0809 : The ADC 0808 (or 0809) is an 8-bit A/D converter (ADC) with 8-channel multiplexer. It is a monolithic CMOS chip manufactured by National Semiconductors. The ADC uses successive approximation as the conversion technique. It does not require external zero and full scale adjustments. There is no terminal available for sample and hold between the multiplexer and comparator stages. Figures displayed below show the schematic diagram and the timing diagram of ADC 0808/0809. The device operates with a single 5 V d.c. supply. The conversion time is 100 ns at clock frequency 640 KHz. The resolution is 8 bits. Error ± 1 LSB.
Fig: Schematic diagram of ADC0809
Fig: Timing Diagram of ADC0809 39
Some important characteristics of ADC 0809 are as follows: Electrical CharacteristicsMinimum Start Pulse Width 100 ns Minimum ALE Pulse Width 100 ns Clock Frequency 10 to 1280 KHz Conversion Time 100 nS at 640 KHz Resolution 8 bits Error ± 1 LSB Ref. (+) should not be more positive than supply. Ref. (-) should not be more negative than ground. Supply 5 V d.c. Logical "I" Input Voltage Min Vcc-1.5 Logical "0" Input Voltage Max. 1.5 V Logical "I" Output Voltage Min. : Vcc-O.4 Logical "0" Output Voltage Max. : 0.45 V DAC 0800 : The DAC 0800 is a simple monolithic 8-bit D/A converter (DAC). Pin diagram and interfacing connections of the DAC are shown below. It has fast settling time (~100 ns). It can be directly interfaced to TTL, CMOS, PMOS and others. It operates at 4.5 V to +18 V supply. The supply V+ may be either +5 V or +12 V. V- is kept at -12 V, being easily available on standard power supply units.
40
P i n - o u t c o n f i g u r a t i o n o f J 2 / J 3 Connector of Dyna85 µP Kit
CONNECTOR J2 : 8155 CONNECTOR Pin No Signal Name 1 PA3 2 PA2 3 PA1 4 PA0 5 VCC 6 PA7 7 PA6 8 PA5 9 PA4 10 TIM OUT 11 TIM IN 12 PC5 13 PC4 14 PC0 15 PC1 16 PC2 17 PC3 18 PB0 19 PB1 20 PB2 21 PB3 22 PB4 23 PB5 24 PB6 25 PB7 26 GND
CONNECTOR J3 : 8255 CONNECTOR Pin No Signal Name 1 PA3 2 PA2 3 PA1 4 PA0 5 VCC 6 PA7 7 PA6 8 PA5 9 PA4 10 PC7 11 PC6 12 PC5 13 PC4 14 PC0 15 PC1 16 PC2 17 PC3 18 PB0 19 PB1 20 PB2 21 PB3 22 PB4 23 PB5 24 PB6 25 PB7 26 GND
41
STEPPER MOTOR CONTROLLER CARD Stepper motors have immense applications in printing, industrial robotics, precision tool motions in drilling, cutting and shaping machines, lathe etc. The aim of experiment #9 is to demonstrate interfacing of stepper motor to 8085 microprocessor and to run it in continuous or stepped motion in forward or reverse direction in a programmable manner using 8085 microprocessor. The hardware setup consists of a microprocessor trainer kit and stepper motor interface board. The stepper motor interface consists of driver transistors (current amplifiers) for energizing stepper motor windings and address decoding circuit. The microprocessor outputs the binary sequence (programmed) through the data bus, which is converted in to current pulses by the driver transistors and used for driving the stepper motor.
Fig. F-1 The STP-PIO card interfaces with the microprocessor kit and has the capability to drive 12 V d.c., 5 A/phase stepper motor and has the choice of two rotating directions. The card can be used for varying the rotation speeds in terms of 00H to FFH steps, which can be programmed. The dynamic torque is mainly controlled by the drive circuit and the output transistors can give up to 3 A current. The maximum working temperature of the stepper motor is 30 to 40 °C above the ambient. The schematic diagram of the stepper motor is shown as in Fig.F-2.
42
Fig.F-2: The schematic diagram of the stepper motor The control s/w is in 8085 assembly language. The control word is written to the 8255 IC to select speed, direction and motor ON/OFF states. The numbers of rotation steps can also be programmed. After program execution, the motor starts and rotates in the selected direction with the chosen speed. It stops after the specified number of steps. Stepper motors (four phase) available in the lab require 12V DC and 5 Amps/phase. The Step angle of the stepper motor is -1.8° with an error of up to 5% and their holding torque is 2 kg cm.
*****
43