1 / 18

[ Lab11] Character LCM

[ Lab11] Character LCM. Deploy LCM Example Exercise. Character LCM. In this lecture, we use YJD1602A-1 as LCD module to display 16 characters, 2 lines information . Character LCM (cont.). Character LCM (cont.). YJD1602A-1 data sheet 4-bits or 8-bits interface avaliable

lucus
Download Presentation

[ Lab11] Character LCM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. [Lab11] Character LCM • Deploy LCM • Example • Exercise

  2. Character LCM • In this lecture, we use YJD1602A-1 as LCD module to display 16 characters, 2 lines information.

  3. Character LCM (cont.)

  4. Character LCM (cont.) • YJD1602A-1 data sheet • 4-bits or 8-bits interface avaliable • Power supply: 5V±10%

  5. Character LCM (cont.) • Vss : Connect to GND. • VDD: Connect to P9_7, +5V from BBIO. • V0: For adjusting the contrast. Connect to GND. • RS: Register Select. Connect to P8_12, control by program. • R/W: Read from LCM or write to LCM. Connect to GND for write only.

  6. Character LCM (cont.) • E: Enable Signal Signal, Connect to P8_14, control by program. • DB0-DB3: Data bus used in 8 bits transfer, did not use in this lecture. • DB4-DB7: Data bus for both 4 and 8 bits transfer. Connect to P8_16, P8_18, P8_20, P8_22. • BLA and K: Power for BackLight. A for +5V and K for GND.

  7. Character LCM (cont.) • We are going to implement functions Including: • lcdcommand(str) for giving instructions to LCM • lcdprint(str) for giving string to LCM. • setup() for initial setting. • loop() for discribe main function’s action control.

  8. Character LCM (cont.) • Example: • Show a string and Beaglebone uptime on the LCM.

  9. Character LCM (cont.) Source code: from bbio import * from datetime import timedelta import time import datetime import os import sys usleep = lambda x : time.sleep(x/1000000.0) #generate a microsecond delay iomap = [GPIO1_12, GPIO0_26, GPIO1_5, GPIO1_31, GPIO2_1, GPIO1_14]

  10. Character LCM (cont.) def lcdcommand(str) : digitalWrite(iomap[1], 1) usleep(500) digitalWrite(iomap[0], 0) iteration = 0 for idr in str: digitalWrite(iomap[iteration+2], int(idr)) iteration = iteration + 1 if iteration == 4: iteration = 0 usleep(100) digitalWrite(iomap[1], LOW) usleep(100) digitalWrite(iomap[1], HIGH) usleep(500) return

  11. Character LCM (cont.) def lcdprint(str) : for char in str: bitmap = bin (ord(char)) [2:].zfill(8) digitalWrite(iomap[1], 1) usleep(20) digitalWrite(iomap[0], 1) iteration = 0 for idr in bitmap: digitalWrite(iomap[iteration+2], int(idr)) iteration+= 1 if iteration == 4: iteration = 0; usleep(20) digitalWrite(iomap[1], LOW) usleep(20) digitalWrite(iomap[1], HIGH) usleep(20) return

  12. Character LCM (cont.) def setup(): sys.stdout.write(“Python YJD1602A-1 LCD Driver”) sys.stdout.write(‘\n’) pinMode(iomap[0], OUTPUT) pinMode(iomap[1], OUTPUT) pinMode(iomap[2], OUTPUT) pinMode(iomap[3], OUTPUT) pinMode(iomap[4], OUTPUT) pinMode(iomap[5], OUTPUT) sys.stdout.write(“Setting Up Screen”) sys.stdout.write(‘\n’) lcdcommand(‘0011’) #Initialization Sequence lcdcommand(‘0011’) #Initialization Sequence lcdcommand(‘0011’) #Initialization Sequence lcdcommand(‘0010’) #4BIT Mode

  13. Character LCM (cont.) lcdcommand(‘00000001’) # Reset lcdcommand(‘00001100’) # Display On sys.stdout.write(“Transferring LCD Control to main loop”) sys.stdout.write(‘\n’) sys.stdout.write(“Process PID: “) sys.stdout.write(str(os.getpid())) sys.stdout.write(‘\n’)

  14. Character LCM (cont.) def loop(): with open('/proc/uptime', 'r') as f: uptime_seconds = float(f.readline().split()[0]) uptime_string = str(datetime.timedelta(seconds = uptime_seconds)) pid = str(os.getpid()) lcdcommand('10000000') #upper line display lcdprint("B-Bone Uptime") lcdcommand('11000000') #lower line display lcdprint(uptime_string) usleep(1000) #1ms delay run(setup,loop)

  15. Character LCM (cont.)

  16. Character LCM (cont.) • Exercise: • Show your student ID and “exercise11” on each line.

  17. Pin Configuration

  18. END

More Related