Communication device and method between single-chip microcomputer based on VB language and upper computer of testing machine

Through serial port to USB chip and VB language programming, the communication process between the microcontroller and the tester is simplified, the problems of high complexity and debugging difficulty in the existing technology are solved, and the stability and flexibility are improved.

CN120371756APending Publication Date: 2025-07-25TIANJIN PUZZIX TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510437963.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-09
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

In the prior art, the UART serial communication between the microcontroller and the tester has high complexity, poor program versatility, high debugging difficulty, and the performance status of the tester affects the communication stability.

Method used

The serial port to USB chip (such as XR21V1410IL16-F) is used to convert the serial port of the microcontroller into a USB port, and the VB language is programmed, and the communication process is simplified through hardware and software cooperation, and the communication process is achieved to achieve convenient interaction between the upper computer and the microcontroller.

Benefits of technology

It reduces program complexity, improves communication stability and flexibility, simplifies adjustments to baud rate, number of transmission bits and wait time, and reduces the probability of manual errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371756A_ABST
    Figure CN120371756A_ABST
Patent Text Reader

Abstract

The invention provides a communication device and method between a single-chip microcomputer and a testing machine upper computer based on a VB language, and belongs to the technical field of single-chip microcomputer testing. Converting an input data system; the upper computer sends data; the upper computer waits for receiving data; the upper computer processes the data system; and closing the serial port. Vectors do not need to be used, the steps of switching digital channel connection and the like are reduced, the mode that an original test machine simulates a time sequence to provide input waveforms and manually writes vectors is converted into code control, the upper computer provides the input waveforms through an external chip, the test machine does not need to participate in the whole process, the influence of the performance state of the test machine on serial port communication is eliminated, and the test efficiency is improved. Program stability is improved, and the possibility of errors caused by manual writing is reduced. Serial port communication initialization is convenient, a current program only needs to modify several initialization parameters according to requirements, baud rate modification can be met, and operation is simple.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of single-chip microcomputer testing, and particularly to a communication device and method between a single-chip microcomputer and a host computer of a testing machine based on VB language. Background Art

[0002] In the existing technology test, for the test instruction communication between the testing machine and the single-chip microcomputer, it is necessary to pass through the external peripheral interface of the single-chip microcomputer. When using UART serial communication, it is necessary to connect the digital channel of the testing machine to the RX and TX of the single-chip microcomputer. The following are mainly several aspects of inconvenience in use:

[0003] (1) To receive and send instructions, it is necessary for the testing machine to design vectors by imitating the UART serial timing, and add steps of initializing the digital channel, loading vectors, and running vectors in the program. The program complexity is relatively high.

[0004] (2) When communicating between the testing machine and the single-chip microcomputer through UART, the vector timing of the testing machine needs to be consistent with the serial port protocol (including parity check bit, number of transmission bits, baud rate, etc.) set by the single-chip microcomputer program. When facing different serial port protocol requirements, it is necessary to modify the test vector content and timing, and the program versatility is relatively poor.

[0005] (3) When the single-chip microcomputer returns data through UART, due to the lack of clock synchronization in the UART communication protocol, it is necessary for the testing machine to manually capture the returned data. After the testing machine recognizes the low level of the data transmission start bit, it needs to wait for a period of time to capture the valid data. Affected by different single-chip microcomputer attributes and data transmission frequencies, the waiting time will be different. Therefore, during the debugging process, it is necessary to adjust the waiting time according to the captured waveform of the current test chip, which increases the debugging difficulty and may lead to incorrect test results.

[0006] Therefore, there is an urgent need in the art for a test method and system that can realize convenient, fast, and accurate communication interaction between the host computer of the testing machine and the single-chip microcomputer on the test board by the cooperation of hardware and software.

[0007] The information disclosed in this background art section is only for enhancing the understanding of the overall background of the present invention, and should not be regarded as an admission or any form of suggestion that this information constitutes the prior art already known to those of ordinary skill in the art. Summary of the Invention

[0008] The object of the present invention is to provide a technical solution that can realize convenient, fast, and accurate communication interaction between the host computer of the testing machine and the single-chip microcomputer on the test board by the cooperation of hardware and software.

[0009] To achieve the above object, the present invention provides the following solutions:

[0010] A communication device between a single-chip microcomputer and a host computer of a testing machine based on VB language, comprising:

[0011] A testing machine, a host computer of the testing machine, a testing board and a single-chip microcomputer; the single-chip microcomputer is connected to the host computer of the testing machine through a USB port, and a serial-to-USB chip is used to convert the serial port of the single-chip microcomputer into the USB port.

[0012] Optionally, a driver of the serial-to-USB chip is installed in the host computer of the testing machine, so that after the host computer of the testing machine is connected to the testing board, the host computer can identify the serial port in the device manager.

[0013] Optionally, a VB control is installed in the host computer of the testing machine to provide an environment required for a VB program to configure the use of the serial port.

[0014] Optionally, the serial-to-USB chip includes a chip with the model XR21V1410IL16-F.

[0015] A communication method between a single-chip microcomputer and a host computer of a testing machine based on VB language, comprising:

[0016] Initialize the serial port;

[0017] Convert the input data base;

[0018] The host computer sends data;

[0019] The host computer waits to receive data;

[0020] The host computer processes the data base;

[0021] Close the serial port.

[0022] Compared with the prior art, the present invention has the following beneficial effects:

[0023] (1) There is no need to use vectors, reducing steps such as switching the connection of digital channels. The original method of the testing machine imitating the timing to provide the input waveform and manually writing vectors is changed to code control, allowing the host computer to provide the input waveform through an external chip, without the participation of the testing machine throughout the process, eliminating the influence of the performance state of the testing machine on serial communication, improving the program stability, and reducing the possibility of errors caused by manual writing.

[0024] (2) The initialization of serial communication is convenient. The current program only needs to modify a few initialization parameters according to requirements to meet different requirements such as baud rate modification, transmission bit number change, whether there is a parity check bit, different waiting times, input / output base change, and serial port switching on and off at any time, and the operation is simple. Description of the Drawings

[0025] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0026] Figure 1 Schematic diagram of the process steps of the communication method provided by the embodiment of the present invention.

[0027] Figure 2 Schematic diagram of the hardware connection circuit provided by the embodiment of the present invention.

[0028] Figure 3 Schematic diagram of the test line structure provided by the embodiment of the present invention.

[0029] Figure 4 Schematic diagram of the specific content of the VB code and the running steps of serial port data sending and receiving provided by the embodiment of the present invention. Detailed implementation manners

[0030] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present invention.

[0031] The purpose of the present invention is to provide a device and method that can realize convenient, fast and accurate communication interaction between the upper computer of the test machine and the single-chip microcomputer on the test board by using the cooperation of hardware and software.

[0032] To make the above objects, features and advantages of the present invention more obvious and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific implementation manners.

[0033] Embodiment 1:

[0034] This embodiment provides a communication device between a single-chip microcomputer and the upper computer of a test machine based on the VB language, including: a test machine, an upper computer of the test machine, a test board, and a single-chip microcomputer.

[0035] To connect the upper computer of the test machine to the serial port of the test board, a serial port to USB chip of model XR21V1410IL16-F is selected, which can convert the serial port at the single-chip microcomputer end into a USB port and connect it to the computer of the upper computer of the test machine for convenient connection operation. The hardware connection circuit diagram is as Figure 2 shown

[0036] The XR21V1410IL16-F is powered by 3.3V. The RX pin of the single-chip microcomputer is connected to PIN10 of the serial-to-USB chip, and the TX pin is connected to PIN9. A square USB_B female header is reserved on the test board (such as Figure 2 XW1 in Figure 3 ). When in use, one end of the square USB data cable male head is connected to the female head, and the other end USB plug is connected to the host computer of the test machine. The test line is as shown in

[0037] The software design steps include:

[0038] (1) Install the XR21V1410 chip driver: The host computer of the test machine needs to install the XR21V1410 chip driver so that after the host computer of the test machine is connected to the test board, the host computer can recognize the serial port in the device manager.

[0039] (2) Install VB controls: The MSCOMM32.OCX and MSCOMCTL.OCX controls need to be added to the program to provide the environment required for the VB program to configure the use of the serial port.

[0040] First, press Alt+F11 to enter the background program interface. Select MainForm under Project-Forms on the left and open it. Then open the ToolsBox under View.

[0041] Open Additional Controls under Tools, add Microsoft Communications Control, version 6.0, and click OK.

[0042] A small phone icon will appear in the Toolbox. Drag the small phone to UserForms1, and the serial port control addition is completed.

[0043] (3) Write VB code:

[0044] The specific content of the VB code and the running steps of serial port sending and receiving data are as shown in Figure 4 :

[0045] The process steps are as shown in Figure 1 :

[0046] Step 1: Initialize the serial port

[0047] The following code is for initializing the interface. The baud rate, parity bit, number of transmission bits, and the serial port number used can be set in this part, and the serial port is opened.

[0048]

[0049]

[0050] Step 2: Send and Receive Data

[0051] This part is the main program for sending output. In this step, the input data is converted from its original base to the decimal number required by code, and then the serial port is called to send the data to the microcontroller. Then, the for if statement is used to determine whether data has been received in the receive array, and the received data is converted to the required base.

[0052]

[0053] This part is the specific content of the sub-function tran1, which converts the input data code from other bases to decimal. The value of r can be set according to the actual base of the input data, and the current default is hexadecimal.

[0054] Public Function tran1(ByVal s As String, ByVal r As Integer) As Double

[0055] Dim n As Integer, dec As Integer

[0056] s = UCase(Trim(s))

[0057] For i% = 1 To Len(s)

[0058] If Mid(s, i, 1) >= "A" Then

[0059] n = Asc(Mid(s, i, 1)) - Asc("A") + 10

[0060] Else

[0061] n = Val(Mid(s, i, 1))

[0062] End If

[0063] dec = dec + n * r ^ (Len(s) - i)

[0064] Next i

[0065] tran1 = dec

[0066] End Function

[0067] This part is the specific content of the sub-function CommBinarySend, which sends the input data to the microcontroller.

[0068]

[0069] This part is the specific content of the sub - function CommRecvFunc, which waits to receive data for a maximum of 0.02×(timeout + 1) time, and assigns the received return data to CommRecvFunc. The value of timeOutCount can be freely modified to increase the waiting time and improve the program stability.

[0070]

[0071] This part is the specific content of the sub - function tran2, which converts the output data code from decimal to other bases. The value of r can be set according to the required output data base, and the current default is hexadecimal.

[0072] Public Function tran2(ByVal m As Integer,ByVal r As Integer)As Double

[0073] Dim StrDtoR As String,n As Integer

[0074] Do While m<>0

[0075] n = m Mod r

[0076] m = m\r

[0077] If n>9Then

[0078] StrDtoR = Chr(65 + n - 10)&StrDtoR

[0079] Else

[0080] StrDtoR = n&StrDtoR

[0081] End If

[0082] Loop

[0083] tran2 = StrDtoR

[0084] End Function

[0085] The data received through the above steps is stored in srcode and can be freely called.

[0086] Step 3: Close the serial port

[0087] The code for this part is as follows:

[0088] MainForm.MSComm1.PortOpen = False

[0089] The various embodiments in this specification are described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. For the same or similar parts among the embodiments, reference can be made to each other. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method section.

[0090] Specific examples are used in this article to elaborate on the principles and implementation manners of the present invention. The descriptions of the above embodiments are only used to help understand the method of the present invention and its core idea. At the same time, for those of ordinary skill in the art, based on the idea of the present invention, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation on the present invention.

Claims

1. A communication device between a single-chip microcomputer based on VB language and the host computer of a testing machine, characterized in that, Including: A testing machine, a host computer of the testing machine, a test board and a single-chip microcomputer; the single-chip microcomputer is connected to the host computer of the testing machine through a USB port, and a serial-to-USB chip is used to convert the serial port of the single-chip microcomputer into the USB port.

2. The communication device between the single-chip microcomputer based on VB language and the host computer of the testing machine according to claim 1, characterized in that, The driver of the serial-to-USB chip is installed in the host computer of the testing machine, so that after the host computer of the testing machine is connected to the test board, the host computer can recognize the serial port in the device manager.

3. The communication device between the single-chip microcomputer based on VB language and the host computer of the testing machine according to claim 1, characterized in that, VB controls are installed in the host computer of the testing machine to provide an environment required for the VB program to configure the use of the serial port.

4. The communication device between the single-chip microcomputer based on VB language and the host computer of the testing machine according to claim 1, characterized in that The serial-to-USB chip includes a chip with the model number XR21V1410IL16-F.

5. A communication method for a communication device between a single-chip microcomputer based on VB language and a host computer of a testing machine according to any one of claims 1-4, characterized in that, Including; Initializing the serial port; Converting the input data base; The host computer sends data; The host computer waits to receive data; The host computer processes the data base; Closing the serial port.