This blog discuss about my research work and projects related to artificial intelligence, Internet of things, Embedded systems,Data science, Machine learning and deep learning
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);
A display that consists of two polarizing transparent panels and a liquid crystal surface
sandwiched in between. An electric current passed through the liquid causes the crystal to align so that
light cannot pass through them. The LCD has ability to display numbers, characters and graphics. A
sample photo of the LCD module is shown in Figure.
LCD Pin Description:
The LCD we used in the module has 16 pins. The functions of each pin is
RS (Register select):
There are two very important registers inside the LCD
1. Command code register
2. Data register
The RS pin is used for selection of this registers. If RS = 0, Instruction command code register is selected, allowing the user to send a command. If RS= 1 the data register is
selected, allowing the user to send data to be displayed on the LCD.
R/W (Read/ Write):
R/W input allows the user to write information to the LCD or write information from it.
R/W = 1 ; When reading
R/W = 0 ; When Writing
E (Enable):
The enable pin is used by the LCD to latch information presented to its data pins.When data is supplied to data pins, a high to low pulse must be applied to this pin in order for the LCD to latch in the data present at the data pins. This pulse must be a minimum of 450 ns wide.
D0 – D7 (Data pins):
The 8 bit data pins, D0 – D7, are used to send information to the LCD or read the contents of the
LCD‟s internal registers.
Program code
#include <lpc214x.h>
void delay_ms(unsigned char time)
{
unsigned int i, j;
for (j=0; j<time; j++)
for(i=0; i<8002; i++);
}
void LCD_command(unsigned char command)
{
IOCLR0 = 0xFF<<16;// Clear LCD Data lines
IOCLR1=1<<16;// RS=0 for command
IOCLR1=1<<17;// RW=0 for write
IOSET0=command<<16;// put command on data line
IOSET1=(1<<18);// en=1
delay_ms(10) ;// delay
IOCLR1=(1<<18);// en=0
}
LCD_data(unsigned char data)
{
IOCLR0 = 0xFF<<16;// Clear LCD Data lines
IOSET1=1<<16;// RS=1 for data
IOCLR1=1<<17;// RW=0 for write
IOSET0= data<<16; // put command on data line
IOSET1=(1<<18);//en=1
delay_ms(10) ;//delay
IOCLR1=(1<<18);//en=0
}
LCD_init()
{
LCD_command(0x38);//8bit mode and 5x8 dotes (function set)
delay_ms(10) ;// delay
LCD_command(0x0c);//display on, cursor off, cursor char blinking off(display on/off)
delay_ms(10) ;// delay
LCD_command(0x06); //cursor increament and display shift(entry mode set)
delay_ms(10) ;// delay
LCD_command(0x01); //clear lcd(clear command)
delay_ms(10) ;// delay
LCD_command(0x80); //set cursor to 0th location1st lne
}
LCD_write_string(unsigned char *string)
{
while(*string)//Check for End of String
LCD_data(*string++); //sending data on LCD byte by byte
}
int main(void)
{
PINSEL1 = 0x00;//Configure PORT0 as GPIO
PINSEL2 = 0X00;//Configure PORT1 as GPIO
IODIR1= 0x07<<16;//Configure P1.18, P1.17, P1.16 as output
IODIR0=0xFF<<16; //Configure P0.23 - P0.16 as output