Tuesday, September 20, 2022

Graphical LCD interface with LPC2148


 



The graphical LCD used in this experiment is Winstar’s WDG0151 -TMI module, which is a 128×64 pixel monochromatic display. It uses two Neotic display controller chips: NT7108C and NT7107C, which are compatible with Samsung KS0108B and KS0107B controllers . The KS0108B (or NT7108C) is a dot matrix LCD segment driver with 64 channel output, and therefore, the WDG0151 module contains two sets of it to drive 128 segments. On the other hand, the KS0107B (or NT7107C) is a 64 -channel common driver which generates the timing signal to control the two KS0108B segment drivers. The KS0108B and KS0107B are very popular controllers and have made their way into many graphical LCDs. The internal block diagram of the

WDG0151 GLCD module is shown below.

The NT1707C drives the 64 display lines, COM1 – COM64. The first NT7108C drives the left half segments (SEG1 to SEG64) and the second one drives the right half segments (SEG65 to SEG128) of the display. The two halves of the display can be individually accessed through th e chip select pins (CS1 and CS2) of the two NT7108C drivers. Each half consists of 8 horizontal pages (0 -7) which are 8 bits (1 byte) high. This is illustrated in the drawing below.

Starting from page 0 on the left half (/CS1 = 0) if you transmit one data byte, it will appear on the first column of page 0. If you repeat this 64 times, then switch to the second half, and repeat until 128th position is reached, the first 8 display lines will be plotted. The next 8 lines can be plotted similarly by switching to page address 1.The total amount of bytes needed for a complete display frame (128×64 pixels) is, therefore, 2 * 64 pixels * 8 bits = 1024 bytes.




Source Code:

#include <LPC214X.H>

#define CS2 0

#define CS1 1

#define RS 4

#define RW 5

#define EN 6

#define RST 7

extern const char MY_LOGO[];

unsigned char D0;

unsigned char CMD[] = {0x3e,0xc0,0xb8,0x40,0x3f};

unsigned char i;

void GLCD_Init(unsigned long *, unsigned char);

void GLCD_Page(unsigned char);

void GLCD_Cmd (unsigned long *, unsigned char, unsigned char);

void GLCD_Data (unsigned long *, unsigned char, unsigned char);

void GLCD_Draw (unsigned long *GLCDPort, unsigned char Datt, const char *Base);

void Delay();


const char MY_LOGO[1024] = {

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,128,128,128,128,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  3,  3,  3,  3,255, 

 255,255,255,255,  3,  3,  3,  3,  3,  1,  0,  0,252,252,252,248, 

  24, 28, 12, 12, 12,  0,  0,224,240,248,248,124,108,108,108,108, 

 108,124,120,120,112,  0,  0,  0,248,252,252,252,248, 24, 12, 12, 

  12, 12,252,252,248,248,  0,  0,  0,  0,240,248,248,252, 28, 12, 

  12, 12,  8, 24,255,255,255,255,  0,  0,  0, 12, 28,124,252,240, 

 224,192,128,192,240,248,124, 60, 28,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1, 

   3,  3,  3,  1,  0,  0,  0,  0,  0,  0,  0,  0,  3,  3,  3,  3, 

   0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  3,  3,  3,  3,  3,  3, 

   3,  3,  3,  3,  0,  0,  0,  0,  1,  3,  3,  3,  1,  0,  0,  0, 

   0,  0,  3,  3,  3,  3,  0,  0,  0,  0,  1,  1,  3,  3,  3,  3, 

   3,  3,  3,  1,  1,  3,  3,  3,  0,  0,  0,  0,  0,  0,  0, 25, 

  31, 31, 15, 15,  3,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,192,224,240,240,112, 

  56, 24, 24, 24, 24, 24, 24, 24, 48, 16,  0,  0,  0,128,128,192, 

 192,192,192,192,192,192,192,192,192,128,128,  0,  0,  0,  0,128, 

 128,192,192,192,192,192,192,192,128,248,248,248,248,  0,  0,  0, 

   0,216,216,216,216,  0,  0,  0,  0,192,192,192,192,128,192,192, 

 192,192,192,192,192,192,128,  0,  0,  0,  0,128,192,192,192, 64, 

  64, 64,192,192,192,192,192,192,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  7, 15, 31, 31, 28, 

  56, 56, 48, 48, 48, 48, 48, 48, 24, 24,  0,  0,  6, 15, 31, 31, 

  57, 48, 48, 48, 48, 48, 48, 61, 31, 31, 15,  7,  0,  0,  6, 31, 

  31, 63, 57, 48, 48, 48, 48, 24, 24, 31, 63, 63, 63,  0,  0,  0, 

   0, 63, 63, 63, 63,  0,  0,  0,  0, 31, 63, 63, 63,  1,  0,  0, 

   0,  0,  0, 31, 63, 63, 63,  0,  0,  0,232,255,255,255,190,188, 

 188,188,190,183,247,243,241, 96,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1, 

   1,  1,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 

   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0 

 };

int main()

{

PINSEL0 = 0;

PINSEL1 = 0;

IODIR0 = 0x0000FFFF;

GLCD_Init (&IO0PIN, 8);

while(1)

{

Delay(10);Delay(10);Delay(10);Delay(10);

GLCD_Draw(&IO0PIN, 8,MY_LOGO);

}

}

void GLCD_Init(unsigned long *GLCDPort, unsigned char Datt)

{

D0 = Datt;

IOPIN0 = 0;

IOSET0 = 1 << RST;

Delay();

IOCLR0 = 1 << RST;

Delay();

IOSET0 = 1 << RST;

GLCD_Page(1);

for(i=0;i<5;i++)

{

GLCD_Cmd(GLCDPort, D0, CMD[i]);

}

GLCD_Page(0);

for(i=0;i<5;i++)

{

GLCD_Cmd(GLCDPort, D0, CMD[i]);

}

}

void GLCD_Page(unsigned char PagE)

{

if (PagE)

{

IOCLR0 = 1 << CS1;

IOSET0 = 1 << CS2;

}

else


{

IOCLR0 = 1 << CS2;

IOSET0 = 1 << CS1;

}

}

void GLCD_Cmd (unsigned long *GLCDPort, unsigned char Datt, unsigned char c)

{

D0 = Datt;

if(c & 0x80) IOSET0 = 1 << (D0+7); else IOCLR0 = 1 << (D0+7);

if(c & 0x40) IOSET0 = 1 << (D0+6); else IOCLR0 = 1 << (D0+6);

if(c & 0x20) IOSET0 = 1 << (D0+5); else IOCLR0 = 1 << (D0+5);

if(c & 0x10) IOSET0 = 1 << (D0+4); else IOCLR0 = 1 << (D0+4);

if(c & 0x08) IOSET0 = 1 << (D0+3); else IOCLR0 = 1 << (D0+3);

if(c & 0x04) IOSET0 = 1 << (D0+2); else IOCLR0 = 1 << (D0+2);

if(c & 0x02) IOSET0 = 1 << (D0+1); else IOCLR0 = 1 << (D0+1);

if(c & 0x01) IOSET0 = 1 << (D0); else IOCLR0 = 1 << (D0);

IOCLR0 = 1 << RS;

IOCLR0 = 1 << RW;

IOSET0 = 1 << EN;

Delay();

IOCLR0 = 1 << EN;

}

void GLCD_Data (unsigned long *GLCDPort, unsigned char Datt, unsigned char c)

{

D0 = Datt;

if(c & 0x80) IOSET0 = 1 << (D0+7); else IOCLR0 = 1 << (D0+7);

if(c & 0x40) IOSET0 = 1 << (D0+6); else IOCLR0 = 1 << (D0+6);

if(c & 0x20) IOSET0 = 1 << (D0+5); else IOCLR0 = 1 << (D0+5);

if(c & 0x10) IOSET0 = 1 << (D0+4); else IOCLR0 = 1 << (D0+4);

if(c & 0x08) IOSET0 = 1 << (D0+3); else IOCLR0 = 1 << (D0+3);

if(c & 0x04) IOSET0 = 1 << (D0+2); else IOCLR0 = 1 << (D0+2);

if(c & 0x02) IOSET0 = 1 << (D0+1); else IOCLR0 = 1 << (D0+1);

if(c & 0x01) IOSET0 = 1 << (D0); else IOCLR0 = 1 << (D0);

IOSET0 = 1 << RS;

IOCLR0 = 1 << RW;

IOSET0 = 1 << EN;

Delay();

IOCLR0 = 1 << EN;

}

void GLCD_Draw (unsigned long *GLCDPort, unsigned char Datt, const char *Base)

{

int Page, Column;

D0 = Datt;

for (Page = 0; Page < 8 ; Page++)

{

GLCD_Page(1);

GLCD_Cmd (GLCDPort, D0, (0xB8 | Page));

GLCD_Cmd (GLCDPort, D0, 0x40);

for (Column = 0; Column < 128; Column++)

{

if (Column == 64)

{

GLCD_Page (0);

GLCD_Cmd (GLCDPort, D0, (0xB8 | Page));

GLCD_Cmd (GLCDPort, D0, 0x40);

}

GLCD_Data (GLCDPort, D0, *Base++);

Delay();

}

}

}

void Delay()

{

unsigned int i,j;

for(i=0;i<25;i++)

for(j=0;j<200;j++);

}


Circuit Diagram



No comments:

Post a Comment

GPS sensor interface with ESP8266 using Blynk IoT cloud

   Circuit diagram: Source Code: #include <TinyGPS++.h> #include <SoftwareSerial.h> #define BLYNK_PRINT Serial #include <ESP8...