View the step-by-step solution to:

LEDs DAC lcd_cmd lcd_st lcd_wr lcd_rd ORG equ equ equ equ equ equ p1 0600h 0800h 0801h 0802h 0803h ;LEDs on port 1 ;DAC mapped at address 0600h...

8051 Laboratory Series

COURSEWORK – Digital Volt Meter (DVM) Display

1. Lab 7 – Task 5 was to create the assembly code to make a Digital Volt Meter that displays the message and the correct voltage on the LCD. Once you managed to display the hex value for the conversion you were required to convert this to an actual voltage reading in decimal.

255 = 5volts
1 bit = 5/255 = 19.6 mV.

The display should be accurate to +/- 2 mV
(7 Marks)

2. The LEDs should also display the rounded percentage of the full scale output. Since there are 8 LEDs each one represents 12.5%. However, since we want the rounded percentage the LED on the LSB should be illuminated if the voltage is above 6.25% (312mV) and the next LED should illuminated if the voltage is above 18.75% (937mV) etc….
(3 Marks)

3. Alter the brightness of the most significant illuminated LED to represent voltages between the ranges so that if the value is half way between the range then the LED should be 50% brightness. This can be achieved by using Pulse Width Modulation (PWM) ie. Turn the LED ON for 50% of the time and OFF for 50% of the time will.
(3 Marks)

4. The code should set the RS232 serial port to 19200 baud rate and output the voltage value so that it is displayed on hyperterminal. The display should be refreshed every 100ms
(3 Marks)

5. Create FLOWCHARTS for the above.
(4 Marks)

LEDs equ p1 ;LEDs on port 1 DAC equ 0600h ;DAC mapped at address 0600h lcd_cmd equ 0800h ;Write COMMAND reg address 0800h lcd_st equ 0801h ;Read STATUS reg address 0801h lcd_wr equ 0802h ;Write DATA reg address 0802h lcd_rd equ 0803h ;Read DATA reg address 0803h ORG 8100H ;start address start: mov dptr,#DAC ;load dptr address of DAC mov R7,#80h ;initialise Event mov r6,#0 ;initialise DAC value acall delay nxtbit: xrl a,R7 ;Ex-OR DAC value with Event movx @dptr,A ;Output DAC value jb P3.5,keep ;if comparator +ve keep set bit acall delay xrl a,R7 ;else reset bit keep: xch a,R7 ;R7?A (move R7 to A so we can rotate it) clr c ;make sure we put zero in MSB rrc a ;Rotate R7 right through carry xch a,R7 ;R7?A (mov A back to R7 & restore A) jnc nxtbit ; repeat nxtbit until all bit done cpl a ;invert Dac Value mov LEDs,a ;write Dac Value to LEDs sjmp start ;Go back and do it again delay: mov r0,10 djnz r0,$ ;repeat this line 255 times ret ;end off sending voltage to LEDs DVM: mov P2, #(lcd_cmd SHR 8) ;load P2 with high address mov R0, #(lcd_cmd AND 255) ;load R0 with command reg addr mov R7, #01h ;set LCD position, line=1, char=1 mov dptr, #mesg1 ;point to mesg1 acall wr_string ;write mesg1 to LCD mov R7, #41h ;set LCD position, line= 2, char=1 mov dptr, #mesg2 ;point to mesg2 acall wr_string ;write mesg2 to LCD mov R7,#50h ;set LCD position line=2, char=1 mov dptr,#LEDs ;value of LEDs acall delay acall print_hex4 acall wr_string ;write value of LEDs to LCD stop: ajmp stop ;soft halt wr_string: acall lcd_busy ;wait until LCD not busy clr a mov a, R7 ;get LCD position orl a, #080h ;msb set for LCD RAM address movx @R0, a ;write lcd_cmd to set line & char nxt_char: acall lcd_busy ;wait until LCD not busy clr a movc a, @a+dptr
Background image of page 1
inc dptr ;point to next byte in string jz str_end ;if 0 then end of string mov R1, #(lcd_wr AND 255) ;Load R1 with wr_data address movx @R1, a ;Write char to LCD sjmp nxt_char ;get next char in string str_end: ret lcd_busy: mov R1, #(lcd_st AND 255) ;Load R1 with status address movx a, @R1 ;read LCD status jb acc.7, lcd_busy ;keep checking until busy bit clear ret mesg1: db "DVM Prog ",0 mesg2: db "Voltage = ",0 ;sending mesg1 and 2 to LCD print_hex4: PUSH ACC SWAP A ACALL put_nibble4 POP ACC put_nibble4: ANL A, #0Fh ADD A, #-10 ;processor cannot directly compare to a ; constant so we'll use subtraction instead JNC phex_n ADD A, #7 phex_n: ADD A, #'0'+10 ;+10 is added since storing a value before ;comparison and restoring it would be less effective char_from_Acc: AJMP char_from_Acc end
Background image of page 2

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question