GROUP EVALUATION FORM Laboratory 5: Parallel Port Interfacing Group No: Section: LAB SCHEDULE: Group Members: DATE PERFORMED: 1. DATE SUBMITTED: 2. Exercises 3. Prog’g Problems 4. Teamwork (+pts) 5 EVALUATION GRADE: EVALUATION: (for lab instructor use only) Exercises (50%): Prog’g Problems (50%): Lab Performance (10%): Attendance (10%): LABORATORY NO. 5 Parallel Port Interfacing I. Objective To introduce parallel port of PC its internal registers and pin configurations. To understand the operations of basic I/O devices. To develop interface programs that will manipulate the I/O devices using parallel port. II. Components to be borrowed PC power cords (2) Keyboard Mouse Printer Cable Power supply Breadboard Connecting wires (13) I/O-01 module I/O-02 module III. Conceptual Framework The professor will provide this. IV. Procedure: Using LEDs 1. Connect I/O-01 module to DB25 connector. DB 25 25 GND 1 9 10 8 11 7 6 5 4 12 13 14 15 3 2 16 17 +5v LEDS CIRCUTRY I/O-01 MODULE 26 Note: Don’t forget to connect any of the pins 18 to 25 of DB25 and pin 1 of I/O-01 module to GND, and pin 26 to +5v. j.tio Lab5 2 PIN CONFIGURATION OF DB25: Pin No 2-9 10,11,12,13,15 1,14,16,17 18-25 1. 2. 3. 4. Description D0-D7 S6,S7,S5,S4,S3 C0,C1,C2,C3 GND Assemble the given program LAB5E1.asm (refer to attached file) using NASMIDE software. Compile and execute the program. Observe the output of the LEDs for each of the following inputs. Shade the circle that corresponds to LED being lit. Key pressed (Input) 1 0 8 LEDs output 5. Repeat steps number 2 and 3 considering the given program LAB5E2.asm. Observe the output of LEDs and illustrate the output. Screen Output 8 LEDs output Using 7-segment Display 6. Connect I/O-02 module to DB25 connector. DB 25 25 GND 1 9 17 8 16 7 6 5 4 15 14 13 12 3 2 11 10 +5v 7-SEGMENT DISPLAY CIRCUTRY I/O-02 MODULE 26 Note: Don’t forget to connect any of the pins 18 to 25 of DB25 and pin 1 of I/O-02 module to GND and +5v to pin 26 of I/O-02 module. j.tio Lab5 3 7. Assemble the program LAB5E3.asm. 8. Compile and execute the program. 9. Observe the output. Write your observation on the provided table. Key pressed 7-segment Screen Output 1 0 Any key V. Programming Problems: 1. Develop a program that will display the equivalent binary code (using the LED board) of the key being pressed. Key pressed (Input) 0 1 2 3 4 : : : E F 8 LEDs output : : : 2. Design a PC-based application that will automatically display the numbers from 00 to 99 into the 7segment display. 3. Design a PC-based application that will simulate a parking system having 10 parking slots. The system should indicate if the parking is full, which will be indicated by the 7-segment display as FULL (displaying 2 letters at a time). It should also provide the number of parking spaces occupied. Screen Output Customer wants to park/exit (P/E)? Customer wants to park/exit (P/E)? P Customer wants to park/exit (P/E)? P Customer wants to park/exit (P/E)? E *Customer wants to park/exit (P/E)? P 7 segment Output 00 01 02 01 FULL * Assume 10 slots occupied j.tio Lab5 4 4. Write a program that will display the following 8-LED patterns based on the switch pressed. Please refer to the conditions and connections below. Conditions: Switch Pressed 1 2 3 8-LED Pattern Alternate lights Running lights Blinking lights DB 25 25 GND 1 15 2 13 3 12 4 +5v 26 GND 1 SWITCHES CIRCUTRY I/O-01 MODULE DB 25 25 9 10 8 11 7 6 5 4 12 13 14 15 3 2 16 17 +5v j.tio LEDS CIRCUTRY I/O-01 MODULE 26 Lab5 5 ;NASM-IDE ASM Assistant Assembler Project File BITS 16 ;Set code generation to 16 bit mode ORG 0x0100 ;Set code start address to 0000h ; Filename: LAB5E1.asm ; LED Control ; Author: J. TIO [section .text] MAIN: jmp START DISP: mov ah,09h int 21h ret OFF: mov mov out jmp ON: mov mov out ;String Print int service al,00h dx, 378h dx, al MAIN ;All LEDs OFF al,0FFh dx, 378h dx, al ;All LEDs ON START: lea dx,[msg1] call DISP mov ah, 01h int 21h cmp al,'1' je ON cmp al,'0' je OFF END: mov al, 00h mov dx, 378h out dx, al mov ah, 4Ch int 21h ;Display message ;keyboard interrupt ;press 1 to ON ;press 0 to OFF ;OFF LEDs and motor ;End of program section .data msg1 db 13,10,'Press 1/0(press any key to exit): j.tio Lab5 ','$' 6 ; Information ; Program Title : Introduction to NASM ; External name : LAB5E2.COM ; ; ; Version Author Description bits 16 org 0x0100 : 1.1 : J. Tio : A simple example of ;parallel interfacing file programmed ;using NASM-IDE 1.5 and NASM 0.98.08. ; Set 16 bit code generation ; Set code start address to ; 100h (COM file) [section .text] MAIN: jmp START DISPLAY: lea dx,[msg1] mov ah,09h int $21 ret ; Jump to label 'START' ; ; ; ; DELAY: .NEXT: .NEXT2: END: mov int ret MOV CX, 01Fh MOV BX,0FFFFH NOP NOP NOP DEC BX JNZ .NEXT2 LOOP .NEXT RET ah, $4C $21 PATTERN: ;1st pattern mov dx,$378 mov al,$03 out dx,al call DELAY j.tio Subroutine program string print service no 09h interrupt 21h ;Delay program ;outer loop ;inner loop ;Define label 'END' ;service no =4ch ;return to calling ;set data port address ;set two LEDs ON ;output to data port ;call delay subroutine Lab5 7 ;2nd pattern mov dx,$378 mov al,$02 out dx,al call DELAY ;3rd pattern mov dx,$378 mov al,$01 out dx,al call DELAY ;4th pattern mov dx,$378 mov al,$00 out dx,al call DELAY ret START: call DISPLAY call PATTERN call END section .data msg1 ;set data port address ;set one LED = OFF, another LED=ON ;output to data port ;call delay subroutine ;set data port address ;set one LED = ON, another LED=OFF ;output to data port ;call delay subroutine ;set data port address ;set two LEDs = OFF ;output to data port ;call delay subroutine ; display message on screen ; display pattern ; end program db 13,10,Program running? ','$' ---------------------------------------------- ;NASM-IDE ASM Assistant Assembler Project File BITS 16 ;Set code generation to 16 bit mode ORG 0x0100 ;Set code start address to 0000h ; Filename: LAB5E3.asm ; 7-Segment Display Control ; Author: J. TIO [section .text] MAIN: jmp START DISP: mov ah,09h int 21h ret j.tio ;String Print int service Lab5 8 ON2: lea dx,[msg3] call DISP mov al,0F0h mov dx, 378h out dx, al jmp MAIN ;Display message lea dx,[msg2] call DISP mov al,0Fh mov dx, 378h out dx, al ;Display message ;2nd 7-seg ON ON1: START: lea dx,[msg1] call DISP ;1st 7-seg ON ;Display message mov ah, 01h int 21h ;keyboard interrupt cmp al,'1' je ON1 cmp al,'2' je ON2 ;press 1 to ON1 mov mov out mov int ;LEDs OFF ;press 2 to ON2 END: section msg1 db msg2 db msg3 db j.tio al, dx, dx, ah, 21h 00h 378h al 4Ch ;End of program .data 13,10,'Press 1/0: ','$' 13,10,'First 7-SEG ON...','$' 13,10,'Second 7-SEG ON...','$' Lab5 9