Pages

Showing posts with label Mikrokontroller. Show all posts
Showing posts with label Mikrokontroller. Show all posts

Monday, October 10, 2011

Introduction of LCD Interface

I have an article from my friend. I think i can share it to you. I hope this article will useful for you.. :)
Lets try to know LCD Interface.



Liquid Crystal Display (LCD) consists of rod-shaped tiny molecules sandwiched between a flat piece of glass and an opaque substrate. These rod-shaped molecules in between the plates align into two different physical positions based on the electric charge applied to them. When electric charge is applied they align to block the light entering through them, where as when no-charge is applied they become transparent.
Light passing through makes the desired images appear. This is the basic concept behind LCD displays.  

LCDs are most commonly used because of their advantages over other display technologies. They are thin and flat and consume very small amount of power compared to LED displays and cathode ray tubes (CRTs).


►Pin Description

The most commonly used LCDs found in 
the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support at most of 80 charachers, whereas LCDs supporting more than 80 characters make use of 2 HD44780 controllers.

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two pins are extra in both for back-light LED connections). Pin description is shown in the table below.


LCD type HD44780 pin diagramFigure 1: Character LCD type HD44780 Pin diagram
Pin No.Name
Description
Pin no. 1VSS
Power supply (GND)
Pin no. 2VCCPower supply (+5V)
Pin no. 3VEE
Contrast adjust
Pin no. 4RS
0 = Instruction input
1 = Data input
Pin no. 5R/W
0 = Write to LCD module
1 = Read from LCD module
Pin no. 6EN
Enable signal
Pin no. 7D0Data bus line 0 (LSB)
Pin no. 8D1Data bus line 1
Pin no. 9D2Data bus line 2
Pin no. 10D3
Data bus line 3
Pin no. 11D4
Data bus line 4
Pin no. 12D5
Data bus line 5
Pin no. 13D6
Data bus line 6
Pin no. 14D7
Data bus line 7 (MSB)
Table 1: Character LCD pins with 1 Controller

Pin No.Name
Description
Pin no. 1D7Data bus line 7 (MSB)
Pin no. 2D6Data bus line 6
Pin no. 3D5Data bus line 5
Pin no. 4D4
Data bus line 4
Pin no. 5D3
Data bus line 3
Pin no. 6D2
Data bus line 2
Pin no. 7D1
Data bus line 1
Pin no. 8D0
Data bus line 0 (LSB)
Pin no. 9EN1Enable signal for row 0 and 1 (1stcontroller)
Pin no. 10R/W0 = Write to LCD module
1 = Read from LCD module
Pin no. 11RS0 = Instruction input
1 = Data input
Pin no. 12VEEContrast adjust
Pin no. 13VSSPower supply (GND)
Pin no. 14VCCPower supply (+5V)
Pin no. 15EN2Enable signal for row 2 and 3 (2ndcontroller)
Pin no. 16NCNot Connected
Table 2: Character LCD pins with 2 Controller

Usually these days you will find single controller LCD modules are used more in the market. So in the tutorial we will discuss more about the single controller LCD, the operation and everything else is same for the double controller too. Lets take a look at the basic information which is there in every LCD.

Friday, October 07, 2011

Writing First C in Keil Compiler

lets we do with keil compiler. Keil C is not much different from a normal C program. If you know assembly, writing a C program is not a problem, only thing you have to keep in mind is forget your controller has general purpose registers, accumulators or whatever. But do not forget about Ports and other on chip peripherals and related registers to them.

In basic C, all programs have atleast one function which is entry point for your application that function is named as "main" function. Similarly in keil, we will have a main function, in which all your application specific work will be defined. Lets move further deep into the working of applications and programs.

When you run your C programs in your PC or computer, you run them as a child program or process to your Operating System so when you exit your programs (exits main function of program) you come back to operating system. Whereas in case of embedded C, you do not have any operating system running in there. So you have to make sure that your program or main file should never exit. This can be done with the help of simple while(1) or for(;;) loop as they are going to run infinitely. Following layout provides a skeleton of Basic C program.

CODE:
void main(){
//Your one time initialization code will come here
        while(1){
                //while 1 loop
                //This loop will have all your application code
                //which will run infinitely
        }
}

and, for add , just right click, and choose insert include REGx51.h. Its very simple and easy,,,

lets do with practice
we try to make Blink LED on PORT1, Pin 1

CODE:
#include //header file for 89C51
void main(){
        //main function starts
        unsigned int i;
        //Initializing Port1 pin1
        P1_1 = 0; //Make Pin1 o/p
        while(1){
                //Infinite loop main application
                //comes here
                for(i=0;i<1000;i++)
                        ; //delay loop
                P1_1 = ~P1_1;
                //complement Port1.1
                //this will blink LED connected on Port1.1
        }
}
 
and then, build it to Hex first, and then download to your microcontroller. and look what happen with Port1 pin1. if your it not blink, check your circuit and your code.

HAVE FUN with MICROCONTROLLER... ^_^