The General purpose 16x2 or 16x1 char LCD are very easy to interface with any microcontroller , and these lcd are really very cheap and thoroughly available in the whole world, but the only problem with these lcd is they require 4 or 8 data lines + 2 or 3 control line to at minimum 6 line and maximum 11 lines are required. that not good because many small package microcontroller like PIC10 ,PIC12,PIC16 from microchip ,MSP430 Texas Instrument and Attiney from Atmel there all microcontroller have either 6 to 15 I/O lines. in this condition this technique will save you many I/O line because in this we use only 2 wires to connect the lcd with any microcontroller.
Most of these 16x2 ,16x1,8x1,8x2 ,8x4 ,20x4 and so on use stranded 8 line data and three control signal EN :- enable ,,RS- Register Select(data/command) ,, RW - read write
for futher details how these lcd works , pin configuration and command other things please visit my previouse post CLICK HERE :- 16x2 LCD with MCU
Theory Of Operation
This heart of the circuit is CD4094 shift register, this serial in Parallel out shift register allow us to clock the data and command on to the data and command line of the lcd basically we have first send the rs and data then send the enable in general
To achieve this, the data input to the shift register is logically ANDed with output Q7 using a resistor and a diode. Only when Q7 is high will allow a pulse on the data input be transmitted to the LCD as a pulse on its E input. because if the Q7 is low the the diode will start working in forward region and all the current will sink in to the Q7 nothing will to lcd .
To make sure that no spurious E pulses are generated,the following sequence of instruction must be followed care fully
1. Clock eight zero bits into the shift register by setting the data signal low and generating eight clock pulses. The bits are clocked in on each rising clock edge. Now all the Q outputs of the shift register are low, and in particular no E signal can be generated.
clk = 0; // represent any port pin
data= 0; // represent any port pin
for(i=0;i<8;i++)
{
clk = 1;
clk = 0;
}
2. Now send seven data bits. The first bit must be high and will ultimately appear on Q7, where it will allow an E pulse to be generated. The second bit is destined for the RS signal on Q6; the next four bits are data. The final bit is zero, ensuring that the data signal is left low. After a total of seven clock pulses the data bits will appear as required on the Q outputs, and in particular Q7 will be high.
Download the Software firmware ,Source code and Schematic
Simulation in ISIS
Download the Simulation file
THE HARDWARE
PCB
THIS CIRCUIT CAN BE USED WITH
you may also like 30 volts Panel Volt Meter Using Pic mcu
Most of these 16x2 ,16x1,8x1,8x2 ,8x4 ,20x4 and so on use stranded 8 line data and three control signal EN :- enable ,,RS- Register Select(data/command) ,, RW - read write
for futher details how these lcd works , pin configuration and command other things please visit my previouse post CLICK HERE :- 16x2 LCD with MCU
Theory Of Operation
This heart of the circuit is CD4094 shift register, this serial in Parallel out shift register allow us to clock the data and command on to the data and command line of the lcd basically we have first send the rs and data then send the enable in general
To achieve this, the data input to the shift register is logically ANDed with output Q7 using a resistor and a diode. Only when Q7 is high will allow a pulse on the data input be transmitted to the LCD as a pulse on its E input. because if the Q7 is low the the diode will start working in forward region and all the current will sink in to the Q7 nothing will to lcd .
To make sure that no spurious E pulses are generated,the following sequence of instruction must be followed care fully
1. Clock eight zero bits into the shift register by setting the data signal low and generating eight clock pulses. The bits are clocked in on each rising clock edge. Now all the Q outputs of the shift register are low, and in particular no E signal can be generated.
clk = 0; // represent any port pin
data= 0; // represent any port pin
for(i=0;i<8;i++)
{
clk = 1;
clk = 0;
}
2. Now send seven data bits. The first bit must be high and will ultimately appear on Q7, where it will allow an E pulse to be generated. The second bit is destined for the RS signal on Q6; the next four bits are data. The final bit is zero, ensuring that the data signal is left low. After a total of seven clock pulses the data bits will appear as required on the Q outputs, and in particular Q7 will be high.
data = 1; //set Q7= 1 for E
clk =1;
clk=0;
data = rs; //set Q6 for RS
clk =1;
clk =0;
for ( i=8;i>0;i=i>>1)
{
if(d & i) //i= 8 ,4, 2, 1
{
data =1;
}
else
{
data =0;
}
clk = 1;
clk = 0;
}
3. Now we emit a pulse on the data signal, which in turn generates a pulse on the E line because Q7 is high. The above procedure must be carried out twice, once for the high data nibble (bits D4 to D7) and once for the low data nibble (bits D0 to D3).
data=0; //shift Q0
clk = 1;
clk = 0;
data = 1; //now send enable
data = 0;
Implementing the Software with PIC12F675
clk =1;
clk=0;
data = rs; //set Q6 for RS
clk =1;
clk =0;
for ( i=8;i>0;i=i>>1)
{
if(d & i) //i= 8 ,4, 2, 1
{
data =1;
}
else
{
data =0;
}
clk = 1;
clk = 0;
}
3. Now we emit a pulse on the data signal, which in turn generates a pulse on the E line because Q7 is high. The above procedure must be carried out twice, once for the high data nibble (bits D4 to D7) and once for the low data nibble (bits D0 to D3).
data=0; //shift Q0
clk = 1;
clk = 0;
data = 1; //now send enable
data = 0;
Implementing the Software with PIC12F675
Simulation in ISIS
Download the Simulation file
THE HARDWARE
PCB
you may also like 30 volts Panel Volt Meter Using Pic mcu
O-oh, the good idea!
ReplyDeleteThank you!
this is amasing idea ,we can save the ports for other use.sir pls post c code for mcs51 for test 16*2 display.
ReplyDeletedear sir,
ReplyDeleter u using 4-bit mode for driving lcd,can we use 8-bit mode with same technique?
i m using 4 bit mode
ReplyDeleteThis is first time i heard about serial LCD! its really very nice! designing of PCB is a little bit difficult. sir which software did u used for pcb design. Thank alot for new ideas in embedded systems.
ReplyDeleteyou can even use just one pin.....feed clock as it is....tie data to the same input, but trhough an rc network...all you need to do is strech low level for clock a little longer to mark a zero (capacitor discharges)....
ReplyDeletehi,
ReplyDeletemy friend acctually i want to connect this device with any uart.
i mean, i want to connect lcd with pc also. so i can send data thugh pc port to lcd
my mail id is prafful.sorani@gmail.com
if you have any idea about this than please tell me.
This comment has been removed by the author.
ReplyDeleteHi, i'm desperatly looking for an example assembler code for a PIC 12 F 675 thah uses the ADC, so i can start from there a project
ReplyDeleteHi. Can I use a LCD 2x8 instead of a LCD 2x16? Thank you
ReplyDeleteYes, it can be used with any size of lcd with similar parallel interface
ReplyDeleteBom Dia!
ReplyDeleteAmigo ao compilar apresenta os seguintes erros:
Executing: "C:\Arquivos de programas\HI-TECH Software\PICC\PRO\9.65\bin\picc.exe" --pass1 "C:\Documents and Settings\Carlos Roberto\Desktop\Nova pasta\LCD PIC12F675\Serial LCD\lcd16.c" -q --chip=12F675 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Error [192] C:\Documents and Settings\Carlos Roberto\Desktop\Nova pasta\LCD PIC12F675\Serial LCD\lcd16.c; 7.1 undefined identifier "GPIObits"
Error [196] C:\Documents and Settings\Carlos Roberto\Desktop\Nova pasta\LCD PIC12F675\Serial LCD\lcd16.c; 7.14 struct/union required
you may not have correct header there, may be HI tech compiler is not installed.
ReplyDeletestructure GPIObits is defined in the header file included by htc.
Thank you!I could make a step by step I have no knowledge of Hit Tech so the compiler CCs
ReplyDeleteThank you.
Obrigado! poderia fazer um passo a passo para mim não tenho conhecimento do Hit Tech so do CCs compiler
Obrigado
you can download hi-tech c compiler for PIC12 from the link blow . install it and use with MPLAB IDE
ReplyDeleteftp://ftp.microchip.com/HI-TECH%20C%20for%20PIC10-12-16%20%28PRO%20and%20Standard%29/picc_9_.83_win.exe
A página da web em ftp://ftp.microchip.com/HI-TECH%20C%20for%20PIC10-12-16%20%28PRO%20and%20Standard%29/picc_9_.83_win.exe pode estar temporariamente indisponível ou pode ter sido movida permanentemente para um novo endereço da web.
ReplyDeletei have just checked it is working here
DeleteThanks for your help.
ReplyDeletegive up the project
grateful
THE CONVERTER IS IT THE MICRO OR THE DIGITAL IC ,WHAT I MEAN IS THAT IF I CAN CONNECT ANY MICRO TO THE DIGITAL IC AS THE INTERFACE
ReplyDeleteconverter IC is just a digital shift register , not a microcontroller
DeleteThank you Brother ,I did it circuit and working fine .
ReplyDeleteand i want to use the LCD and rest of pins to LEDs simultaneusly, 4,9,10 and 11 in 4094 is free it can be utilized ?. Or any other IC or articles that you know
I think 2 more output pins not used pin4 and pin11
ReplyDeletei did try to use these pins for LED. PIN4 OK, but pin11 not possible to use