The influence of Delphi serial communication data bit length on data transfer

Source: Internet
Author: User
Tags bit set

 

For serial communication, the effect of setting data bit length on communication is

In the serial data communication, you will see the serial port parameter settings. Where the "Data bits" setting, there are four options, namely 8, 7, 6, 5. So how does changing this parameter affect the transfer of data?

I'm going to do an experiment, through the oscilloscope to observe the communication process, can analyze the results as follows:

For example, the data bit is set to 5. Then it is equivalent to specify that each transmission byte can only be represented by 5 bits, for example: 11111,10110,01110, etc. That is, this RS232 port can only send 00000~11111 the number within this range, if sent a number larger than 11111, such as 11111+1, that is, 100000, then after the processing of this RS232 port, will only send out a 00000, The receiving end can only receive 00000. This seems to send the data and receive a different, in fact, this is the length of the serial data bit determines how many bits of data he will send, the exceeded bits will not be sent.

Through the oscilloscope observation, we can clearly see that if the device is normal, and the serial port and receiver both set the data bit to 5 bits, send the following hexadecimal number, will show the following waveform:

In the serial debugging software in the sending window to enter the above four hexadecimal number, you can see through the oscilloscope of these numbers corresponding to the binary code waveform. Data bit set is 5 bits, to view the waveform from right to left, because serial communication is the first transmission low, after transmission high, so in turn read bits.

From the above observation, we can determine that if the data bit set is 5 bits, then we can send the largest number is 0x1f, that is, the binary number 11111B. The number of more than 0x1f is kept low five bits, the binary number is the number that can be received, if we set the data bit is 6 bits, then we can send the largest number is 0x3f. More than the number of 0x3f will be kept low six bits, the composition of the binary number, is capable of receiving data.

In addition, we know that an ASCII code must be represented by a 8-bit binary number, where the lower 7 bits represent the characters, and also note that in standard ASCII, the highest bit (B7) is used as the parity bit. This means that if the data bit set of the serial port transmission is 5 or 6 bits, then in this case, the serial port is unable to send out the ASCII code table values greater than 11111B (decimal 31) or 111111B (decimal 63) of the number of ASCII characters represented.

For example, we set the serial port data bit is 5 bits, we send a letter A, we know in the letter A in ASCII code decimal number is 97, binary is 1100001B, greater than 11111B. At this point only five bits can be transmitted, that is, 00001B, and the receiving end will only show the hexadecimal number 01, but not a complete letter A. A full ASCII character can be transmitted only if the data is set to be 7-bit and more than 7-bit.

The influence of Delphi serial communication data bit length on data transfer

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.