LMG1278 LCD Module Datasheet 1) General specification 1.1 Mechanical Dimension Item Dimension Unit Number of characters 16 characters x 1 line - Module dimension (L x W x H) 80.5x36.5x6.6 mm. View area 64.1x13.7 mm. 1.2 Controller IC: SED1278 (EPSON) 1.3 Temperature Range Normal Operating 0~+50˚C Storage -10~+60˚C 2) Absolute maximum ratings Item Symbol Min Max Unit Supply voltage Vdd-Vss -0.3 7 V Input voltage Vi Vss Vdd V 3) Electrical characteristics Item Symbol Min Type Max Unit Supply voltage Vdd – Vss - 5.0 V Input high VIH 2.0 - Vdd V Input low VIL Vss - 0.8 V Output high VOH 2.4 - Vdd V Output low VOL - - 0.4 V Supply current IDD - 0.5 0.8 mA
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
LMG1278 LCD Module Datasheet
1) General specification 1.1 Mechanical Dimension
Item Dimension Unit Number of characters 16 characters x 1 line - Module dimension (L x W x H)
80.5x36.5x6.6 mm.
View area 64.1x13.7 mm.
1.2 Controller IC: SED1278 (EPSON) 1.3 Temperature Range
Normal Operating 0~+50˚C Storage -10~+60˚C
2) Absolute maximum ratings Item Symbol Min Max Unit
Supply voltage Vdd-Vss -0.3 7 V Input voltage Vi Vss Vdd V
3) Electrical characteristics
Item Symbol Min Type Max Unit Supply voltage Vdd – Vss - 5.0 V Input high VIH 2.0 - Vdd V Input low VIL Vss - 0.8 V Output high VOH 2.4 - Vdd V Output low VOL - - 0.4 V Supply current IDD - 0.5 0.8 mA
4) Interface pin function Pin No.
Wire color
Symbol Level Description
1 Black D7 H/L Data bit 7 2 Brown D6 H/L Data bit 6 3 Red D5 H/L Data bit 5 4 Orange D4 H/L Data bit 4 5 Yellow E H,H→ L Chip enable 6 Green R/W H/L H: Read (MCU→Module)
L: Write (MCU→Module) 7 Blue RS H/L H: Data
L: Instruction 8 Purple Vo Variable Operating voltage for LCD 9 Gray Vdd 5.0V Supply voltage 10 White Vss 0V Ground
5) Display command
6) Character font
7) Drawing
8) Code example
Note: Compiled by CCS and deployed on PIC16F913 or PIC16F914. LCD016M001L.C /////////////////////////////////////////////////////////////////////////// //// LCD016M001.C //// //// Driver for common LCD modules (KS0066) //// //// //// //// lcd_init() Must be called before any other function. //// //// //// //// lcd_putc(c) Will display c on the next position of the LCD. //// //// The following have special meaning: //// //// \f Clear display //// //// \n Go to start of second line //// //// \b Move back one position //// //// //// //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) //// //// //// //// lcd_getc(x,y) Returns character at position x,y on LCD //// //// //// /////////////////////////////////////////////////////////////////////////// // *** Port C of PIC16F9xx, there're pins VLCD1, VLCD2, VLCD3 which are enabled (1) by default // register LCDCON (address 107h, at bit4 VLCDEN). This make these pins can't be used as I/O. // So the must thing to do first is to disable (0) this bit. // For CCS compiler, there will have built-in function as the named setup_lcd() which can be found // in 16F913.h. So we can declare at the first main (before lcd initial) as setup_lcd(LCD_DISABLED); // For Hitech C, there's no built-in function. So we need to clear bit 4 of LCDCON manually. // Like this bitclr(LCDCON, 4); // As defined in the following structure the pin connection is as follows: // RD0 rs // RD1 rw // RD2 e // RD4 D4 // RD5 D5 // RD6 D6 // RD7 D7 // // LCD pins D0-D3 are not used and PIC RD3 is not used. // ***Important thing if use Vishay LCD016M001L version Vee on board // ---> pin 15 is A for B/L and also is Vee (~ -5V). So this can't be drive the B/L // When using B/L, it is strongly noted to use pin A and K (separated from 16 pin connector) // by desoldering RA out (normally RA=0 and shorted pin 15 and pin A (at LED) together both be Vee) // ***Backlighgt at pin A of Vishay brand (LCD-016M001L), it's shown in datasheet that recommended to // supply to pin A only 4.2V. So it must be connected by diode (1N4001 or 1N4002 or BY251) in order to // drop out from 5V supply.
// Normally pin K (for B/L) isn't connected to GND pin // rs = 0 ------> Instruction/ rs = 1 ------> Data // rw = 0 ------> Write / rw = 1 ------> Read // DDRAM = 0x8x (1xxxxxxx) ---> Starting at first line and position. // So example of DDRAM 00H will become to 80H // DDRAM LINE1 0x00 to 0x07 (8, half left) and 0x40 to 0x47 (8, half right) // So DDRAM becomes to: // LINE1 0x80 to 0x87 (8, half left) and 0xC0 to 0xC7 (8, half right) // **This is 1 line but DDRAM is separated to 2 address ranges, so acting like 2 lines (use 2 lines mode) // (n << 2) -----> Left shift data in n to 2 bits [Ex. n=0x03 (00000011) ---> 00001100 = 0x0C] // (n >> 4) -----> Right shift data in n to 4 bits [Ex. n=0x28 (00101000) ---> 00000010 = 0x02] // Un-comment the following define to use port B // #define use_portb_lcd TRUE /* This structure is overlayed on to an I/O port to gain access to the LCD pins. The bits are allocated from low order up. ENABLE will be pin B0. */ struct lcd_pin_map { int1 rs; // RD0 (int1 = int 1 bit) int1 rw; // RD1 int1 e; // RD2 int1 unused; // RD3 int data : 4; // RD4-RD7 } lcd; #if defined use_portc_lcd #locate lcd = getenv("sfr:PORTC") // This puts the entire structure over the port #define set_tris_lcd(x) set_tris_c(x) #else #locate lcd = getenv("sfr:PORTD") // This puts the entire structure over the port #define set_tris_lcd(x) set_tris_d(x) #endif #define lcd_type 2 // 0=5x7 and 1 line, 1=5x10, 2=2 lines #define lcd_line_one_hl 0x00 // LCD RAM address for the half left first line #define lcd_line_one_hr 0x40 // LCD RAM address for the half right first line // These bytes need to be sent to the LCD to start it up. // 0x0C is display on-off control --> Display on, cursor off, cursor blink off // 0x01 is clear display // 0x06 is entry mode set --> cursor moves to right and DDRAM address is increased by 1 // 0x28 is function set --> 4 bit mode, 2 line display mode, 5x8 dots format int const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0x0C, 0x01, 0x06};
// The following are used for setting the I/O port direction register. struct lcd_pin_map const LCD_WRITE = {0,0,0,0,0}; // For write mode all pins are out struct lcd_pin_map const LCD_READ = {0,0,0,0,15}; // For read mode data pins are in, other pins are out // Read display int lcd_read_byte(void) { int low,high; set_tris_lcd(LCD_READ); // Direction of data pins are set to 0xF0 (input) lcd.rw = 1; delay_cycles(1); lcd.e = 1; delay_cycles(1); high = lcd.data; lcd.e = 0; delay_cycles(1); lcd.e = 1; delay_us(1); low = lcd.data; lcd.e = 0; set_tris_lcd(LCD_WRITE); // Direction of data pins are set to 0x00 (output) return( (high<<4) | low); // group 4 bits MSB and 4 bits LSB to one byte } // Send data 4 bits per each time to chip void lcd_send_nibble(int n) { lcd.data = n; delay_cycles(1); lcd.e = 1; delay_us(2); lcd.e = 0; } // Set data for nibble sending void lcd_send_byte(int address, int n) { lcd.rs = 0; // set 0 for instruction while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low lcd.rs = address; delay_cycles(1); lcd.rw = 0; delay_cycles(1); lcd.e = 0; lcd_send_nibble(n >> 4); // Send 4 bits MSB first, ex. n=0x28 (00101000) --> 00000010 = 0x02 lcd_send_nibble(n & 0x0F); // Send 4 bits LSB then, ex. n=0x28 (00101000) --> 00001000 = 0x08 } // Initialization chip void lcd_init(void)
{ int i; set_tris_lcd(LCD_WRITE); // Direction of data pins are set to 0x00 (output) lcd.rs = 0; lcd.rw = 0; lcd.e = 0; delay_ms(15); for(i=0; i<=3; i++) { lcd_send_byte(0, LCD_INIT_STRING[i]); } } // Go to called position void lcd_gotoxy(int x, int y) { int address; if(y!=1) address = lcd_line_one_hr; // go to half right position else address = lcd_line_one_hl; // go to half left position address+=x-1; // address = address+(x-1) lcd_send_byte(0, 0x80|address); // 0x80 | DDRAM ---> Set DDRAM address } // Data is needed to be sent void lcd_putc(char c) { switch (c) { case '\f' : lcd_send_byte(0, 1); // Clear and return to home DDRAM 00H delay_ms(2); break; case '\n' : lcd_gotoxy(1, 2); break; // go to half right position case '\b' : lcd_send_byte(0, 0x10); break; default : lcd_send_byte(1, c); break; } } // Returns character at position x,y on LCD char lcd_getc(int x, int y) { char value; lcd_gotoxy(x,y); while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low lcd.rs = 1; value = lcd_read_byte(); lcd.rs = 0; return(value); }
Main.c /* #include <16F917.h> // No need to add header file, it'll be automatically called by compiler
// Header file must be in the same folder with project #fuses INTRC_IO,NOPROTECT,NOWDT,NOBROWNOUT,NOPUT,MCLR,DEBUG #use delay(clock=4000000) */ #include <16F913.h> // No need to add header file, it'll be automatically called by compiler // Header file must be in the same folder with project #fuses HS,NOWDT,NOPUT,MCLR,NOPROTECT,NOBROWNOUT,DEBUG #use delay(clock=8000000) #define use_portc_lcd TRUE #include "LCD016M001L.c" /* LCD command \f clear display \n Go to start of second line \b Move back one position */ void main(void) { setup_lcd(LCD_DISABLED); lcd_init(); while(1) { printf(lcd_putc, "\fWELCOME\nTO..."); delay_ms(2000); printf(lcd_putc, "\fELECTRON\nICS"); delay_ms(2000); printf(lcd_putc, "\fSOURCE C\nO., LTD."); delay_ms(2000); printf(lcd_putc, "\fThe art \nof..."); delay_ms(2000); printf(lcd_putc, "\fELECTRON\nICS"); delay_ms(2000); printf(lcd_putc, "\fThis is \n16x1 dot"); delay_ms(2000); printf(lcd_putc, "\fcharacte\nr LCD"); delay_ms(2000); printf(lcd_putc, "\fPart Num\nber:"); delay_ms(2000); printf(lcd_putc, "\fLMG1278"); delay_ms(2000); printf(lcd_putc, "\fBrand: ES"); delay_ms(2000); } }