Tuesday, December 27, 2011

16x2 Serial LCD (Two Wire) with PIC12F675

           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.
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





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

9 comments:

  1. O-oh, the good idea!
    Thank you!

    ReplyDelete
  2. this is amasing idea ,we can save the ports for other use.sir pls post c code for mcs51 for test 16*2 display.

    ReplyDelete
  3. dear sir,
    r u using 4-bit mode for driving lcd,can we use 8-bit mode with same technique?

    ReplyDelete
  4. This 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.

    ReplyDelete
  5. you 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)....

    ReplyDelete
  6. hi,
    my 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.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Hi, 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

    ReplyDelete