Uživatel:Saimbsak

Z MAM wiki

Přejít na: navigace, hledání

Semester project: LCD Display On Glass Interface

In this project the display is connected to an AVR AT2313 microcontroller.

Description

Liuid Crystal Display on Glass is the newest in LCD technology. The display's are very compact, it measures 55x27 mm and the height is only 2mm without LED backlight and 5.8mm with LED backlight. The display's can have different LED background light instead of only the green and blue of the normal LCD modules.There are 5 monochrome colors available: white, green/yellow, blue, red, amber and there is even a full color RGB background possible. The contrast of the display can be set with a command.

Soubor:Exp1.jpg

Soubor:Exp2.jpg

Soubor:Exp33.jpg

The display and the corresponding backlight are clipped together and inserted into a PCB and soldered. The display has a build-in character set of 248 european and japanese characters, in addition you can also define 8 characters. The integrated controller, the ST7036, has build in commands to control the display.

Hardware

For the ease of use i have designed a small PCB. The board has two rows of 20-pins socket connectors, in which the display can be inserted, it has also a resistor to limit the current through the background LEDs. For connection with the microcontroller the board has a 5x2-pin connector, so the board can easily connected to the STK500 board or to the AT2313 project board with a 10-pole flat cable. In this project the 4-mode is used so ther are only 4 datalines and 2 control lines.

Software

The software is made in assembler program code. It is made with the Studio4 program wich you can download for free from the Atmel website. Before you can send characters to the display, it has to be initialized. First you have to switch the display to the 4-bit mode.

Assembly code

.device AT90S2313

.include "2313def.inc"

.def buffer = r16

.def temp = r17

.def wt0 = r18

.def wt1 = r19

.def counter = r20

.CSEG ; start code segment

.ORG 0x00  ; set program counter to 0

rjmp main

nop

nop

nop

nop

nop

nop

Definition command lines

.equ E = PB6 ;E @ Pin PB7

.equ RS = PB7 ;RS @ Pin PB6

LCD commands

.equ clr_LCD = 0b00000001 ;clear display

.equ home_LCD = 0b00000010 ;home display

.equ entry_mode = 0b00000110 ;set Cursor

.equ on_LCD = 0b00001100 ;LCD on

.equ move_LCD = 0b00011000 ;move LCD

.equ set_LCD = 0b00101100 ;8 bits,2 lines,5x7dots

Subroutines LCD

LCD_inst: cbi PORTB,RS

rjmp LCD_write

LCD_data: sbi PORTB,RS

LCD_write: in temp,PORTB

push buffer

swap buffer

andi buffer,0x0f

or buffer,temp

out PORTB,buffer

sbi PORTB,E

rcall delay

cbi PORTB,E

pop buffer

andi buffer,0x0f

or buffer,temp

out PORTB,buffer

sbi PORTB,E

rcall delay

cbi PORTB,E

clr temp

out PORTB,temp ret

Subroutine delay

delay: ldi wt1,50 ;delay ~10ms @ 4mhz lus: dec wt0

brne lus

dec wt1

brne lus

ret

main: ldi temp,ramend

out spl,temp ;set lowbyte for sp

ser temp

out DDRB,temp

ldi ZL,low(Tabel_1*2)

ldi ZH,high(Tabel_1*2)

ldi counter,56

ldi buffer, 0b00101001 ;Function Set and Instruction Table Select

rcall LCD_inst

ldi buffer, 0b00011100 ;Bias Set

rcall LCD_inst

ldi buffer, 0b01010001 ;Power Control and contrast

rcall LCD_inst

ldi buffer, 0b01101100 ;Follower Control

rcall LCD_inst

ldi buffer, 0b01110111 ;Contrast Set

rcall LCD_inst

ldi buffer, 0b00001100 ;Display On/Off

rcall LCD_inst

ldi buffer, 0b00000001 ;Clear Display

rcall LCD_inst

ldi buffer, 0b00000110 ;Entry Mode Set

rcall LCD_inst

lees: lpm

mov buffer,r0

rcall LCD_data

inc ZL

dec counter

brne lees

loop: rjmp loop

Reference:

http://www.avrprojects.net/

Osobní nástroje