Wednesday, August 31, 2011

Nokia 3315 / 3310 LCD interfacing with Microcontroller

    Displaying content on a normal alphanumeric display is very limited ,we have to be limited with the font size and we can't draw any graphics also. but convention Graphics lcd are really very expensive so here is the solution, you can use Nokia 3315 / 3310 monochrome  LCD to display your large font text and graphics . the reason behind using this LCD is ,it is really very cheap and can be powered with 3 volts supply. so it is really good for battery powered application.

Project Description 

       however you can use almost any microcontroller (with capability to work on 3v ) do display content on this LCD, may be that micro controller is PIC , AVR or MSP 430 , but in this demonstration we will be using Microchip PIC 18F458 Microcontroller.

    The software program for this project will be written in C with MPLAB IDE , This LCD has a resolution of 84x48 pixel.

Circuit Description

Circuit Diagram of  Nokia 3315/3310 interface with micro controller



Nokia: 3310/3315 LCD
About LCD:-
 
       Nokia 3315 / 3310 Graphical LCD uses PCD8544 Controller chip From Philips. It is a chip-on glass(COG) with  8 pin connector on the back side of the LCD . You can refer to its datasheet for more information about this controller. (CLICK HERE TO DOWNLOAD PCD8544 Controller DATA SHEET).we will discuss only few main points here for out project purpose.

       This LCD has 84x48 pixels , which mapped directly in the ram memory of the LCD, as shown in the figure blow

The typical example of RAM is shown in the figure blow, The vertical axes area addressed form 0 to 5 with eight bits for each address when combining with x axes, it can be represented as bank.
The horizontal axes are addressed form 0 to 83 and each bit will refer the corresponding pixel in X direction.

Addressing Mode  
 There are two type of addressing mode in this LCD
Vertical addressing Mode

        In vertical addressing Mode each write instruction will increment the address in Y direction and then return to starting address
Horizontal addressing
horizal addressing each wire instruction will increment the address of X direction and return to starting address

INSTRUCTION SET OF PCD8544



Serial Communication 
  
          The interface basically a serial peripheral interface (SPI). Serial bus protocol fro transmission of one byte is shown in figure blow

  A byte is sent to The LCD as follows:-
1:- Set SCE To GND
2.Set D/C to required state (Data or command)
3.Place a bit in SDIN line
4. Make high-to-low transition in CLK input.
5.Repeat step 3 and 4 for the remaining seven bits.


The initialization sequence of  LCD

  1. Pull SCE line to Ground to Enable The LCD.
  2 Set D/C pin low to send commands to the LCD.
  3. Write 0x21 Byte to LCD on the serial Bus. Here the LCD operates in Function set Command For extended instruction set.
  4. Write 0xC8 Byte to LCD on the serial Bus. This set the operating voltage (Vop) of the LCD.
  5. Write 0x06 Byte to LCD on the serial Bus. This set the temperature coeffcient.
  6.  Write 0x13 Byte To LCD on the serial Bus.  This set the bias system of the LCD. 
  7.  Write 0x20 Byte To LCD on the serial Bus.  This allow the LCD to operate in function set command with basic instruction.
  8. Write the 0x0C Byte to LCD on tee serial Bus. This set the display in normal mode.

The lcd initialization routine
     void lcdInit()
     {
          SCE=0;
          DC=0;
          spi(0x21);  
          spi(0xC8);
          spi(0x06);
          spi(0x13);
          spi(0x20);
          spi(0x0C);
     }

clearing the LCD,  after initialization pull SCE pin to ground to enable the LCD.Set D/C pin to high to send the data to the LCD.  Repeat  "write byte 0x00" operation to the LCD for 504 times (i.e. 54x48/8) thi will turn off all the pixels in the LCD.

Turn on all the pixels on the LCD, Pull SCE pin to ground to enable the LCD. Set DC pin to high to send the data  to LCD. Repeat "write byte 0xFF"  operation to the LCD. Repeat to LCD for 504 times. This will Turn on all the pixels in the LCD.

Display Character in LCD. the lookup table 'FONTLOOKUP' for the ASCII characters is included in the program. Pull the SCE pin to ground to enable the LCD. SEC DC pin to high to send the data to LCD write five bytes from 'FONTLOKUP[X][Y]  to the LCD.This will turn on the pixels for the ASCII character in the LCD.


Nokia 3315 LCD utilization logic analyzer view



Nokia 3315 LCD utilization logic analyzer view  

The following function are being used in the example program
spi  :- routine to wire the data to the LCD (using SPI module in PIC 18F)
lcdStr :- Routine to write a string to the LCD
lcdDec:- Routine to write the digit to the LCD
lcdDir :- Routine to write directly form the lookup table
gotoXy :- Routine to set X,Y points in LCD
delayMs :- Routine for ms delay.

Assembling the Circuit
  The circuit is very easy to understand. but  the only precaution which need to be taken care is soldering the  wire to the LCD is very complex job.and you can't supply more than 3 volts  , please not that 5 volts may blow up the LCD  My prototype image shown blow.

You can also use general purpose pcb to hold the lcd and have a burg strip on the back with a LED for back light .


Software 
 The software program is written in C with the help of MPLAB and Microchip C18 compiler 


Click here to Download the software source code and ready to run firmware 


if some body sill have any question please let me know




You May also like
Nokia 3315 LCD based Temperature meter

7 comments:

  1. Hi Gaurav,

    Is it possible for you to write a short tutorial on how to interface NOKIA 6280 LCD with PIC18F4550 to display a simple "Hello World" ?

    The only reference I could get is this:
    http://www.ivica-novakovic.from.hr/MotorCycle%20Computer%20Board%20with%20Nokia6280%20lcd-eng.htm

    The schematic used by the author:
    http://www.ivica-novakovic.from.hr/Picture/Pdf/Schematic-Lcd-Nokia6280.pdf

    The reason to use this LCD is the resolution which is 320x240 which is very good.

    I would be really very grateful to you for your support.

    Thanks in advance.
    Please reply.

    Regards,
    mahesh.

    ReplyDelete
  2. Hi Mahesh

    thank you for your comment that is very good lcd i will definitely do a tutorial

    do you have datasheet of Nokia6280 LCD controller

    ReplyDelete
  3. Thanks Gaurav,

    See if this helps:
    http://www.displayalliance.com/storage/1-spec-sheets/LS022Q8UX05_SPEC_with_IIS070131.pdf

    It's for a dual LCD model with almost same specs.

    I understand, without datasheet it is really hard to get the LCD work.

    I bought a Nokia 6280 compatible LCD for 200 rupees. On the back side, it has a printed serial number : LS022Q8UX03B. On search, it appears to be a SHARP LCD model. I did searched for the datasheet, but all that I can get is the above mentioned datasheet for LS022Q8UX05 which seems to be the closest match.

    I am on a tight schedule. In fact, today I was going to hook up the LCD to LPT port of my system and try to drive it. But, after I saw your web page, I felt optimistic about correctly interfacing it to PIC micro-controller.

    Please reply.

    Regards,
    mahesh.
    bytelogik@gmail.com

    ReplyDelete
  4. hello sir,
    i need same circuit with mcs pic to 89s52 or pic16f877,instead of 18f458 used here .pls post .
    thanks in advance

    ReplyDelete
  5. software is almost same for all the pic

    but for 89s52 you have to generate spi signal using software and have to use voltage level converter(using resistor network)
    because this lcd will work with around 3.6 v

    ReplyDelete
  6. hy...
    am using nokia3310 display..for my project called logic analyser...its displaying nothing when i give pulse
    from a t.v remote...so i checked whether its workin or not...i gave power supply
    its just displaying some lines for 2minutes. and disappearing..please help me....
    my mail id:tejarazz22@gmail.com

    ReplyDelete
    Replies
    1. if lcd display some data at least for while it means lcd is fine and properly initialized.

      i believe there is some bug in your code.

      Delete