Objective: In this lab you will design a voltage level monitor. You use the Free
ID: 1716882 • Letter: O
Question
Objective: In this lab you will design a voltage level monitor. You use the Freescale microprocessor board as a platform for your design. You will write the code only in "Assembly language''. You need to finish this project in one lab session and present your design to the lab instructor or TA. Design: 1- Your code should continuously check the status of a voltage level in intervals of 0.5 second. 2- Acceptable variation of the voltage level is between 2 V and 4V. In this case LED5 should be on. 3- If the voltage jumps to any level above 4V or below 2V. A command should be sent to LED2 to turn it on as a warning indicator. LED5 should be off in this case. 4- Microprocessor continues monitoring of the level until it detects an acceptable level between 2 V and 4V again. Microprocessor then checks for another 10 second to see if the level stays in acceptable range during the 5 second period. In this case, the warning LED2 has to go off and the normal LED5 is turned on.Explanation / Answer
Water level programming using 8051
Program.
MOV P2,#11111111B // initiates P2 as sensor input
MOV P0,#11111111B // initiates P2 as the output port
MOV A,#00000000B
MAIN:ACALL SMPCK // checks the level of the sump tank
MOV A,P2 // moves the current status of P2 to A
CJNE A,#11110000B,LABEL1 // checks whether tank is full
SETB P0.1
SETB P0.2
SETB P0.3
SETB P0.4
CLR P0.0 // glows full level LED
SETB P0.5
LABEL1:MOV A,P2
CJNE A,#11111000B,LABEL2 // checks whether tank is 3/4
SETB P0.0
SETB P0.2
SETB P0.3
SETB P0.4
CLR P0.1 // glows 3/4 level LED
LABEL2:MOV A,P2
CJNE A,#11111100B,LABEL3 // checks whether tank is 1/2
SETB P0.0
SETB P0.1
SETB P0.3
SETB P0.4
CLR P0.2 // glows 1/2 level LED
LABEL3:MOV A,P2
CJNE A,#11111110B,LABEL4 // checks whether tank is 1/4
SETB P0.0
SETB P0.1
SETB P0.2
SETB P0.4
CLR P0.3 // glows 1/4 level LED
JB P0.6,LABEL4
CLR P0.5 // switches motor ON
LABEL4:MOV A,P2
CJNE A,#11111111B,MAIN // checks whether tank is empty
SETB P0.0
SETB P0.1
SETB P0.2
SETB P0.3
CLR P0.4 // glows EMPTY LED
JB P0.6,MAIN // checks whether sump is low
CLR P0.5 // switches motor ON
SJMP MAIN
SMPCK:JB P0.6,LABEL5 // checks whether sump is low
SETB P0.7 // extinguishes the sump low indicator LED
SJMP LABEL6
LABEL5:SETB P0.5 // switches the pump OFF
CLR P0.7 // glows sump low indicator LED
LABEL6:RET
END
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.