-->

LCD Interfacing

By

.......LCD Interfacing.......

                             ..........................................................

                LCD display is commonly used in most of the micro controller based projects. A different kind of LCD modules are available in the market. The display used here is 16X2 LCD it meas that 16 character per line by 2 lines.Hitachi HD 44780 LCD controller is one of the most common dot matrix Liquid Cristal Display controller available in the market (4more).
Datasheet of Hitachi HD 44780 LCD controller Download here.












The 44780 standard has  16 pins 8 pins for data or instruction .
The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. 
ie , it can interface with 3 control line   +  4 I/O ----->  called 4 bit mode 
or , it can interface with 3 control lines + 8 I/O  -----> called 8 bit mode 



The Lcd works according to the data comes from the micro controller. We gives the data from micro-controller to the LCD port of the DB0 - DB7 (see the picture) these applying data is 8 bit data ,because ,Hitachi HD 44780 LCD controller has two 8 bit registers named an instruction register (IR) and a data register (DR).we can disscuss later about the instruction register and data register .


3 Control Lines   RS,RW and EN -Pin No: 4,5,6 respectively.

RS-is the "Register select " the 8 bit data gives to the LCD from the micro-controller are of two type  one is the command data (these command data are giving to the LCD's internal controller and the controller decide as display screen ,position,clear disply ,second line etc according to the command data )  ,which is 8 bit . 
And the second  data is the data which is actually display to LCD (string,name ,numbers etc)

When RS is low (0) the data coming from the micro-controller to the LCD data port is treated as command data


Some LCD Basic Commands:
No.
Instruction
Hex
Decimal
1
Function Set: 8-bit, 1 Line, 5x7 Dots
0x30
48
2
Function Set: 8-bit, 2 Line, 5x7 Dots
0x38
56
3
Function Set: 4-bit, 1 Line, 5x7 Dots
0x20
32
4
Function Set: 4-bit, 2 Line, 5x7 Dots
0x28
40
5
Entry Mode
0x06
6
6
Display off Cursor off
(clearing display without clearing DDRAM content)
0x08
8
7
Display on Cursor on
0x0E
14
8
Display on Cursor off
0x0C
12
9
Display on Cursor blinking
0x0F
15
10
Shift entire display left
0x18
24
12
Shift entire display right
0x1C
30
13
Move cursor left by one character
0x10
16
14
Move cursor right by one character
0x14
20
15
Clear Display (also clear DDRAM content)
0x01
1
16
Set DDRAM address or cursor position on display
0x80+add
128+add
17
Set CGRAM address or set pointer to CGRAM location
0x40+add
64+add

For example
8 bit controller out put port  is named as P0 (8 bit )
RS = 0;     // select the register in command mode 
P0 = 0x20 // giving a 8 bit data  work the LCD as   4-bit, 1 Line, 5x7 Dots refer above command 

When RS is high (1) ,the data coming from the micro-controller to the LCD data port is the text data which should be displayed on the screen.
 For example, to display the letter "m" on the screen you would set RS high.
RS = 1;     // select the register in Data mode 
P0 = 0x20 // giving a 8 bit data,that  will be displayed on the LCD screen.

RW :- When RW is low(0), the data from the micro-controller is being written to the LCD. When RW is high (1), the microcontroller reads the data from the  LCD (eg: busy flag testing )
Most of the times there is no need to read the LCD so this(RW) lines can be connected to ground directly,for saving controller one I/O port line. 
EN :- line is called "Enable." This control line is used to tell the LCD that you are sending it data. To send data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus. When the other lines are completely ready, bring EN high (1) and wait for the minimum amount of time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.

DD-RAM is the Ram used to display the content of the DD-RAM to LCD ,we send the data (to display in LCD screen) to DD RAM in ASCII format ,8 bit character code .
DD-RAM address is the position of the cursor (ie,where the data sent will be displayed) .








The data of the LCD display according to the command register that we have sent to the instruction register of the LCD. These command determine how /where the data display on the LCD. some of the Command as follows.









picture (4)







Complete command reference:








Picture (4)




Initialization 
Initialization means starting of LCD  . Initialization can be done by two ways as follows

  1.Initialization by internal Reset Circuit .
It will happen automatically when the power is ON
An internal reset circuit automatically initializes the HD44780U when the power is turned on. The following instructions are executed during the initialization. The busy flag (BF) is kept in the busy state until the initialization ends (BF = 1). The busy state lasts for 10 ms after VCC rises to 4.5 V.
  • Display clear
  • Function set:
    DL = 1; 8-bit interface data
    N = 0; 1-line display
    F = 0; 5 x 8 dot character font
  • Display on/off control:
    D = 0; Display off
    C = 0; Cursor off
    B = 0; Blinking off
  • Entry mode set:
    I/D = 1; Increment by 1
    S = 0; No shift
If we need to initialization by internal Reset  there are certain condtions that has to be met  see the picture below .picture (5)

2. Initialization By Instruction (By our control through Microcotroller
This type of initialization  is simple.Given below is a flowchart that describes the step to follow, to initialize the LCD.

8-Bit Interface 












picture(6)
As you can see from the flow chart, the LCD is initialized in the following sequence...
1) Send command 0x30 - Using 8-bit interface
2) Delay 20ms
3) Send command 0x30 - 8-bit interface
4) Delay 20ms
5) Send command 0x30 - 8-bit interface
6) Delay 20ms
7) Send Function set - see Table 4 for more information
8) Display Clear command
9) Set entry mode command - explained below
The first 3 commands are usually not required but are recomended when you are using 4-bit interface. So you can program the LCD starting from step 7 when working with 8-bit interface. Function set command depends on what kind of LCD you are using and what kind of interface you are using 

.4-Bit Interface










picture(7)


See the circuits below to determine the difference 
4 Bit mode picture(8)


8 Bit Modepicture(9)

Simple Touch Sensor

By
Simple Touch Sensor  

There are various touch sensors in different method, such as resistive (conductive film), optical (infrared), acoustic (SAW), capacitive and etc. This project is an experiment of capacitive touch sensor. This kind of touch sensor is well known as pointing device used in portable PCs.

 

 

 

 

 

 

 

Principle of capacitive touch sensor

The capacitive touch sensor detects changes of capacitance at the electrode occured by closing a conductive object such as a finger. There are several sensing method for the capatitance. For this project, integration method that used in capacitance meter is applied. The changes of capacitance Cx is pretty small, around 1pF to 10pF, but it will able to be detected with ease because 20fF count resolution is acheved at the capacitance meter. Also the objects to be detected must be grounded to create the Cx circuit, according to the principle. However it works well even if the human body is isolated from the ground. It can be thought as the following reason.
The conductive object with a degree of surface area has a self-capacitance. In the concrete, C = 4πε0r, where at ball shape, ε0 is vacuum permittivity, r is radius. The human body has approx. 100pF in self-capacitance according to the human model for ESD test. This is large enough compared to Cx. Therefore the human body can be thought as a grounded conductor even if not grounded. Ofcourse a ground wire or a self-capacitance equivalent to the human body is required to the equipment, too. However it is coupled with earth or human body via various stray-capacitance and creates the Cx circuit.

Hardware

 The detector electrode (touch area) is a 10mm square copper plate put on the PCB and covered with an insulation overlay (Kapton tape). An ATtiny2313 with 1M ohms pull-up resister is used for the detector circuit. The integration time at normal state is determined by value of pull-up register and stray capacitance on the port and electrode. When touch the electrode with a finger, the integration time increases and can be detected the touch. The actual integration time becomes several μs to several ten μs.

Software

First, calibrate each point (get reference time due to Cs), and then start scanning in constant period. When the integration time increased and exceeded a threshold, it is judged `detected'. A hysteresis is required to the threshold, or output will not be stable at half touch. The measureing time for each point is equal to the integration time so that it can be done very fast.
The capacitance meter is measuring the integration time in resolution of one clock (100ns) with analog comparator and input capture function. However this function is not that available on all I/O pins. To implement a touch sensor on any I/O pin, the integration time is measured by software polling and the resolution becomes 3 clock (375ns). The number of time count was around 80 at normal state and it was sufficient for touch swith.
 

Firmware 


 

 

More Posts

gElectron. Powered by Blogger.

Contributors

16x2 LCD Interfacing with STM32,STM32F103C6

 16x2 LCD  Interfacing with STM32,STM32F103C6 lcd_init(); LCD_LINE1; lcd_String(" GeElectron"); LCD_LINE2; lc...

Contact Form

Name

Email *

Message *

Contact us

Name

Email *

Message *

Follow Us

https://www.facebook.com/gElectron-393939667321867/ FBbox/https://www.facebook.com/IVYthemes

Comments

[blogger]

MKRdezign

Test

Latest

[recent][newsticker]

Technology

Top Ads

RECENT COMMENTS

Subscribe Via Email

Subscribe to our newsletter to get the latest updates to your inbox. ;-)


Your email address is safe with us!

RECENT COMMENTS