【正文】
sends and receives data eight bits at a time, using eight separate wires. For serial munication to work, you just need a minimum of three wires—one to send, one to receive, and one signal ground. For parallel munication, you need eight wires. Despite the paratively slower transfer speed of serial ports over parallel ports, serial munication remains a popular connectivity option for devices because of its simplicity and costeffectiveness. It shows some of the devices that use a serial port to connect to the puter. Using a serial port, you can connect to a modem, a mouse, or a device such as a bridge/router for configuration purposes. II. THE BRIEF DESCRIPTION OF SERIAL PORT COMMUNITION Serial munication is the munication between sender and receiver data transfer is in the single data line, to move each time a bit. The advantage is that only a pair of transmission lines to send information, so its low cost, suitable for longdistance munications。 it is the road receiver and driver IC chip. About MAX232 chip MAXIM MAX232 chip is produced by lowpower, singlesupply dual RS232 transmit / receiver 1 for all EIA232E and V. 28 / V. 24 munication interfaces 1MAX232 a chip 5 supply voltage converter, can+ 5V input power converted into RS 232C 177。一般來說,一個(gè)完整的通信系統(tǒng)由發(fā)射器,接收器,轉(zhuǎn)換數(shù)據(jù)接口和傳輸數(shù)據(jù)通道所構(gòu)成。正是考慮到在控制系統(tǒng)中需傳遞的數(shù)據(jù)量多,而單次傳輸?shù)臄?shù)量少,因此在控制系統(tǒng)中選擇串口通信的方法,簡化了硬件結(jié)構(gòu)并節(jié)約了所需的成本。它表現(xiàn)為一些設(shè)備使用串口連接到計(jì)算機(jī)。 開始傳輸時(shí),設(shè)備先發(fā)送一個(gè)起始位,其次是數(shù)據(jù)位。 為了檢測數(shù)據(jù)已被正確發(fā)送,一個(gè)可選的校驗(yàn)位可以同數(shù)據(jù)位在一起。而異步通信應(yīng)用于傳送速度在 50到 19200波特之間,是比較常用的傳送方式。在智能傳感器 IC 設(shè)計(jì)中,在傳感器和信號處理電路以外,通訊接口電路也可發(fā)揮重要角色。 RS232C 標(biāo)準(zhǔn) RS232C 是美國電子工業(yè)協(xié)會 (EIA)正式公布的 ,在異步串行通信中應(yīng)用最廣的標(biāo)準(zhǔn)總線。新一代的計(jì)算機(jī)有一個(gè)九針連接器( DB9),這樣就可以通過這個(gè)九針連接器來連接 RS232串行端口。 MAX232芯片簡介 MAX232是 Maxim 公司的產(chǎn)品,它是路徑接收和驅(qū)動 IC 芯片。 MAX232芯片有一個(gè)電壓轉(zhuǎn)換器,它可以改變 +5V 的電壓至所需的電壓。為了充分利用單片機(jī),以減少 CPU 的占用時(shí)間,提高溝通效率 ,控制程序?qū)⑹俏覀儠皶r(shí)響應(yīng)和控制的對象,通訊程序?qū)⒌玫絻?yōu)化。 圖 3 主要中斷服務(wù)子程序流程圖 C 判斷指令的子程序 PC 微機(jī)發(fā)送數(shù)據(jù)到單片機(jī)。因此,串口中斷設(shè)置為“關(guān)閉”狀態(tài)的單片機(jī),將它設(shè)定為“開”狀態(tài)的數(shù)據(jù)后再發(fā)送數(shù)據(jù)。 ( 4)關(guān)閉串口,供其他程序使用。在傳送數(shù)據(jù)前先聯(lián)絡(luò)地址碼 ,如地址碼正確則傳送數(shù)據(jù) ,否則繼續(xù)聯(lián)絡(luò)地址碼。該控制系統(tǒng)在產(chǎn)業(yè)領(lǐng)域運(yùn)行良好,并通過控制單個(gè)步進(jìn)電機(jī)啟動 /停止和正轉(zhuǎn) /反轉(zhuǎn)旋轉(zhuǎn)。在這里介紹查詢方式通信。在編寫程序之前 ,制定其雙方通信協(xié)議是十分重要的 ,否則將無法保證通信數(shù)據(jù)的可靠性 ,從而失去通信的意義。第二種方法是 調(diào)用Windows API(應(yīng)用程序接口)函數(shù),此函數(shù)是由操作系統(tǒng)提供,以提供大量的功能。否則,單片機(jī)判定接收到的數(shù)據(jù)是不是“停止”指令,如果是這樣,它發(fā)出“停止”指令驅(qū)動系統(tǒng),如果沒有,它便退出中斷。當(dāng)串口中斷程序接收到指定的數(shù)據(jù)時(shí),便退出串行口中斷。串行通信模塊的硬件電路如圖 2所示。 MAX232外圍需要 4個(gè)電解電容 C C C C4,是內(nèi)部電源轉(zhuǎn)換所需 電容。常見的 TTL 電平和 RS232電平之間的電平轉(zhuǎn)換芯片是MCI1488和 MCI1489。在接口電路和計(jì)算機(jī)接口芯片中大都為 TTL 或 CMOS 電平 ,所以在通信時(shí) ,必須進(jìn)行電平轉(zhuǎn)換 ,以便與 RS232C 標(biāo)準(zhǔn)的電平匹配。 USB 接口和 IEEE1394具有傳輸速度快的優(yōu)點(diǎn),但是有一些電腦和操作系統(tǒng)并不支持這種接口。通過對 8250的初始化編程,可 以控制串行數(shù)據(jù)傳送格式和速度。 大多數(shù)串行端口使用 RS232C 標(biāo)準(zhǔn) ,它指定了一個(gè) 25針或 9針的連接器。一個(gè)停止位可以是一位,一個(gè)半位,或兩位。它的缺點(diǎn)是傳送速度低。相反,一個(gè)并行端口一次發(fā)送和接收 8位數(shù)據(jù),使用 8個(gè)單獨(dú)的電線。并行通信可以同時(shí)傳輸大量的數(shù)據(jù),具有傳送速度快的優(yōu)點(diǎn)。 if not, it quits the interrupt. D. The processing subprogram of send interrupts The processing subprogram of send interrupts is responsible to send data to the puter, sending interrupt state is off in the general. When the munication program pletely deals with data sent by PC microputer, the symbol “1” can be written to send buffer. As the puter receives the symbol “1”, it is said that single chip puter executes pletely the introduction sent by PC microputer. Therefore the serial port interrupt is set as “off” state by the single chip microcontroller and it is set “on” state again after the data are sent. So the single chip microputer returns to main program and waits for receiving instructions. V. THE DESIGN OF COMMUNICATION PROGRAM OF PC MICROCOMPUTER AND SINGLE CHIP MICROCOMPUTER In order to realize the system software easily grafted and uniformity, the program of upper puter is designed using the Boland C++ Builder as a programming tool in the control system s the Boland C++ Builder as a programming tool for PC programming. The serial port munication can be utilized in two ways: First, register ponents, C++ Builder does not in itself provide a separate serial munication ponent, but it can be obtained through registered Microsoft MSComm32 ponents, in which it is relatively simple for VB, VC in this way. The second method is called Windows API (Application Program Interface) function, in which this function is provided by the operating system in order to provide a lot of executive function. The program steps are followed: (1) Setting by munication protocol and opening the serial port, which is called initialization, then blocking the other programs to use the serial port. (2) Configuring the serial port. (3) Transmitting data by the serial port to and fro, verifying data during transmission. (4) Closing the serial port as no needing it so that other program uses. The subinterface is simple, in which the setting on subinterface parameters are defaults, such as baud rate that single chip munication module has been set to 2400Bps and that the baud rate is set to 2400Bps in the puter settings on the ports. The PC microputer has two ports called as serial port COM1 and COM2 generally, so the program can automatically identify serial port so that it can send and receive data and instructions successfully. Serial munication program includes two aspects, one