Showing posts with label lcd installation. Show all posts
Showing posts with label lcd installation. Show all posts

Nokia 3310 LCD Interfacing

In this tutorial we will interface Nokia 3310 LCD with AT89C51.The Nokia 3310 LCD is based on a PCD8544 48x84 pixels matrix LCD controller.

Pin Diagram

Circuit Diagram

NOTE:Nokia 3310 LCD works on voltage level of 3.3v.To get this voltage level 10K resistor array, LED, diodes are used.

Few details

Display Data RAM (DDRAM)

The DDRAM is a 48x84 bit static RAM which stores the display data. The RAM is divided into six banks of 84 bytes (6x8x84 bits). During RAM access, data is transferred to the RAM through the serial interface. There is a direct correspondence between the X-address and the column output number.

Addressing

The columns are addressed by the address pointer. The address ranges are:

X 0 to 83 (1010011)

Y 0 to 5 (101)

Addresses outside these ranges are not allowed.

Horizontal addressing mode:

In the horizontal addressing mode, the X address increments after each byte. After the last X address (X = 83), X wraps around to 0 and Y increments to address the next row. After the very last address (X = 83 and Y = 5), the address pointers wrap around to address (X = 0 and Y = 0).

Lcd command list

21H: Activate Chip and H=1.

90H: Set Vop voltage (contrast)

13H: Adjust voltage bias.

20H: Horizontal addressing and H=0

09H: Activate all segments.

08H: Blank the Display.

0CH: Display Normal.

0DH: Inverse video mode

Y-ram address: 40H or (y and 07H)

X-ram address: 80H or (y and 7FH)

Serial Bus Protocol

Serial interface maximum 4.0 Mbits/s

The MSB of a byte is transmitted first.

The serial interface is initialized when SCE is HIGH. In this state, SCLK clock pulses have no effect and no power is consumed by the serial interface.

A negative edge on SCE enables the serial interface and indicates the start of a data transmission.

SDIN is sampled at the positive edge of SCLK. The level of the D/C signal is read during the last bit of data byte.

Convert BMP to HEX

1. Create bitmap image using MS Paint.

2. Go to Image/Attribute option

Set width: 88 and height: 48

Select unit: Pixels color: Black and white

3. Invert color

4. Rotate 270 degree.

5. Save as image.bmp

6. In command prompt go to directory where z_bmptohex.exe is saved.

7. In command prompt type z_bmptohex image.bmp

8. You will see that image_bmp.inc file is created having hex array of [88] [6]

9. Open image_bmp.inc file in notepad and delete first four rows of array so that you get [84] [6] matrix.

10. Copy this array and convert this file according to your assembler syntax and paste into your main program code.

Source code : Nok3310_code.asm

Output

Interfacing Alphanumeric LCD

This page will let you learn a very easy tutorial on interfacing alphanumeric LCD.I opted for interfacing LCD with parallel port using visual basic 6 programming.With ease of programming in graphical user interface environment and its event driven nature makes this project more innovative.Working with DLL files in visual basic is easy as compared to C++ for programming parallel port.Before staring with Visual Basic 6 programming one should be clear with the concepts of the parallel port.Refer this link Parallel port tutorial
Lcd used here has HD44780u dot matrix lcd controller.

Connection Diagram:

Caution:Make sure that 5V and GND lines are properly connected otherwise you may end up in damaging parallel port.

If you want backlight than connect pin 15 of LCD to 5V and pin 16 of LCD to GND. By adjusting 10k resistor make pin 3 of LCD at 0V. If connection are proper you will see this after power on.

LCD Video

Pin Information of LCD:

Algorithm to send data to LCD:

1.Make R/W low

2.Make RS=0 ;if data byte is command

RS=1 ;if data byte is data (ASCII value)

3.Place data byte on data register

4.Pulse E (HIGH to LOW)

5.Repeat the steps to send another data byte

LCD Initialization:

This is the pit fall for beginners.Proper working of LCD depend on the how the LCD is initialized. We have to send few command bytes to initialize the lcd. Simple steps to initialize the LCD

1.Specify function set:

Send 38H for 8-bit,double line and 5x7 dot character format.

2.Display On-Off control:

Send 0FH for display and blink cursor on.

3.Entry mode set:

Send 06H for cursor in increment position and shift is invisible.

4. Clear display:

Send 01H to clear display and return cursor to home position.


NOTE:One must refer the datasheet of LCD to get the proper time delay and required sequence.

Major hurdle in accessing parallel port in Windows Xp is the knowledge of using inpout32 files.

Download : Driver files

Now save inpout32.dll and port.dll in system32 folder in windows directory.We will use certain subroutine provided by these dll files in our VB6 code.Open new project in VB6 and create the form as shown below.

Set the max length of two text boxes to 16.Create "Start" and "Clear" command button.Add visual basic code to form.

Visual Basic Code

Dim data As Variant

Private Sub Clear_Click()
LowRs
Out Val(&H378), Val(1) ' function to send data to parallel port
Enable
txtlcd1.Text = " " ' line 1 for LCD
txtlcd2.Text = " " ' line 2 for LCD
End Sub

Private Sub Start_Click()
Out Val(&H37A), Val(Inp(&H37A) And &HDF)
lcd_int
LCDWriteString txtlcd1.Text
next_line ' function to set cursor to second line
LCDWriteString txtlcd2.Text
End Sub

Sub LowRs()
Out Val(&H37A), Val(Inp(&H37A) Or &H8) ' Rs Low
End Sub


Sub LowEn()
Out Val(&H37A), Val(Inp(&H37A) Or &H1) ' En Low
End Sub

Sub HighRs()
Out Val(&H37A), Val(Inp(&H37A) And &HF7) ' Rs High
End Sub

Sub HighEn()
Out Val(&H37A), Val(Inp(&H37A) And &HFE) ' En High
End Sub

Sub lcd_write(data%)
HighRs
Out Val(&H378), Val(data)
Enable
End Sub

Sub next_line()
LowRs
Out Val(&H378), Val(&HC0)
Enable
End Sub


Sub lcd_int() 'subroutine to initialize LCD
LowRs
Out Val(&H378), Val(&H38)
Enable
LowRs
Out Val(&H378), Val(&HC)
Enable
LowRs
Out Val(&H378), Val(&H6)
Enable
LowRs
Out Val(&H378), Val(&H1)
Enable
End Sub


Sub Enable()
DELAYUS 20000
HighEn
DELAYUS 2000
LowEn
DELAYUS 2000
End Sub

' function to send ASCII character one by one to LCD
Public Sub LCDWriteString(ByVal OutStr As String)
Dim i As Integer 'write a string to LCD
For i = 1 To Len(OutStr)
lcd_write (Abs(Asc(Mid(OutStr, i, 1))))
Next i
End Sub

Now go to Project>Add Module .Select inpout4.bas and port.bas

Subroutine Out Val (&address),Val(data) and DELAYUS 2000 is available in inpout4.bas and port.bas respectively.

Running the Program:

1.Press F5 to run the program

2.Write the text you want to display on the LCD in the textboxes

3.Click "Start" command button.

4.You will see that the same text appears on LCD as shown in the textboxes.

5.To send other text click "Clear" command button and repeat the same procedure.

 
Mobile Phones Blog | Features,Concepts,Applications and Prices © 2012 | Designed by Cheap TVS, in collaboration with Vegan Breakfast, Royalty Free Images and Live Cricket Score