The use of serial port

Source: Internet
Author: User
Tags ftp port number

Serial communication

When exchanging information between the terminal and the computer or between the computer and the computer, in addition to using the parallel communication mode, the serial communication mode is often used. Parallel communication refers to the data of everyone at the same time, it is a bit of data transmission speed, the disadvantage is how many bits of data need to how many root transmission line, this in the number of data bits, transmission distance is not appropriate to use. Serial communication is an exponent according to the order of a single transmission, the outstanding advantage is that only a transport line, especially suitable for long-distance transmission, the disadvantage is the transmission speed is slow.

In the microcomputer measurement and control system, the current transmission of serial data mostly adopts the asynchronous communication method. Synchronous communication and asynchronous communication

Serial communication is divided into synchronous transmission and asynchronous transmission of two ways. Synchronous mode of transmission requires both parties to communicate at the same rate, and to coordinate accurately. It ensures accurate synchronization between the sender and receiver by sharing a single clock or timing pulse source.  It is characterized by the continuous sending of a sequence of characters (rather than a single character), with the same number of bits per character, with no starting and stopping bits, and high efficiency. The asynchronous transfer method does not require synchronization between the communicating parties, and the sender and receiver can have their own clock source. In order to be able to communicate, both parties must follow the asynchronous communication protocol. In asynchronous communication, both parties must specify two things: one is the character format, that is, the number of bits that are specified for each part of the character, whether parity is used, and how the checksum is applied, and the baud rate used, and the proportional relationship between the clock rate and the baud rate. Thus, the transmission efficiency of asynchronous communication is lower than that of synchronous communication, but it can reduce the synchronization requirement of both sides, so the cost is lower than the synchronous communication mode. DTE and DCE

In serial communication, the device used to send and receive data is known as a data terminal equipment (Terminal equipment, DTE). The DTE can be either a computer or a printer that only receives data. The device used to connect to the DTE and data communication network is called a Data communication device (Communications equipment, DCE) or a data circuit termination device. The DCE can be either a modem or a simple line driver. Baud rate

There is also an important indicator in serial communication-baud rate (also known as modulation rate). The baud rate is defined as the number of bits per second (bit/s), also known as "baud", that transmit binary digits. In asynchronous communication, the baud rate is the number of characters transmitted per second and the number of bits per character, for example, the rate of transmission per second is 120 characters/second, and each character contains 10 bits (1 bit starting bit, 7 bit data bit, 1 bit parity bit, 1 bit stop bit), the baud rate is:

120 characters/sec x10 bit/character = 1200 bits per second =1200 baud

Note: The baud rate is not the same as the clock frequency, the clock frequency is much higher than the baud rate, usually 16 times times or 64 times times higher. Because the two sides of the asynchronous communication with their own clock source using a higher frequency clock, in one data has 16 or 64 clocks, capturing the correct signal can be guaranteed, if the clock frequency is the baud rate, the frequency of a slight deviation will occur receive error.

Serial Communication Palette in LabVIEW

After installing labVIEW8.2, you also need to install the visa driver to use the serial port, the driver download address is:

Ftp://ftp.ni.com/support/visa/drivers/win32/4.0/visa400full.exe

The function palette of the serial port in LabVIEW is shown in the function → instrument i/o→ serial port

Here's an example of how the serial port communicates.

Example: Dual-machine communication

1. Function description

The two-machine communication is the serial communication between both computers. One computer acts as a server, sending data outward through the RS-232 serial port, and the other computer as the client, receiving data sent by the server.

2. Serial Port PIN Connection

Between the two computer serial port through a RS-232 cable connection, serial cable using three-wire system, it only uses the sending data (TxD), receive data (RxD) and Signal Ground (SG) three signal lines.

3. Server programming

The program is designed as follows:

㈠ Create a new VI and place 4 input controls on the front panel: "Port number", "baud rate", "Data Bit" and "stop Bit". In addition, place a string input control inside it to enter the string data that is sent outward. Add the program text label "Serial Server".

㈡ puts a cascading sequence structure in the program diagram, creating two branches. In the No. 0 branch, place a "Serial port Init.vi" function and add a sequential local variable, and in the 1th branch, place a "Serial port write.vi" function, They are located in Labview8.2→vi.lib→instr→serial. Connect as shown:

Front panel as shown:

4. Client programming is similar to a server program, where the "Bytes at Serial port.vi" function and the "Serial Port read.vi" are used, both of which are in the path mentioned earlier, and the client program block diagram is as follows:

Front panel as shown:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.