摘 要:在智能家居系統設計中,串行通信是實現上位機與下端模塊通信的最主要的手段。為了提高上位機與下端模塊的通信效率,在上位機設計時通過使用Windows的MSComm控件和自編制的串口接收發送動態控件的比較,發現利用MSComm控件雖然可以方便快捷地編制出上位機程序,但其通信效率偏低,誤幀和失幀率較高,只適用于單模塊測試。對于多模塊實時通信系統,采用其他控件或自編制收發程序更為有效。
關鍵詞:上位機; 單片機; 智能家居系統; 協議; 串行通信; MSComm控件
中圖分類號:TP18 文獻標識碼:A
文章編號:1004-373X(2010)13-0133-04
Upper Computer Control in Intelligent Home System Based on Serial Communication
JIANG Yong-chi
(Shantou Polytechnic College, Shantou515078, China)
Abstract: Serial communication is the most important communication method between upper computer control and lower model(MCU) in the design of intelligent home system. By comparison between MSComm control of Windows and self-written serial transcieving dynamic control during the design of the uppercomputer to improve the communication efficiency of the upper computer control and the model at lower end, it is found that the communication efficiency of the upper computer program written by MSComm control is low, and the rate of error-frame and lost-frame is high though the program can be written out quickly with MSComm control. Two different ways to test the serial port communication abbility and find the follow facts: MSComm control can only use in single model can′t use in a multi-model system.
Keywords: upper computer control; MCU; intelligent home system; protocols; serial communication; MSComm control
0 引 言
上位機設計是智能家居系統的一個重要組成部分,擔負著管理、控制、維護和用戶界面操作的重任,高效可靠的上位機設計是整個系統正常運作的重要保障。上位機與系統的通信實際上是與下端單片機的通信[1]。單片機或單片機系統是智能家居控制的核心,當計算機作為單片系統的一個角色時,通常被稱為“工控機”或“上位機”,各獨立的單片機是系統中實現功能的一個模塊,所以有時也稱單片機為模塊。
計算機與單片機是通過串口來實現通信的,本文著重討論計算機與單片機的串口通信的實現方法和MSComm控件技術。
1 上位機在智能家居系統的角色
首先,必須認識計算機在智能家居系統的作用,可以概括為以下幾個方面:
1.1 通信測試工具
傳統的單片機系統的通信測試通過示波器來監測,既不直觀又容易丟失信息。將計算機加入到系統中,可以實時監測到線路中的信息,并以數字化呈現,使各個單片機間的通信得到檢驗,及時解決系統存在的問題。……