Thursday, March 1, 2012

PIC MCU LCD Driver 4 commmon 7 Segmented LCD & PIC16F917

  Now a days almost all the mcu projects use a normal 16x2 char LCD or the LED  to display the data, but the problem with those 16x2 LCD and LED is , they consumes a lot of power , they are very thick  , bulky and the font size is really very small , and if you go for a big font size then they are really very expensive  and some times we just don't want that may lines and character , what we want is just a 3 - 4 digit numbers and a big display font size.
 so  here is a quick tutorial on how to use a microchip pic mcu to drive an 4 common 7 segment lcd .
Prototype


TYPES OF SEGMENTED(controller les "RAW")  LCD
     These type of LCD have no controllers built in all they are is just a liquid crystals sandwiched between to pieces of glass and sometimes a reflective plate at the back. The LCD who have that plate on the back (like my LCD has) called reflective and the LCD who don't have those plate looks quite a transparent called Transreflective.

There is another criteria for classification of the raw lcd glasses

Non Multiplexed (single Common) ( STATIC )
 In this Type of there is one common signal called Backplane .and a dedicated pin for each of the segment of LCD to drive them you have to input a square wave (~100 Hz) to that..if u wanna switch on a segment you the provide a wave 180 degrees out of phase with the backplane and if u wanna turn it off then give same phase wave as the backplane. and you have to keep the square wave going for all the time you want the display to be on other wise in the mean time display will got fade.
These LCD are simplest of it's type and very easy to drive , but the only problem is , each segment need a dedicated pin , so need too may pins lead to a big package mcu.
Picture 1 (STATIC LCD driver signals)


Multiplexed  ( more than 1 common)

`Thse type of LCD have more than one common pins or Backplane. they can have 2 ,3 ,4 or so may back panes (the HD44780 16x2 char drive has 16 common). so driving these lcd is not a easy task i guess you can drive up to 2 common lcd without a dedicated lcd controller but beyond 2 common lcd you gonna need a lcd controller.
Picture 2
if you need more details how the lcd works please refers to the microchip application notes AN658
  
THE PIC16F917 LCD Microcontroller 
 the PIC16F917 microcontroller from Microchip has a LCD controller built-in,
comes is DIP 40 , TQFP44, and QFN 44 package. 
Support up to 24 segments with up to 4 common or back planes

The lcd i m gonna use to demonstrate the PIC16F917 LCD controller is a multiplexed LCD which has 4 common and 8 segments. total 4 digits . 

PIN CONFIGURATION of MY LCD
Picture 3 pinout 


Check list:-  Before you Go ahead there are some things you have to be sure about 
1. you must some how verify how may Common back planes your LCD have,, if you don't have the data sheet of the LCD or you don't know the source from where it came . then you have to do lots of hit and trial to determine how may back plane your lcd have .. what i can suggest in this condition is take two signals of about 100Hz who are invert to each other ( phase difference of 180). CAUTION::don't supply DC voltage to the raw lcd it gonna damage the liquid crystal. , and don't even touch the lcd pins if the some other pin is connect to a drive signal. now you have to try every single pin with respect of every other pin. let me remind you two things one is that "few pins could be NC" and two or more pins may have the same function like my lcd have COM0 is on pin 1,2 . well it don't matter much which pin you use both them will work same.   

2. what is the maximum voltage the lcd can take , most of the raw lcd will work in the range of 2 to 5 volts but after that if you supply more than 5v you gonna damage the pixels if you supply less voltage then the contrast will be really less.
3. you need to know the pinout of the lcd. if you don't know it go google for the datasheet or  do some hit and trial test with two 180 degree phase difference(invert) signals.
5. how may segment  your lcd has , if you are driving a non multiplexed lcd(STATIC lcd "having one common plane") then you need a single dedicated pin for each segment. so the required number of pins may go to very high . look whether the mcu has that much of segment pins . and even if it has check if these segment pins of the mcu are multiplexed pin some other peripheral like adc or timer input  that you are gonna use then it may cause a problem. 
SCHEMATIC

picture 4 schematic LCD Driver prototype

DOWNLOAD SOURCE Code and Firmware.


PROTOTYPING 


THINGS TO KEEP IN MIND
*   I guess most important thing in the hardware is the VLCD pins the there the total 4 VLCD pins VLCD0 is internally connected to ground and not available on the package pins so rest VLCD1 VLCD2 VLCD3 pins are available on the package. these the pins where you have to supply the proper voltage for diffrent levels of the signal V0 , V1,V2,V3 ( please refer to Picture 2 of this page "4 common driving signal")   
you have to set these voltages according to your lcd ,like my lcd is 5 volts lcd so i use  the resistor network configuration in such a way that VLCD3 pins has about 4.30 volts which is V3 level , VLCD2 pins to 3.40 volts which is V2 level and VLCD 1 pins got about 1.3 volts which goes as V1 level voltage. 
let me remind you some facts about these voltage pins  first is that microcontroller use voltage of these pins to generate the LCD driving signal . so if you left them unconnected then there will be nothing on the lcd.
second is that  you have to first enable them in the software before using them , in our example code i also enabled them. 
third  is that you have to keep sufficient  diffrence between these voltages, if you failed to maintain the sufficient difference then you will saw that if you on one segment then some other segment will also lit up( but with very less contrast.) . 
and you have to keep these LCD voltage as close as possible so that every back plane's pixel's contrast will remain same.
so the all you have to do is keep all the voltage as high as possible for best contrast but blow the maximum tolerance of the lcd . 
as you can see in the schematic there is pot on between the VCC and the VLCD3 pin actually this pin is used to adjust the control the voltage on all three pins , by which you can adjust the contrast  




thanks for reading 
any Questions ??? feel free to ask.


13 comments:

  1. Hi there,

    Exactly what LCD module (part #) is this?
    I like the addtition of the "LOWBAT" and "SENSOR", perfect for my applications!

    Cheers,
    Tony

    ReplyDelete
    Replies
    1. sorry tom
      i picked up this lcd in local market, it doesn't have any part no. but the only thing the shopkeeper told me is that this lcd is used in petrol pump machines.
      the only thing i can suggest you should look lumex lcd website there are similar module available

      Delete
  2. hi
    i have 8common 16segment lcd.
    can i drive it with pic mcu?
    plz help me?
    tanx alot

    ReplyDelete
  3. Hey, I have 3 digit 7 segment lcd, I'm trying to connect it to a pic16f917. Could you help show me the connection diagram or something? thanks

    ReplyDelete
    Replies

    1. first you need to figure out is this lcd single common , or multiple common plane.

      then you need pinout , these all information are given in the datasheet.
      but if you don't have data sheet then you need to figure out by following the post above and some rational thinking.

      Delete
  4. Hi, Gaurav Singh

    I have a glass LCD with 4 common pin and 20 segment pin with 1/4 duty cycle and 1/3 bias.

    I know about every pin relation with dedicated symbols.

    But, problem is how can i interface it with STM32-L053R8T6 micro-controller,
    I doesn't have any idea about interfacing glass LCD and how can i generate a differential voltage level.

    controller has a LCD driver but i stuck at programming.

    Please, suggest me for programming or method to drive the lcd module.

    ReplyDelete
  5. muito bom, a tempos venho procurando algum projeto do tipo e só agora encontrei! excelente post, vou dar uma estudada no código e descobrir o que posso aprender com a ajuda de seu post. quando fazemos busca por programação com pic e display de cristal liquido, só encontramos material sobre display lcd do tipo 16x1, 16x2 ou similar!
    seu post vem a ser de grande valia para todos que buscam esse tipo de material para experimentos e estudos!

    ReplyDelete
  6. Hello,
    For the same pic16f917 i interfaced the lcd display its working fine. But i want to communicate this pic16f917 with one arduino. I need a reference code for i2c communication to this pic16f917. Please help me to find out. Thank you.

    ReplyDelete
  7. Nice article dear , very helpful and great effort .
    Can you help me i have different lcd ,

    having # of pins 10
    # of digits 3
    4 common , com 1,2, 3 and 4
    Pin # 1 have 1F,1G,1E and 1D
    Pin # 2 have 1A,1B,1C

    Pin # 3 have 2F,2G,2E and 2D
    Pin # 4 have 2A,2B,2C

    Pin # 5 have 3F,3G,3E and 3D
    Pin # 6 have 3A,3B,3C

    Pin # 7 Com4
    Pin # 8 Com3
    Pin # 9 Com2
    Pin # 10 Com1

    Can you help me in this regard that how i use pic16f916 for this type of lcd

    ReplyDelete
  8. source cod link is not opening
    please give source code link again
    thank you

    ReplyDelete
    Replies
    1. google sites has gone offline, I saved all old projects and put them github. but it appears this project somehow was missed. I do not have this project anymore with me. Sorry

      Delete
    2. how did you write (lowbat and sensor statement)

      please tell
      thanks

      Delete