2010年7月12日星期一

How to interfacing LCD with printer port in C# .NET


Understand C#.NET programming to display LCD with printer port This program controls a LCD for display of string that we will be write string to printer port for control LCD. In general ,We can connect LCD with a printer port signal that
For the LCD modules,You can provide to electronic store that there are a wide range like 8x1, 8x2, 16x1, 16x2, 20x2, 20x4, 40x4. For this project ,I have used 16x2- that means 2 rows of 16 characters. It is a IC model HD44780 compatible module, having 16 pins including 2 pins for backlight source. Following table gives pin structure of LCD module. This LCD modules without backlight will have using only 14 pins. If you are using such LCDs, simply ignore 15th and 16th pins.
Pin No
Symbol
Details
1
GND
Ground
2
Vcc
Supply Voltage +5V
3
Vo
Contrast adjustment
4
RS
0->Control input, 1-> Data input
5
R/W
Read/ Write
6
E
Enable
7 to 14
D0 to D7
Data
15
VB1
Backlight +5V
16
VB0
Backlight ground
Pins Position and Wring Name of LCD module Table


Note
For more information about before starting our project LCD.
When you are using computer in full screen mode like Games, movie or TV; You need to exit the application to get a small updating information from the computer. i.e., if you need to watch time in that time, you have to close the games. But instead of that you can use LCD module to display real time from the PC and you can use it along with your application. Real time implementation from the system clock example is explained in this article. If you are good in programming, even you can connect to the internet to get news, stock exchange updates and make them flash in the LCD module, only if you found it important, you can go through it by exiting your application.
If you need to modify the code, you need not have to disconnect the circuit or re-program the chip as you do in the case of microcontroller.
You need to spend less: One LCD module, DB25 female connector, one potentiometer (optional), and some wires- this is what you need along with a computer.
In above picture LCD connection, LCD module is connected to the lpt port using D25 male connector. The Pin number 3 of the LCD is for adjusting the contrast, connected in such a way that it can be varied from 0V to 5V. Keep it to 0 initially.
If everything is OK, you should get the LCD module as follows when power is switched ON.
If you get this screen, then we can start programming. Otherwise check your connections, try by varying the 10K potentiometer. If you get this display also, you can get maximum clearness by varying the pot. For us, pot was needed to be nearly 0V. So, it is OK if you don't use pot also, just connect pin 3 to ground.
Following table explains how to write control words. When RS=0 and R/W=0, data in the pins D0 to D7 will have following meaning.
Instruction
D7
D6
D5
D4
D3
D2
D1
D0
Description
Clear Display
0
0
0
0
0
0
0
1
Clears Display and returns cursor to home position.
Cursor home
0
0
0
0
0
0
1
X
Returns cursor to home position. Also returns display being shifted to the original position.
Entry mode set
0
0
0
0
0
1
I/D
S
I/D = 0 --> cursor is in decrement position. I/D = 1 --> cursor is in increment position. S = 0 --> Shift is invisible. S = 1 --> Shift is visible
Display ON- OFF Control
0
0
0
0
1
D
C
B
D- Display, C- cursor, B- Blinking cursor = 0 --> OFF =1 --> ON
Cursor/ Display Shift
0
0
0
1
S/C
R/L
X
X
S/C = 0 --> Move cursor. S/C = 1 --> Shift display. R/L = 0 --> Shift left. R/L = 1 --> Shift right
Function Set
0
0
1
DL
N
F
X
X
DL = 0 --> 4 bit interface. DL = 1 --> 8 bit interface. N = 0 --> 1/8 or 1/11 Duty (1 line). N = 1 --> 1/16 Duty (2 lines). F = 0 --> 5x7 dots. F = 1 --> 5x10 dots.
I would like to left other instruction related to read and write LCD RAM area, we are going to see them later. Using these information, we are going to write some routines for basic functions of LCD. Please look at our this program below. There I have written functions for all our needs in LCD interfacing. So, For your next programs, we will be to change our "main" function only.
Step by Step
Open Visual Studio .NET Software.
Select menu : File-->New-->Project , and Select "Visual C# Project" on .NET software after that select "Console Application"
Go to the View Code windows .
using System;using System.Runtime.InteropServices;
namespace ParallelPort{ Private class PortAccess { Call OutPut function from DLL file. [DllImport("inpout32.dll", EntryPoint="Out32")] public static extern void Output(int adress, int value);
#include ;
#include
#include

#define PortAddress 0x378 /* Here ,Please make sure your printer port address */
#define DATA PortAddress+0
#define STATUS PortAddress+1
#define CONTROL PortAddress+2
// * I wrote a func for init ,write ,putch ,puts,goto,clear,home and entry mode for LCD which are: //
private void lcd_init(void);
private void lcd_write(char char2write);
private void lcd_putch(char char2write);
private void lcd_puts(char * str2write);
private void lcd_goto(int row, int column);
private void lcd_clear(void);
private void lcd_home(void);
private void lcd_cursor(int cursor);
private void lcd_entry_mode(int mode);
static void main()
{
Application.Run(new Form1());
lcd_init(); // start LCD function for initial
}
private void button1_Click(object sender, System.EventArgs e)
{
lcd_goto(1,1);
lcd_puts("Welcome To");
lcd_goto(1,0);
lcd_puts("LCD Wolrd");
}
private void lcd_init()
{
outportb(CONTROL, inportb(CONTROL) & 0xDF);
//config data pins as output
outportb(CONTROL, inportb(CONTROL) 0x08);
//RS is made high: control (register select)
lcd_write(0x0f);
delay(20);
lcd_write( 0x01);
delay(20);
lcd_write( 0x38);
delay(20);
}
private void lcd_write(char char2write)
{
outportb(DATA, char2write);
outportb(CONTROL,inportb(CONTROL) 0x01); /* Set Strobe */
delay(2);
outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
delay(2);
}

private void lcd_putch(char char2write)
{
outportb(CONTROL, inportb(CONTROL) & 0xF7);
//RS=low: data
lcd_write(char2write);
}
private void lcd_puts(char *str2write)
{
outportb(CONTROL, inportb(CONTROL) & 0xF7);
//RS=low: data
while(*str2write)
lcd_write(*(str2write++));
}
private void lcd_goto(int row, int column)
{
outportb(CONTROL, inportb(CONTROL) 0x08);
if(row==2) column+=0x40;
lcd_write(0x80 column);
}
private void lcd_clear()
{
outportb(CONTROL, inportb(CONTROL) 0x08);
lcd_write(0x01);
}
private void lcd_home()
{
outportb(CONTROL, inportb(CONTROL) 0x08);
lcd_write(0x02);
}
private void lcd_entry_mode(int mode)
{
outportb(CONTROL, inportb(CONTROL) 0x08);
lcd_write(0x04 + (mode%4));
}

private void lcd_cursor(int cursor)
{
outportb( CONTROL, inportb(CONTROL) 0x08 );
lcd_write( 0x0c + (cursor%4));
}
Press Ctrl + F5 to Complie and Run the porgram on Console Window(Windows is like DOS). That the LCD should be display the "Welcome To" and "LCD Wolrd" word. English is not my first language, so please excuse any mistakes. So any suggestions and/or feedback will be appreciated. Thanks for reading till here.

2010年7月5日星期一

Region banks on vertically integrated supply chains


Region banks on vertically integrated supply chains
China’s LCD module and LCD panel industries thrive in the region’s most dynamic economic zones: the Bohai Bay Economic Zone, Yangtze River Delta and Pearl River Delta. Smaller concentrations of active suppliers can also be found in Fujian and neighboring provinces.
More than 60 percent of China’s TN/STN-LCD module and LCD product suppliers are located in the Pearl River Delta. Large companies have set up production facilities in the cities of Shenzhen, Guangzhou, Dongguan and Foshan. The aggregate capacity of Truly, Tianma, Varitronix International Ltd, China Display Technology Co. Ltd, Shantou Goworld Display Co. Ltd and other large companies situated in this area accounts for about 70 percent of the local supply.
The Pearl River Delta boasts a vertically integrated supply chain for TN/STN-LCD modules. Some of the largest LCD module makers in China, including Shenzhen Shenchao, Tianma and Truly, are based in the Pearl River Delta. These companies source ITO glass, color filters, polarizers, driver ICs and backlighting units from suppliers in the area.
TFT-LCD module makers in the area get their panels from foreign-invested companies such as Innolux Display Corp., LG Electronics and Chunghwa Picture Tubes (CPT), which likewise have factories in the delta. The Pear River Delta is also home to a few companies that offer TFT-LCD terminals. Some of LCD module makers’ biggest clients, such as TV makers Konka, TCL and Skyworth, also maintain operations in the area.

The Yangtze River Delta is the major TFT-LCD module manufacturing hub in China and, arguably, the entire world. Makers of TFT-LCD modules in the delta are mostly located in Shanghai; Nanjing, Suzhou and Kunshan in Jiangsu; and Ningbo in Zhejiang. Most of these are foreign-invested enterprises with a large production capacity. Companies here, including Samsung, LG, CMO, Sharp, CPT, SVA, IVO, Epson, Wintek TPO Displays, AU Optronics Corp. (AUO) and HannStar Display Corp., specialize in large TFT-LCD modules and panels.

Makers improvise to sustain supply market

Makers improvise to sustain supply market
Makers project the decrease in order volumes that started in October 2008 will persist until late 2009. With some companies starting to feel the crunch not only in their export business but also in their domestic sales, especially with local buyers declaring bankruptcy, more suppliers are exploring ways to stay afloat.
Suppliers predict more consolidation and mergers in the next few months with more small companies dropping out of the LCD module line. At present, makers with monthly capacity exceeding 1 million number no more than 20. However, prospects are brighter for some companies that produce TN/STN- and TFT-LCD modules, specifically large-scale manufacturers, as demand inches up and costs dip.
Several companies are reducing their losses by speeding up product turnaround and locking exchange rates to those quoted when orders were placed. Other makers are acquiring automated production equipment for labor-intensive LCD module lines.
Price-wise, fluctuations are inevitable, China makers say. A 100x64 dot graphics STN-LCD module is priced at $5 to $6; a 4.3in TFT-LCD module at $18 to $19; and a 17in TFT-LCD module at $160 to $170. However, given vacillating costs and diverse applications, TFT-LCD modules are not always more expensive than TN, STN or CSTN types. For instance, some FSTN graphic LCD modules can fetch as high as $34. Makers project that prices of TN-, STN- and CSTN-LCD modules will remain stable in 2009, but quotes for TFT-LCD modules will likely fall.
About 75 percent of the cost of manufacturing LCD modules is spent on LCD panels, backlighting units and ICs. TFT panels, on the other hand, are largely sourced from tier-one companies such as Chi Mei Optoelectronics (CMO) and LG Electronics.

Product scope covers all types, technologies, applications

Product scope covers all types, technologies, applications
China LCD module makers’ product portfolio encompasses all types, interfaces and packaging of standard or customized models for the low-end, midrange and high-end markets. Makers offer dot-matrix, alphanumeric, segmented and graphics LCD modules employing TN, HTN, STN, FSTN, CSTN and TFT technologies and packaged in COG, COF, TAB and COB.
TN/STN-LCD modules are usually for entry-level finished products, including those with irregularly shaped form factors such as novelty calculators, clocks and watches. However, because of the limited applications and high technology threshold, not many China suppliers mass-produce customized models. TN/STN-LCD modules for novelty products entail a degree of customization. In some cases, makers use silkscreen or specialized printing methods.
CSTN and TFT-LCD modules are primarily for upmarket applications. These modules usually come in standard models, as the higher production overhead compared with that for TN/STN types limits makers’ customization activities.
Suppliers are cutting down their output of CSTN LCD modules in response to declining demand. As for TFT-LCD modules, makers have no immediate major production expansion plans although the popularity of TFT-LCD modules as an alternative for CSTN types continues to rise. This is largely because of the uptrend in storage and raw material costs, especially TFT panels and ICs.
Most China companies focus on TN/STN/CSTN products for communication, consumer electronics, in-car and office automation applications. More TN/STN- or TFT-LCD modules are now also being used in new-generation consumer electronic products. Suppliers forecast low-end TN/STN-LCD modules with black and white display in standard models will continue to dominate production in the coming years. However, a marked increase in demand for high-end static graphic displays will compel more companies to produce more of these products. Moreover, makers are increasingly espousing COG technique, which is less costly than COB. The COG process of IC bonding facilitates integration into end products with very small form factors.

Makers' R&D gears toward enhanced color display, clarity





















Makers' R&D gears toward enhanced color display, clarity
LCD module product development in China centers on augmenting colors and enhancing display clarity. Makers are also tapping into cost-efficient alternative raw materials and technologies.
With the cost of producing CSTN and TFT-LCD modules gradually leveling off to narrow the gap with TN/STN-LCD modules, China suppliers forecast that the transition from b/w displays to color displays will gain speed in the short term. Companies plan to step up their product development efforts and eventually increase their production of CSTN and TFT-LCD modules, especially for use in game machines, home appliances, medical instruments, dashboard status indicators and public information displays.
Development work is also underway to increase the number of STN LCD modules used for industrial applications. For LCD modules used in backlighting units, meanwhile, manufacturers are looking into techniques that will support red and composite color instead of the usual yellow, green and white.
Some China makers are employing DSTN technology to achieve a quick refresh rate. A handful of companies are boosting their capability for 4.3in TFT-LCD modules integrating a single driver IC instead of the usual two. Others make use of frosted polarizers and specialized liquid crystals as alternative to the more expensive dye liquid crystals.
As a long term-goal, China LCD module makers plan to continue R&D on ICs and backlighting units that generally improve product quality while shaving off manufacturing outlay. Their ultimate objective, makers add, is to produce modules that will afford LCDs a higher contrast ratio, wider viewing angles and a broader temperature range. Suppliers are likewise exploring methods to support end-product makers’ aims to reduce power consumption without compromising display quality.
To steer clear of IPR issues, most China suppliers have secured licenses for their production systems and have released patented models. Some companies now offer patented eight-color field sequential color LCD (FS LCD) modules and dot-matrix FS LCD modules. Others have developed patented CSTN-LCD modules for mobile phones with a display resolution that allows viewing even under direct sunlight.

LCD modules focus on true color display, clarity

China’s extensive range of LCD modules serves all markets, from low-end electronic toys to high-end TVs and entry-level mobile phones to upscale laptops. LCD modules come in three primary types and combinations thereof—TN, STN and TFT. TN/STN-LCD modules support b/w display mode suited to low-end watches, electronic counters, telephones and electrographs. STN-LCD modules are often used in industrial equipment, instruments and meters, in-car electronics, medical devices and consumer electronics. TFT-LCD modules are mainstream in full-color display mobile phones, portable DVD players, laptops, monitors and TVs. The diversity of applications alone ensures the sustainability and growth of the industry, makers say.
With the TN/STN/CSTN LCD module line entering maturity and competition from TFT-LCD modules and OLED displays reaching critical levels, a growing number of makers in China are rethinking their production focus and gravitating toward TFT-LCD modules. Declining costs and improving display quality are additional factors pushing interest in TFT-LCD modules, enabling makers of this LCD module type to slowly encroach into the market of CSTN-LCD modules, which has been strong in low-end to midrange mobile phones, MP3 and MP4 players, and PDAs with full-color displays. About 60 China companies now produce small- and medium-sized TFT-LCD modules and at least 20 offer large TFT-LCD modules.
China’s LCD module industry is composed of about 180 primary manufacturers, about 100 of which produce TN/STN/CSTN LCD modules and at least 80 turn out TFT-LCD modules. Most module manufacturers have in-house LCD panel production lines numbering more than 160. Companies that produce their own LCD panels also market these independent of their LCD modules, mostly to domestic companies.
Aside from primary LCD module makers, several small-scale companies outsource LCD panel production and engage only in LCD module assembly. These companies purchase TFT-LCD panels mostly from suppliers in Taiwan, South Korea and Japan and, thus, have less control over cost and delivery time than larger companies. Mainland China companies usually make their own TN, STN and CSTN or source from local makers. However, small companies can accommodate production on demand, flexible minimum orders and multiple models per order batch—selling points that large companies do not have.
The bulk of TFT-LCD module makers in mainland China are foreign-invested enterprises with manufacturing capability that easily outpaces that of locally owned companies. However, local makers are positive that continued capacity transfer from Taiwan, South Korea and Japan will lure more local suppliers into entering the line.