Keyboard Interfacing
Keyboard Interfacing
: 6
Theory: This program displays the code of the key which is pressed on the keyboard pad. The
code is displayed in the data field and remains unchanged till the next key is pressed.
The control world register of 8255 is initialized to make port A as input port and port c as output
port. 20 keys of the keyboard are arranged in matrix of 8x3. The row of matrix is connected
through port C (bit 0, 1, 2) and columns are returned to port A (bit 0-7). The three rows of the
key are scanned one by one and process is repeated till the key is pressed. When no key is
pressed the microprocessor reads the input port as 00. The key scanning starts by giving high
signal at PC0 and low at PC1 and PC2. If any key connected to PC0 through port A is pressed,
the corresponding column bit will also be high and will be detected by the software (program).
Similarly, rest of the keys are scanned in same manner. The information of code is then
displayed and the monitor jumps back again to see if any other key is pressed.
Program:
MNEMONICS
HEX
M. ADDRESS OPERAN COMMENTS
CODE OPCODE
D
2000H 3EH MVI A,90H Initialize the port
2001H 90H
A as an input &
port B and C as an
output
2002H D3H OUT 03
2003H 03H
2004H 06H MVI B,00H Initialize the final
2005H 00H
key code in Reg. B
2006H 0EH MVI C,01H Put the walking
2007H 01H
one pattern in reg
C with one in LSB
position
2008H 79H MOV A,C Move the pattern
in A
2009H D3H OUT PC Output of port C
200AH 02H
200BH DBH IN PA Input port A
200CH 00H
200DH CDH CALL CODE
200EH 38H
200FH 20H
2010H FEH CPI 08H Any key closure
2011H 08H
2012H FAH JM DISP Yes, Go to display
2013H 24H
it
2014H 20H
2015H 78H MOV A,B No, move partial
result in A
2016H C6H ADI 08H Increment the PC
2017H 08H
code in partial
result
2018H 47H MOV B,A
2019H FEH CPI 18H Has PC code
201AH 18H
become II
201BH F2H JP INIT Yes, Go start
201CH 04H
scanning from row
201DH 20H
0
201EH 79H MOV A,C
201FH 07H
2020H 4FH MOV C,A
2021H C3H JMP SCAN Continue scanning
2022H 08H
2023H 20H
2024H B0H ORA B Or the PA Code
with PC Code
2025H 32H STA CURDT Let it be current
2026H F6H
data
2027H 27H
2028H 3EH MVI A,00 Arg.-No dot
2029H 00H
202AH CDH CALL UPDDT Display it in data
202BH FAH
field
202CH 06H
202DH C3H JMP INIT Go to scan the KB
202EH 04H
again
202FH 20H
2038H B7H ORA A
2039H C2H JNZ CODE2
203AH 3FH
203BH 20H
203CH 3EH MVI A,08
203DH 08H
203EH C9H RET
203FH 16H MVI D,00
2040H 00H
2041H 0FH RRC Let LSB in A go to
carry
2042H DAH JC CODE10 Go to return if the
2043H 49H
bit was one
2044H 20H
increment counter
2045H 14H INR D Increment counter
2046H C3H JMP CODE5 Check the next bit
2047H 41H
2048H 20H
2049H 7AH MOV A,D
204AH C9H RET
Result: Thus we had interfaced keyboard with 8085 and seen that the letter pressed in 4x4 matric
keyboard with be displayed at seven segments of 8085.
PROGRAM SR NO.: 7(a)
Apparatus required: VINYTICS VMC-8501 kit, VINYTICS DC motor speed controller card
Theory:
PC0 bit of port C (8255) is responsible for turning the motor ON.
PC1 bit of port C is responsible for motor’s rotational direction.
PC1=1 motor rotates in clockwise direction and
PC1=0 motor rotates in counter clockwise direction
Data output on port A is given to DAC 0808, which gives analog output. Therefore, speed of
motor can be controlled through port A.
If Port A=FF, motor speed will be maximum
If Port A=00, motor will stop
If Port A=7F, motor will run at half of the maximum speed
Procedure:
a) Connect the transformer secondary to tag no’s 6 and 5 of J3 (Vtg. = 12V) for the tapping
of the secondary (AC voltage of DC motor)
b) Connect the DC motor to tag’s 2 and 3 of J3.
c) Connect the 26 pin FRC connector from the kit to the module and check the polarity of
the cable.
d) Connect the power supply to the kit and the module.
e) Enter the program.
f) Observe the motor. Bring the required changes in the program to bring about speed as
well as directional changes.
Program:
MNEMONICS
HEX
M. ADDRESS OPERAN COMMENTS
CODE OPCODE
D
2000H 3EH MVI A,80H CWR (8255)
2001H 80H
2002H D3H OUT 03H
2003H 03H
2004H 3EH MVI A,FFH
2005H FFH
2006H D3H OUT 02H PORT C=FF
2007H 02H
2008H 3EH MVI A,FFH
2009H 04H
200AH D3H OUT 02 PORT A=FF
200BH 00H
200CH EFH RST 5
Result:
We had successfully controlled the speed of a DC motor in clockwise and anti clock wise
direction and observe that motor is rotating in full, zero and half speed.
PROGRAM SR NO.: 7(b)
Aim: Write a program to interface steeper motor with 8085.
Procedure:
a) Initially set value of control word and address of control register, port A. (i.e. 80H, 2BH,
28H).
b) Set value of accumulator first as F9H, F5H, F6H and FAH for reverse rotation and then
observe rotation. To rotate in forward direction reverse the data set.
c) Call delay subroutine between each data set, in delay subroutine assign delay by using
nested method.
d) Connect the 8255 study card with 8085 by using 50 pin frc cable and steeper motor card
by using 24 pin for cables.
e) Connect the steeper motor with card and observe the step movement.
f) For fast movement change the data from 0000H to 0020H.
Program:
MNEMONICS
HEX
M. ADDRESS OPERAN COMMENTS
CODE OPCODE
D
2000H 3EH MVI A,80H Move immediate
2001H 80H
80 to Resister A
2002H D3H OUT 03H Display
2003H 03H
accumulator on the
port address
2004H 3EH MVI A,FAH Move immediate
2005H FAH
FA to Resister A
2006H D3H OUT 00H Display
2007H 00H
accumulator on the
port address
2008H CDH CALL 2030H(D) Call to Delay
2009H 30H
200AH 20H
200BH 3EH MVI A,F6H Move immediate
200CH F6H
00 to Resister A
200DH D3H OUT 00H Display
200EH 00H
accumulator on the
port address
200FH CDH CALL 2030H(D) Call to Delay
2010H 30H
2011H 20H
2012H 3EH MVI A,F5 Move immediate
2013H F5H
F5 to Resister A
2014H D3H OUT 00H Display
2015H 00H
accumulator on the
port address
2016H CDH CALL 2030H(D) Call to Delay
2017H 30H
2018H 20H
2019H 3EH MVI A,F9H Move immediate
201AH F9H
F9 to Resister A
201BH D3H OUT 00H Display
201CH 00H
accumulator on the
port address
201DH CDH CALL 2030H(D) Call to Delay
201EH 30H
201FH 20H
2020H C3H JMP 2004H(S) Jump
2021H 04H unconditionally to
2022H 20H
2004H
2023H 76H HLT Stop the program
2030H 11H LXI D,0000H Initialize seconds,
2031H 00H
minutes
2032H 00H
2033H CDH CALL 03BC Call to Delay
2034H BCh
2035H 03H
2036H C9H RET
Result:
We had successfully controlled the speed of a stepper motor in forward and reverse direction
and observe that motor is rotating in steps of 45 degrees.