Q. The limit switches in the system in question 1 is removed. The string is to be rotated for 1
minute to put all the clothes inside the house if there is rain or send the clothes out when
there is no rain. Write a program for the proper operation of the system.
Solution:
Main Program
START: IN 30H ; get input from rain detector
ANI 01H ; mask the other bits than sensor position
JZ END ; check if the cloth is in the rain
MVI A, 02H ; if yes put the clothes inside
OUT 40H
CALL DELAY ; time required to put the clothes inside
LABEL1: MVI A, 00H ; turn off the motor
OUT 40H
IN 30H ; check if it’s still raining
ANI 01H
JNZ LABEL1 ; if yes put the motor off
MVI A, 01H ; else rotate the string and put clothes out
OUT 40H
CALL DELAY ; time required to put clothes outside
END: MVI A, 00H ; turn off the motor
OUT 40H
JMP START ; repeat the task
Delay Subroutine
DELAY: MVI B, 78H ; factor to multiply to make 1 minute delay
LABEL2: LXI H, F69AH ; count for 0.5 second delay
LABEL3: DCX H
MOV A, L
ORA H
JNZ LABEL3
DCR B
JNZ LABEL2
RET
minute to put all the clothes inside the house if there is rain or send the clothes out when
there is no rain. Write a program for the proper operation of the system.
Solution:
Main Program
START: IN 30H ; get input from rain detector
ANI 01H ; mask the other bits than sensor position
JZ END ; check if the cloth is in the rain
MVI A, 02H ; if yes put the clothes inside
OUT 40H
CALL DELAY ; time required to put the clothes inside
LABEL1: MVI A, 00H ; turn off the motor
OUT 40H
IN 30H ; check if it’s still raining
ANI 01H
JNZ LABEL1 ; if yes put the motor off
MVI A, 01H ; else rotate the string and put clothes out
OUT 40H
CALL DELAY ; time required to put clothes outside
END: MVI A, 00H ; turn off the motor
OUT 40H
JMP START ; repeat the task
Delay Subroutine
DELAY: MVI B, 78H ; factor to multiply to make 1 minute delay
LABEL2: LXI H, F69AH ; count for 0.5 second delay
LABEL3: DCX H
MOV A, L
ORA H
JNZ LABEL3
DCR B
JNZ LABEL2
RET
Comments
Post a Comment