史潔



摘 要:硬件電路由 AT89C51 單片機控制器、1602液晶顯示組成。 通過C語言對單片機進行控制操作。 完成了實物電路并在 Proteus 軟件的基礎上對結果進行仿真, 得到1602液晶顯示效果圖。 實驗結果表明, 在單片機顯示領域的設計開發中 Proteus 軟件具有重要的實用價值, 可以大幅縮短開發周期, 節約開發成本。
關鍵詞:液晶顯示;單片機;Proteus
中圖分類號:TP368.12 文獻標識碼:A
Abstract:The hardware circuit is composed of AT89C51 singlechip controller and 1602 LCD display. C language to control the operation of the microcontroller. Completed the physical circuit, and on the basis of Proteus software on the results of simulation, obtained 1602 LCD display effect diagram. The experimental results show that Proteus software has important practical value in the design and development of single chip display field, which can greatly shorten the development cycle and save development costs.
Keywords: liquid crystal display, SCM, Proteus
0 引言
Proteus 軟件是英國 Labcenter 公司開發的一個電路分析與實物仿真軟件, 它具有模擬電路和數字電路仿真功能,支持主流單片機及其外圍電路組成系統的仿真,提供軟件調試功能。在實際工程中,通常用 Keil 進行軟件仿真,Proteus 進行硬件仿真,并進行系統聯調;通過此方式,可以驗證系統設計方案的正確性,降低設計成本,提高產品開發效率。LCD1602液晶顯示模塊具有體積小、功耗低、顯示內容豐富、超薄輕巧等優點, 在儀器儀表中被廣泛的使用。目前,字符型液晶顯示模塊已經是單片機應用設計中最常用的信息顯示器件。LCD1602液晶顯示模塊,它可以顯示兩行,每行16個字符,采用單+5 V電源供電,外圍電路配置簡單,價格便宜,具有很高的性價比。
1 1602液晶顯示硬件電路的設計
(1)主要技術參數如表1。
(2)接口信號說明如表2。
(3)基本寫操作時序
寫指令如圖1所示。
寫數據如圖2所示。
(4)RAM地址映射圖
控制器內部帶有80×8位(80字節)的RAM緩沖區,對應關系如圖3所示。
(5)指令說明
①顯示模式設置:指令碼為38H,功能為設置16×2顯示,5×7點陣,8位數據接口。
②顯示開關及光標設置如表3。
③數據指針設置如表4。
④顯示清屏為01H,顯示回車為02H。
1602LCD液晶顯示與單片機連接電路如圖4所示。
2 1602液晶顯示軟件的設計
系統的主程序如圖5所示。
顯示單片機參考程序如下:
#include
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="danpianji";
sbit rs=P2^0;
sbit e=P2^1;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void tdata(uchar date);
void tcom(uchar com);
void lcdinit();
void main()
{uchar i;
lcdinit();
for(i=0;i<10;i++)
{
tdata(table[i]);
}
while(1);
}
void tdata(uchar date)
{rs=0;
rs=1;
e=0;
delay(2);
P3=date;
e=1;
delay(2);
e=0;
rs=0;
}
void tcom(uchar com)
{rs=1;
rs=0;
e=0;
delay(2);
P3=com;
e=1;
delay(2);
e=0;
rs=1;
}
void lcdinit()
{
tcom(0x38);
tcom(0x0c);
tcom(0x06);
tcom(0x01);
tcom(0x80+0x00);
}
3 仿真顯示
系統仿真是通過 Proteus 軟件及 Keil 軟件的聯調實現的。 首先,在 Keil 中,采用 C 語言編寫和調試源程序,生成.HEX 文件,接著在 Pro
teus 環境下編輯仿真電路圖如圖6所示,導入.HEX 文件后進行軟硬件交互仿真。
4 結論
實踐證明, Proteus 是單片機應用產品靈活、高效、正確的設計與仿真平臺,為單片機應用產品研發提供了完整的虛擬實驗室, 改革了單片機應用產品的研發過程, 為廣大單片機初學者及工程技術人員提供了單片機開發輔助手段。
參考文獻:
[1] 楊延寧,劉立軍,張志勇.基于Proteus的單片機漢字點陣顯示電路設計[J].液晶與顯示,2009(1):98.
[2] 劉飛,田承雷.單片機控制液晶顯示器[J].礦業科學技術,2005(2):9.
[3] 趙亮.液晶顯示模塊LCD1602應用[J].電子制作,2007(3).
[4] 徐瑋.51單片機綜合學習系統——1602字符型液晶顯示篇[J].電子制作,2008(1):21.