0% found this document useful (1 vote)
464 views13 pages

Experiment 3 Final

The document is a lab report for an experiment using EMU8086 to interface with virtual devices through ports. It describes exercises controlling a traffic light system using port 4, a stepper motor using port 7, and a robot using ports 9, 10, and 11. For the traffic light exercise, the group's code is modified to turn on only the green light for number 0. The stepper motor is observed to turn 8 times clockwise. The robot is seen to move randomly and turn lights on and off as commanded.

Uploaded by

hello87623
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
464 views13 pages

Experiment 3 Final

The document is a lab report for an experiment using EMU8086 to interface with virtual devices through ports. It describes exercises controlling a traffic light system using port 4, a stepper motor using port 7, and a robot using ports 9, 10, and 11. For the traffic light exercise, the group's code is modified to turn on only the green light for number 0. The stepper motor is observed to turn 8 times clockwise. The robot is seen to move randomly and turn lights on and off as commanded.

Uploaded by

hello87623
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 13

Group No: 1

GROUP EVALUATION FORM Laboratory 3: Interfacing with Ports using EMU8086 Section: EL1 Lab Schedule: Monday 6:00-9:00 Date Performed: February 7, 2010 Date Submitted: February 14, 2010 Exercises Prog Problems Teamwork Evaluation Grade

Group Members 1. De Jesus, Jayson 2. Orteza, JB 3. Tan, Howard 4. Tingjuy, Charles

EVALUATION: (for lab instructor only) Exercises (50%)

Programming Problems (50%)

LABORATORY NO. 3 Interfacing with Ports using EMU8086


I. Objective To understand the concept of interfacing the outside world using ports. To apply the port interfacing concepts using IO devices. II. Coponents to be borrowed PC power cords (2) Keyboard Mouse EMU8086 III. Conceptual Framework For this exercise, virtual devices will be used to understand the concept of interfacing with external devices using ports. These virtual devices are available in EMU8086 software. Discussion of each device is provided below: (source: Emu8086 Help Option) Devices are available from: Virtual Devices menu of the emulator. Traffic Lights - Port 4 (word) The traffic lights are controlled by sending data to I/O Port 4. There are 12 lamps: 4 green, 4 yellow, and 4 red. You can set the state of each lamp by setting its bit: 1 the lamp is turned on. 0 the lamp is turned off. Only 12 low bits of a word are used (0 to 11), last bits (12 to 15) are unused. For example: MOV AX, 0000001011110100b OUT 4, AX *For the output: Refer to the figure below

Stepper Motor Port 7 (byte) The Stepper Motor is controlled by sending data to I/O Port 7. Stepper Motor is electric motor that can be precisely controlled by signals from a computer. The motor turns through a precise angle each time it receives a signal. By varying the rate at which signal pulses are produced, the motor can be run at different speeds or turned through an exact angle and then stopped. This is a basic 3-phase stepper motor, it has 3 magnets controlled by bits 0, 1, and 2. Other bits (3..7) are unused.

When magnet is working it becomes red. The arrow in the left upper corner shows the direction of the last motor move. Green line is here just to see that it is really rotating. The motor can be half stepped by turning on pair of magnets, followed by another pair of magnets and in the end followed by a single magnet and so on. The best way to make full step is to make two half steps. Half step is equal to 11.25 degrees. Full step is equal to 22.5 degrees. The motor can be turned both clock-wise and counter-clock-wise. Robot The Robot is controlled by sending data I/O Port 9. First byte (Port 9) is a Command Register. Set values to this port to make robot do something. Supported Values: Deximal Value 0 1 2 3 4 Binary Value 00000000 00000001 00000010 00000011 00000100 Action Do nothing. Move Forward. Turn Left. Turn Right. Examine. Examines an object in front using sensor. When robot completes the task, result is sent to Data Register and Bit #0 of Status Register is set to 1. Switch On a Lamp. Switch Off a Lamp.

5 6

00000101 00000110

Second byte (Port 10) is a Data Register. This register is set after robot completes the Examine command: Decimal Value 255 0 7 8 Binary Value 11111111 00000000 00000111 00001000 Meaning Wall Nothing Switched-On Lamp Switched-Off Lamp

Third byte (Port 11) is a Status Register. Read values from this port to determine the state of the robot. Each bit has a specific property.

Bit Number Bit #0 Bit #1 Bit # 2

Description Zero when there is no new data in Data Register, one when there is new data in Data Register. Zero when robot is ready for next command, one when robot is busy doing some task. Zero when there is no error on last command execution, one when there is an error on command execution (when robot cannot complete the task: move, turn, examine, switch on/off lamp).

IV. Procedure: 1. Compile and execute TRAFFIC.asm code. 2. Give a short description on what is happening. ______________________________________________________________ ______________________________________________________________ ______________________________________________________________ ______________________________________________________________ 3. Make some changes so that only the number 0 green light is on, and write the code made. 4. Compile and execute STEPPER.asm. 5. Indicate what happens to the Stepper motor. How many times did it turn and what direction? ______________________________________________________________ ______________________________________________________________ ______________________________________________________________ ______________________________________________________________ 6. Compile and execute ROBOT.asm code. 7. What happens to the mobot? ______________________________________________________________ ______________________________________________________________ ______________________________________________________________ ______________________________________________________________ 8. When the bulb is lighted off and vice versa, what does the mobot do? ______________________________________________________________ ______________________________________________________________ ______________________________________________________________ ______________________________________________________________ V. Data and Results 2. Give a short description on what is happening.

There are 4 different situations happen at a time. We are asked to choose from 1 to 4. Each number corresponds to a traffic light off one side of the road. For example, if we choose 1, one side of the road will turn off and the other three will turn on. Same applies to the other inputs but with different traffic light. 3. Make some changes so that only the number 0 green light is on, and write the code made. MOV AX, 0000000000000001 OUT 4, AX 5. Indicate what happens to the Stepper motor. How many times did it turn and what direction? It turned 8 times and it rotated in clockwise direction. 7. What happens to the mobot? It moves randomly. We cannot predict where the mobot would go whether it goes up, down, left or right. It also stops and then walks. 8. When the bulb is lighted off and vice versa, what does the mobot do? When the bulb is off, the mobot turns it on and vice versa. VI. Programming Problems: 1. Consider a bridge that connects Lane 012 and Lane 678. A stepper motor controls the bridge. A clockwise rotation of the stepper motor closes the bridge and a counter clockwise rotation opens the bridge. The traffic light will denote if a vehicle can pass thru the bridge or not. A red light means the bridge is closed therefore vehicles cannot pass thru the bridge while a green light signifies bridge is open. Write as assembly code that will simulate this scenario. 2. Write an assembly code that will control the robot to turn OFF all lamps. Assume there are only three lamps on the arena. Obstacles must be present such as wall. Answer Codes: #1.
#MAKE_BIN# #CS=500# #ip=0# MAIN: JMP START DISP: LEA DX,[MSG] MOV AH,9 INT 21H

RET ;-----------------------------------------------; first retracion mode ;Green light, bridge down ONE: MOV AX,CS MOV DS,AX MOV SI,0 MOV CX,5 ACT1: MOV AL,datCCW[SI] OUT 7,AL ADD SI,1 LOOP ACT1 MOV AX,0104H OUT 4,AX CALL MAIN ;------------------------------------------------;second retraction mode ;red light bridge up TWO: MOV AX,0041H OUT 4,AX MOV AX,CS MOV DS,AX MOV SI,0 MOV CX,4 WHILE: MOV BL,0 LOOP WHILE MOV CX,5 ACT2: MOV AL,datCW[SI] OUT 7,AL INC SI LOOP ACT2 CALL MAIN ;-----------------------------------------------;main command line START: CALL DISP MOV AH,1 INT 21H CMP AL,'1'

JE ONE CMP AL,'2' JE TWO END: MOV AH,4CH INT 21H ;motor and light actions datCW db 001b db 011b db 110b db 000b datCCW db 100b db 110b db 011b db 000b ; initial display MSG DB 13,19,'<Press any key to exit>',13,10, 'Enter Bridge Retraction Signal(1 or 2?): $'

#2. #MAKE_BIN# #CS = 500# #DS = 500# #SS = 500# #SP = FFFF# #IP = 0# R_PORT EQU 9 eternal_loop: CALL WAIT_ROBOT MOV AL, 4 OUT R_PORT, AL CALL WAIT_EXAM IN AL, R_PORT + 1 CMP AL, 0 JE cont CMP AL, 255 JE cont

CMP AL, 7 JNE lamp_off CALL SWITCH_OFF_LAMP JMP cont lamp_off: NOP cont: CALL RANDOM_TURN CALL WAIT_ROBOT MOV AL, 1 OUT R_PORT, AL CALL WAIT_ROBOT MOV AL, 1 OUT R_PORT, AL JMP eternal_loop WAIT_ROBOT PROC busy: IN AL, R_PORT+2 TEST AL, 00000010b JNZ busy RET WAIT_ROBOT ENDP WAIT_EXAM PROC busy2: IN AL, R_PORT+2 TEST AL, 00000001b JZ busy2 SWITCH_OFF_LAMP PROC MOV AL, 6 OUT R_PORT, AL RET SWITCH_OFF_LAMP ENDP RANDOM_TURN PROC MOV AH, 0 INT 1Ah

XOR DH, DL XOR CH, CL XOR CH, DH TEST CH, 2 JZ no_turn TEST CH, 1 JNZ turn_right MOV AL, 2 OUT R_PORT, AL RET turn_right: MOV AL, 3 OUT R_PORT, AL no_turn: RET RANDOM_TURN ENDP

VII. Analysis and Conclusion


Charles Tingjuy From the given experiment, it is obviously understood that Emu8086 assembler is a whole new and more fun environment for the world of assembly programming. It is with direct association to the microprocessor 8086 as it emulates in a software manner the given codes in the command module. The assembler also shows what could possibly happen in robots, displays, motors, etc. when a given code is executed and it is shown virtually from the emulators virtual devices tab. For the first task, the concept of traffic lights in intersecting lanes is being executed where each traffic light has 3 bits where each bit represents a red, yellow and a green light respectively where the binary code 1 means that the corresponding color is lit up. In total of 4 traffic lights means there are 12 lights in all resulting to 12 bits for the system. For the stepper motor, the concept from the previous task is done where 3 bits represent the way the motor is turned either in a clockwise rotation or vice versa. For the robot, as observed from the given codes, its motion depends on what it senses. If there is a wall right in front of him, he turns to another direction. If a closed or lighted bulb is in front of him, he lights the bulb or closes it respectively. Putting all these three together, with some codes will result to a cool daily applied thing. For example, combining the stepper motor for a draw bridge and the traffic light will result to a traffic system for a river draw bridge. For the robot, well, the only task assigned was to close all lighted bulbs. JB Orteza Experiment 3 allows us to fully understand how the EMU8086 works. It allows us to emulate a given program. It shows virtual devices such as robots, motors and other devices. For the first part of the experiment, we were asked to run a traffic light. Each light corresponds to a certain arrangement of 1s and 0s in the 12 low bits which enables us to control and manipulate the order of the traffic lights. As a result, only one traffic light can be turned off when emulated. For the second part of the experiment, we were asked to run the stepper motor file. It is the same thing as the first one wherein each rotation is represented by 3 bit-bode. The stepper motor can turn either in a clockwise or counter clockwise rotation. For the last part, the mobot acts based on its program. In the robot file, the mobot actually moves randomly. It either stops or moves and can either turn on or off a light bulb. In the practice problem, we have been able to program the mobot wherein when it senses a turned-on light bulb, the mobot will turn it off. Jayson De Jesus In this experiment, we are to use different virtual devices each differ in characteristic or functions. One of which is the traffic light. As in real traffic light, in such, we are to enter 4 inputs ranging from 1-4 to have an output. We are to manipulate 12 bits that are shown through 1's and

0's. There are different functions so as to enter number from 1-12 such as performing a green light if such a number 1 is inputted where as the logic 1 would represent different numbers. The same operation will function for the red light whereas if we chose a number from 1-12 to be green light, for example 5, we are suppose to use a different number in assigning for the red light. In this function, there is a motor that would function for a certain number of time where the input changes from time to time.

This kind of experiment lets us practice in creating algorithm for interfacing. If we are to understand the basics of these programming, we are to let our mind be exercised in creating algorithms. In the future, we are to make different interfaces which could help us in our income in our life.

Howard Tan Our group has used three virtual devices in this experiment. The three virtual devices have different characteristics and functions. The traffic light is a device that is used to simulate the real traffic light. The output is dependent on the input values. In this part of the experiment, we were asked to input values 1 to 4in which these values have corresponding functions when inputted. The stepper motor is a device programmed in which it has 4 functions but only one function at a time is performed. The four functions are clockwise (CW), counter-clockwise (CCW), clockwise full step (CW_FS), and counter-clockwise full step (CCW_FS). The robot is a device that functions just like an ordinary machine. It executes a specific program that is programmed in it.

We were able to understand the concept of interfacing the outside world using ports. We were also able to apply the port interfacing concepts using IO devices. The objectives of this experiment were met.

You might also like