Home     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Tech-BLOG     RSS     Terms of services     Privacy policy  
 Home     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Tech-News     RSS   

PCB Fabrication
8 August 2011
Author: Giorgos Lazaridis
PWM LCD Contrast Adjustment


The circuit on a breadboard for test

Most of you probably know the popular HD44780 character LCD controller from Hitachi. Usually you find it on LCD display boards with 16 pins. One of these pins is called "Contrast Adjustment" and does exactly this: It adjusts the LCD contrast. This pin requires a voltage level. If a microcontrollers has a Digital to Analog module, then this pin can be directly interfaced with this module. But the D/A module is not very common, instead, the PWM module is.

In such applications, the backlit is usually done with LEDs, so a simple PWM driver can directly adjust the brightness. Unfortunately, the PWM module cannot be directly used to adjust the contrast. So, i made a very simple and small circuit to interface the PWM output of a microcontroller to the contrast adjustment pin of an HD44780 Character LCD.







The Circuit

Here is the circuit schematic: (click to enlarge)





There is a red rectangle at the bottom right corner of the schematic. This is the interesting part. The rest of the circuit (the PIC along with the LCD) is only added to demonstrate the circuit operation. The PIC initializes the LCD and then sends a simple string to be displayed. The potentiometer R1 is used to generate a control voltage from 0 to 5 volts, and it is directly interfaced to an analog input of the PIC. The PIC then translates this control voltage into a binary number with the internal A/D module. Finally, it generates a PWM signal with a duty cycle from 0 to 100% according to the analog control value taken from the R1 potentiometer.

The PWM output from the PIC (RB3) is then driven to the interface circuit. This circuit is composed by a transistor amplifier (T1) and a low-pass filter R3/R4 - C1. This low pass filter will convert the PWM signal into a voltage level. This voltage level is higher when the PWM duty cycle is closer to 0%, and lower when the duty cycle is closer to 100%. This signal can be directly used for the contrast adjustment of the LCD.




The PIC Firmware

 PWM LCD Contrast Adjustment - Assembly listing - V1.0

 PWM LCD Contrast Adjustment - Hex file - V1.0





Bill Of Materials
Resistors
R1Potentiometer 10 KOhm Linear Rotary 1/2W
R2Resistor 22 KOhm 1/4 Watt 5% Carbon Film 
R3Resistor 4.7 KOhm 1/4 Watt 5% Carbon Film 
R4Resistor 680 Ohm 1/4 Watt 5% Carbon Film
Capacitors
C1Electrolytic Capacitor 47 uF 16 Volts
Transistors
T1BC548 Switching and Applications NPN Epitaxial Transistor 
Integrated Circuits
IC1PIC16F88 Microcontroller 
Misc
LCD1LCD 16x2 Character LCD w/ HD44780U1 controller 





 Rate this article!


Comments

  • At 9 February 2012, 5:31:47 user Giorgos Lazaridis wrote:   [reply @ Giorgos Lazaridis]
    • @Sajjad no problem with PWM and ADC for me. What do you control with the PWM? And what sort of spikes? You have oscilloscope view? Post them in the forum to see


  • At 9 February 2012, 4:05:07 user Sajjad wrote:   [reply @ Sajjad]
    • Have you ever encounter a problem that your PWM pulses are affecting your ADC, i am stuck in such a problem. for every rise and fall, spikes appears on my ADC pins. PIC = 16f877A


  • At 8 August 2011, 18:08:58 user Kammenos wrote:   [reply @ Kammenos]
    • @_pike as a matter of fact, the problem with the LCDs is not the ambient light but the ambient temperature. Brand LCDs come with temperature coefficient, and you make a circuit that changes the contrast according to the temperature.
      As for the LCD backlit, this circuit could be used but it is not efficient. A Simple PWM circuit or a simple transistor amplifier on one of the PWM outputs of a PIC is much better.


  • At 8 August 2011, 17:31:34 user _pike wrote:   [reply @ _pike]
    • Congratulations Kam +1000 another great circuit of yours......!!!!!!Additionaly one thought that just came up to me is to use an LDR instead of a pontetiometer so the contrast would be able to be adjusted depending the ambient light of the room.What do you say? I suppose also that this circuit can be used for the lights of the lcd.... am i right?


     

      Name

      Email (shall not be published)

      Website

    Notify me of new posts via email


    Write your comments below:

          






    delicious
    digg
    reddit this Reddit this
    Faves

    Search PCB Heaven


     HOT in heaven!



    PCB Heaven chirps on Follow me on Twitter

    TAGS cloud

    PWM  Dimmer  PIC Microcontroller  LCD Display  Electronic Circuit 



    NEW in heaven!



    New Project: How to make a professional-like panel label

    Random Circuits!
     Closed Loop high frequency PWM PC Fan Controller
     PC Fan RPM Bargraph Meter and Failure Alarm with PIC



     Home     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Tech-News     RSS   

    Site design: Giorgos Lazaridis
    © Copyright 2008
    Please read the Terms of services and the Privacy policy