Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - The serial port of single chip microcomputer sends three groups of data to VB upper computer respectively.
The serial port of single chip microcomputer sends three groups of data to VB upper computer respectively.
First of all, you have to solve the problem of whether the data are synchronized. The frequency of computer is much faster than the clock frequency of single chip microcomputer, so serial communication chooses synchronous transmission. When the microcontroller sends the first data of the array, the host computer sends a response signal to the microcontroller after receiving this data, and then the microcontroller sends the second data to the host computer after receiving the response signal, and so on (the specific value of the response signal is defined by your communication protocol).

Second, your vb should add MSComm controls, refer to the article.

/linkurl = gabsjbhsdk 9 b _ th L3 f 1x ypprzgpit 6 wczghwxe _ h _ 1 Q 8 icdfprp _ Q-FQ 4 jlsbt _ r _ d 8 gztrs _-sa 9956 ohq 0 xd 9 ahbc 6 sa 4d-_ omQVAlXG

Program for controlling MSComm to receive data:

Private submiscomm1_ oncom ()

Dim indata as a variant

Display bte(0) as bytes.

Select MSComm 1 case. CommEvent

Case 2

indata = MSComm 1。 invest

bte(0) = AscB(indata)

If bte(0) = the first value of the array.

Then MSComm 1. Output = response signal 1.

text 1.text=bte(0)

If ... it will be over.

If bte(0) = the second value of the array, MSComm 1. Output = response signal 2.

text2.text=bte(0)

If ... it will be over.

If bte(0) = the third value of the array, then MSComm 1. Output = response signal 3.

text3.text=bte(0)

If ... it will be over.

MSComm 1。 OutBufferCount = 0

End selection

End joint