Data transmission device and transmission method
By connecting the multi-channel ADC acquisition chip and the MCU chip unit to the same clock crystal, the problems of low serial port utilization and loss of channel data during data packaging and upload are solved, and efficient multi-channel data reading and acquisition are realized, reducing acquisition errors.
Patent Information
- Application Number
- CN202411996567.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-25
AI Technical Summary
In the prior art, the serial port utilization rate is low, the channel data is easily lost when data is packaged and uploaded, the multi-channel reading speed is slow, the data acquisition amount is limited, and there is acquisition error.
By connecting the multi-channel ADC acquisition chip and the MCU chip unit to the same clock crystal, the same clock frequency is provided, ensuring that the time points of data collected by all ADC chips are consistent, so that data from all channels are read simultaneously.
It realizes efficient use of the serial port baud rate, ensures real-time and integrity of data transmission, improves the multi-channel data reading speed and acquisition volume, and reduces acquisition errors.
Smart Images

Figure CN119893333A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a data transmission device and a transmission method. Background Art
[0002] Data transmission is the communication process of transmitting data from one place to another. The data transmission system usually consists of a transmission channel and data circuit terminating equipment (DCE) at both ends of the channel. In some cases, it also includes multiplexing equipment at both ends of the channel. The transmission channel can be a dedicated communication channel, or it can be provided by a data exchange network, a telephone exchange network, or other types of switching networks. The data transmission mode refers to the way in which data is transmitted on the channel. For example, according to the order of data code transmission, it can be divided into parallel transmission and serial transmission; according to the synchronization mode of data transmission, it can be divided into synchronous transmission and asynchronous transmission; according to the direction and time relationship of data transmission, it can be divided into simplex, half-duplex and full-duplex data transmission.
[0003] The main current data transmission methods include serial communication, Ethernet communication, 485 communication, 232 communication, etc., and these communication methods are mainly concentrated in the query method, that is, a question-and-answer method of hearing information.
[0004] The prior art has the following disadvantages:
[0005] 1. Low utilization of serial ports. For the current mainstream communication technologies 485, 232 and serial port communications, when the baud rate reaches 115200 baud, about 11.52 bytes can be sent per millisecond. If this is done by active upload, it basically meets the communication needs. However, this is only a theoretical sending speed. The actual active upload cannot reuse the serial port because it requires more embedded processing logic and other time-consuming operations, and may actually be far less than 1ms per data. For multi-channel instruments, this means n*4 bytes of data per second. (4 is the data size of one channel). Because the baud rate of the serial port cannot be fully utilized, the data cannot be sent quickly.
[0006] 2. Data is packaged and uploaded, and channel data is lost. The best way to improve the utilization rate of the serial port baud rate is to give it a set of data and let it send it all the time. In this way, there is no embedded logic processing time occupation and frequent configuration of the serial port, and the baud rate can be fully utilized. However, a new problem has arisen. The sent data does not have the problem of real-time performance. That is, if the current multiple channels (8 channels are taken as an example below) are directly packaged, first of all, the 8-channel data packaged at this time may not be collected at the same time. Channel 1 may have collected one data, and channel 2 has collected 3 data. If the packaged data is processed according to channel 1, then channel 2 will lose 2 data. If the acquisition rate of each channel of the instrument is equal, there will be a problem of loss sometimes. Because the amount of data collected per second is fixed. If more data is collected in the previous period, less data will be collected in the later period. In this way, there are problems with when and how to package the data.
[0007] 3. The hardware reads multi-channel communication at a slow speed. It is difficult to increase the number of channels in the instrument. To read the pressure value of a channel, you only need to use an ADC chip. However, using an ADC chip requires an interrupt to be opened for the embedded system to process the data read by the ADC. Due to the high real-time requirements for ADC data reading, this interrupt takes dozens of us for each reading. If the sampling rate is 1280, it takes dozens of milliseconds to read each channel. What's more, there is a sampling rate of 3200. And this is only data collection for one channel. If the number of channels increases, the microcontroller will not have time to execute other logics, and reading the ADC alone will take a lot of time. In this way, it is difficult to increase the number of channels.
[0008] 4. It is difficult to increase the amount of data collected. Currently, the most direct way to achieve 1000 data points per second for multiple channels is to
[0009] The most popular method is to use EtherCAT bus communication, because its communication cycle can be 1ms, and it is easy to achieve 1000Hz sampling. However, if you want to further increase the speed and collect more data, it will be more difficult. The 1ms cycle is the communication cycle that the current EtherCAT bus is adapted to. 0.5ms is a cycle that can be achieved by a small number of people, but this places high demands on both the master and slave stations. If you want to achieve a 3200Hz sampling rate, or multiple channels, this becomes very difficult.
[0010] 5. Data acquisition error. For multi-channel ADC acquisition instruments, there is also a problem of data loss as the number of channels increases.
[0011] The data acquisition time of each channel is limited, and reading is only valid within this window time, but the priority of ADC read interrupts is the same, so there is no problem of interrupt nesting. If multiple channels such as channel 1 and channel 3 collect data at the same time, it may take until channel 1 finishes reading the data, and the data reading window time of channel 3 has ended. At this time, the data cannot be read completely and will end. At this time, the read data will be wrong. This is a very serious error for data analysis and processing. Summary of the invention
[0012] The technical problem to be solved by the present invention is to provide a data transmission device and a transmission method with high serial port utilization, no loss of channel data during data packaging and uploading, fast multi-channel reading speed, large data collection volume and low collection error.
[0013] In order to solve the above technical problems, the present invention adopts the following technical solution: a data transmission device, comprising a multi-channel ADC acquisition chip, an MCU chip unit, and a crystal oscillator unit, wherein the number of the crystal oscillator unit is one;
[0014] The crystal oscillator unit input pins of the multi-channel ADC acquisition chips are shared and connected to the same crystal oscillator unit to provide the same clock frequency.
[0015] Further:
[0016] The clock communication pins of multiple ADC acquisition chips are shared and connected to the same pin of the MCU chip unit. When the clock changes, the ADC acquisition chips respond simultaneously.
[0017] Further:
[0018] The data pins of the multi-channel ADC acquisition chip are respectively connected to the corresponding pins of the MCU chip unit. Each time a clock signal is generated, multiple channels of data can be read, thereby improving the acquisition rate.
[0019] Further:
[0020] The number of ADC acquisition chips is 8, of which the crystal oscillator input pins of the 8-way ADC acquisition chips are shared and connected to the same crystal oscillator to provide the same clock frequency;
[0021] The clock communication pins of the 8-way ADC acquisition chips are shared and connected to the same pin of the MCU chip unit. When the clock changes, the ADC acquisition chips respond simultaneously.
[0022] The data pins of the 8-channel ADC acquisition chip are connected to the 8 pins of the MCU chip unit respectively, and 8 channels of data can be read every time a clock signal is generated.
[0023] Further:
[0024] The data transmission method includes a multi-channel ADC acquisition chip, an MCU chip unit, and a crystal oscillator unit. The multi-channel ADC acquisition chips share a crystal oscillator unit and provide the same clock frequency. The specific data transmission method is as follows:
[0025] S1: ADC acquisition chip data acquisition step; multiple ADC acquisition chips collect data simultaneously, and multiple ADC acquisition chips share a crystal oscillator and clock line, and data from multiple ADC acquisition chips can be collected at one time;
[0026] S2: The MCU chip unit determines whether it has received the data collection instruction. The MCU chip unit continuously detects the received instructions, and when the instruction is to collect data, it starts to collect data.
[0027] S3: The MCU chip unit determines the current data collection instruction requirements. After receiving the data collection instruction, the MCU chip unit further determines whether to collect real-time values or code values.
[0028] S4: Add the original code value to the buffer. Add the code value to the buffer according to the instruction of the previous step.
[0029] S5: Add 8 channels of real-time values to the buffer. Add real-time values to the buffer according to the instructions in the previous step.
[0030] S6: Determine whether the send buffer quantity has been reached. The MCU chip unit detects whether the buffer has reached the upload condition. If the upload condition is not reached, continue to execute S4 or S5. If the upload condition set in the buffer is reached, execute the next step.
[0031] S7: The MCU chip unit releases the semaphore to send data. The MCU chip unit releases the semaphore to synchronize threads to prevent data confusion during transmission.
[0032] S8: The sending thread receives the semaphore. After receiving the semaphore, the sending thread starts to prepare to send data; S9: Enable the mutex to send data. Enable the mutex to prevent the data from being overwritten by the interrupted data, and start sending data to the host computer.
[0033] S10: After sending, close the mutex. When the data is sent, close the mutex and hand over the buffer to the interrupt for data filling.
[0034] Further:
[0035] In step S1, there are 8 ADC acquisition chips, and 1-8 ADC acquisition chips collect data at the same time. The 8 ADC acquisition chips share a crystal oscillator and clock line, and data of 8 ADC acquisition chips can be collected at one time.
[0036] After adopting the above technical solution, the present invention has the following advantages compared with the prior art:
[0037] The present invention connects all ADC chip acquisition modules to the same clock crystal oscillator, which can ensure that the errors are the same and the time point at which each ADC chip acquires data is the same, so that data from all channels can be read simultaneously.
[0038] After testing, it can be done in about 30us to read 16 channels of data at the same time. The existing method of reading 16 channels of data acquisition without using a shared clock crystal oscillator requires 500 to 600 ms if no data is lost, which is more than 100 times different from the solution of the present invention.
[0039] The shared crystal oscillator of the present invention solves the problem of real-time data packaging and uploading. All data are collected and packaged at the same time, and there is no problem of data loss or data mismatch.
[0040] The present invention adopts a shared crystal oscillator, and all channels collect data simultaneously, thereby solving the error problem of lost data and the problem of increasing the number of channels.
[0041] The present invention adopts a shared crystal oscillator, and 8 channels can achieve a sampling rate of 3200 Hz. The sampling time of the 8 channels is not much different from the original sampling time of each channel.
[0042] The present invention adopts a one-time upload multi-channel data transmission method, which solves the problem of low serial port utilization and the problem of low real-time requirement and high data volume requirement.
[0043] The present invention adopts a method of uploading data in a package, and when packaging, all channels are transmitted into one package to preserve real-time performance. At the same time, because of the shared clock, all data are transmitted into one data frame, and the problem of mismatch in adding data time and difficulty in packaging will not occur when one channel reads data while another channel has no data, thereby ensuring real-time performance.
[0044] The present invention is described in detail below with reference to the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Attached Figure 1 This is a schematic diagram of the communication system architecture of the present invention;
[0046] Attached Figure 2 This is a schematic diagram of the connection between the ADC acquisition chip and the MCU chip unit of the present invention;
[0047] Attached Figure 3 It is a schematic diagram of the crystal oscillator unit of the present invention;
[0048] Attached Figure 4 This is a flow chart of data packaging and uploading of the present invention. DETAILED DESCRIPTION
[0049] like Figure 1-2 As shown, the data transmission device includes an 8-channel ADC acquisition chip, a crystal oscillator unit, an MCU chip unit, and an 8-channel ADC acquisition chip, wherein the crystal oscillator unit input pins of the 8-channel ADC acquisition chip are shared and connected to the same crystal oscillator unit to provide the same clock frequency to prevent errors during data acquisition.
[0050] The clock communication pins of the 8-channel ADC acquisition chips are shared and connected to the same pin of the MCU chip unit. When the clock changes, the ADC acquisition chips respond simultaneously.
[0051] The data pins of the 8-channel ADC acquisition chip are not shared, but are connected to the 8 pins of the MCU chip unit respectively. Each clock signal can read 8 channels of data, which improves the acquisition rate.
[0052] like Figure 3 As shown, the data transmission method comprises the following steps:
[0053] S1: 1-8 ADC acquisition chips collect data at the same time. Because the 8 ADC acquisition chips share the crystal oscillator and clock line, the data of 8 ADC acquisition chips can be collected at one time.
[0054] S2: Determine whether a data collection instruction is received. The MCU chip unit continuously detects the received instructions, and when the instruction is to collect data, it starts to collect data.
[0055] S3: Determine the current data collection instruction requirements. After receiving the data collection instruction, the MCU chip unit further determines whether to collect real-time values or code values.
[0056] S4: Add the original code value to the buffer. Add the code value to the buffer according to the instruction of the previous step.
[0057] S5: Add 8 channels of real-time values to the buffer. Add real-time values to the buffer according to the instructions in the previous step.
[0058] S6: Determine whether the send buffer quantity has been reached. The MCU chip unit detects whether the buffer has reached the upload condition. If the upload condition is not reached, continue to execute S4 or S5. If the upload condition set in the buffer is reached, execute the next step.
[0059] S7: Release the semaphore to send data. The MCU chip unit releases the semaphore to synchronize threads to prevent data confusion during transmission.
[0060] S8: The sending thread receives the semaphore. After receiving the semaphore, the sending thread starts preparing to send data.
[0061] S9: Enable the mutex to send data. Enable the mutex to prevent the data from being overwritten by the interrupted data, and start sending data to the host computer.
[0062] S10: After sending, close the mutex. When the data is sent, close the mutex and hand over the buffer to the interrupt for data filling.
Claims
1. A data transmission device, including a multi-channel ADC acquisition chip, an MCU chip unit, and a crystal oscillator unit, characterized in that: The number of the crystal oscillator unit is one; The crystal oscillator unit input pins of the multi-channel ADC acquisition chips are shared and connected to the same crystal oscillator unit to provide the same clock frequency.
2. The data transmission device according to claim 1, characterized in that: The clock communication pins of multiple ADC acquisition chips are shared and connected to the same pin of the MCU chip unit. When the clock changes, the ADC acquisition chips respond simultaneously.
3. The data transmission device according to claim 1, characterized in that: The data pins of the multi-channel ADC acquisition chip are respectively connected to the corresponding pins of the MCU chip unit. Each time a clock signal is generated, multiple channels of data can be read, thereby improving the acquisition rate.
4. The data transmission device according to any one of claims 1 to 3, characterized in that: The number of ADC acquisition chips is 8, of which the crystal oscillator input pins of the 8-way ADC acquisition chips are shared and connected to the same crystal oscillator to provide the same clock frequency; The clock communication pins of the 8-way ADC acquisition chips are shared and connected to the same pin of the MCU chip unit. When the clock changes, the ADC acquisition chips respond simultaneously. The data pins of the 8-channel ADC acquisition chip are connected to the 8 pins of the MCU chip unit respectively, and 8 channels of data can be read every time a clock signal is generated.
5. A data transmission method, comprising a multi-channel ADC acquisition chip, an MCU chip unit, and a crystal oscillator unit, characterized in that: Multiple ADC acquisition chips share a crystal oscillator unit and provide the same clock frequency; the specific data transmission method is as follows: S1: ADC acquisition chip data acquisition step; multiple ADC acquisition chips collect data simultaneously, and multiple ADC acquisition chips share a crystal oscillator and clock line, and data from multiple ADC acquisition chips can be collected at one time; S2: The MCU chip unit determines whether it has received the data collection instruction. The MCU chip unit continuously detects the received instructions, and when the instruction is to collect data, it starts to collect data; S3: The MCU chip unit determines the current data collection instruction requirements. After receiving the data collection instruction, the MCU chip unit further determines whether to collect real-time values or code values; S4: Add the original code value to the buffer. Add the code value to the buffer according to the instructions in the previous step; S5: Add 8 channels of real-time values to the buffer. Add real-time values to the buffer according to the instructions in the previous step; S6: Determine whether the send buffer quantity has been reached. The MCU chip unit detects whether the buffer has reached the upload condition. If the upload condition is not reached, continue to execute S4 or S5. If the upload condition set in the buffer is reached, execute the next step; S7: The MCU chip unit releases the semaphore to send data. The MCU chip unit releases the semaphore to synchronize threads to prevent data confusion during transmission; S8: The sending thread receives the semaphore. After receiving the semaphore, the sending thread starts preparing to send data. S9: Enable the mutex to send data. Enable the mutex to prevent the data from being overwritten by the interrupted data, and start sending data to the host computer; S10: After sending, close the mutex. When the data is sent, close the mutex and hand over the buffer to the interrupt for data filling.
6. The data transmission method according to claim 5, characterized in that: In step S1, there are 8 ADC acquisition chips, and 1-8 ADC acquisition chips collect data at the same time. The 8 ADC acquisition chips share a crystal oscillator and clock line, and data of 8 ADC acquisition chips can be collected at one time.