先是英文资料,后面有详细的中文资料。
/devzone/cda/tut/p/id/2897Serial Instrument Control Tutorial目录1.Overview of Serial Bus2.Connecting and Setting up a Serial Instrument Control System3.How to Create a VISA Resource for the Instrument in MAX4.Instrument Control Software Articles and Related LinksOverview of Serial BusSerial is a common device communication protocol for instrument control because most computers and many remote instruments include at least one serial port. Single applications can be used across a variety of instruments with few modifications, reducingprogramming and test time.For more information on the serial protocol, including information on transfer speeds and important parameters, please refer toSerial Communication Overview.Connecting and Setting up a Serial Instrument Control SystemEngineers typically use serial to transmit American Standard Code for Information Interchange (ASCII) data. All data types are converted to strings of ASCII characters and then transmitted bit by bit across the serial bus. For two ports to communicate, both the instrument and the controlling computer must have the same baud rate, data bit size, stop bits, and parity.A basic serial instrument control system consists of four parts:1. PC2. Serial cable3. Serial instrumentAs mentioned, most computers include a serial port. The only hardware setup required is connecting the serial cable to the serial port on the PC and the serial port on the instrument. The serial instrument may include some hardware drivers or software utilities for communication, and should include documentation on the baud rate, packet size, stop bits, and parity bits that the instrumentwill use. Additionally, check the National Instruments Instrument Driver Network to see if LabVIEW drivers already exist for youtinstrument, as well has tutorials on how to use them.To confirm that the serial port on your computer is working properly, refer to Serial Communication Starting Point, to see how toperform a serial loop back test.How to Create a VISA Resource for the Instrument in MAXWith NI-VISA, communicating with your serial instrument is easy. To confirm that you are able to communicate with your instrument, open Measurement & Automation Explorer (MAX) found at Start>>Programs>>NationalInstruments>>Measurement & Automation.Figure 1. MAX Main MenuExpand the “Devices and Interfaces” subdirectory below “My System,” then expand “Serial & Parallel.” Below it you should see all the serial and parallel ports o n your computer. In this example the computer has one serial port (“COM1”) and one parallel port (“LPT1”). Figure 2 shows the directory path to the serial port and the configuration window when COM1 is selected.Figure 2. Serial Port Configuration WindowFrom this configuration window you can change the VISA Resource Name for easier identification and you can also “Open VISATest Panel” to send and receiv e communication from your serial instrument. Your instrument should have specific commands for collecting and transmitting data, and sending those commands to the instrument from the VISA Test Panel will confirm that youhave a connection.Using NI-VISA to Communicate with Your Serial InstrumentNI-VISA makes serial instrument programming fast and easy. VISA Open, VISA Read, VISA Write, and VISA Close are the basic VISA functions in LabVIEW used in the example VI in Figure 3. This example opens a VISA session to a serial device. A command is written to the device, and the response is read back. In this example the specific command being sent is the ID query for the device. Check with your device manufacturer for your device command set. After all communication is complete, the VISA sessionis closed.Figure 3. LabVIEW Serial Program Using NI-VISA/public.nsf/allkb/9F439B3D68D9072F4825703000383197串口通信的基本概念问题:我从那里能够学到串口通信的基本知识解答:串口通信的基本概念1,什么是串口?2,什么是RS-232?3,什么是RS-422?4,什么是RS-485?5,什么是握手?1,什么是串口?串口是计算机上一种非常通用设备通信的协议(不要与通用串行总线Universal Serial Bus 或者USB混淆)。
大多数计算机包含两个基于RS232的串口。
串口同时也是仪器仪表设备通用的通信协议;很多GPIB兼容的设备也带有RS-232口。
同时,串口通信协议也可以用于获取远程采集设备的数据。
串口通信的概念非常简单,串口按位(bit)发送和接收字节。
尽管比按字节(byte)的并行通信慢,但是串口可以在使用一根线发送数据的同时用另一根线接收数据。
它很简单并且能够实现远距离通信。
比如IEEE488定义并行通行状态时,规定设备线总常不得超过20米,并且任意两个设备间的长度不得超过2米;而对于串口而言,长度可达1200米。
典型地,串口用于ASCII码字符的传输。
通信使用3根线完成:(1)地线,(2)发送,(3)接收。
由于串口通信是异步的,端口能够在一根线上发送数据同时在另一根线上接收数据。
其他线用于握手,但是不是必须的。
串口通信最重要的参数是波特率、数据位、停止位和奇偶校验。
对于两个进行通行的端口,这些参数必须匹配:a,波特率:这是一个衡量通信速度的参数。