Multi-instrument serial port data acquisition system and method
By using a multi-instrument serial port data acquisition system, which dynamically binds and configures interface parameters and protocol conversions, the problem of accessing heterogeneous instruments nearby is solved, achieving efficient data acquisition and simplified configuration, and reducing construction and maintenance costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2026-03-10
AI Technical Summary
In energy metering data acquisition, heterogeneous instruments in dispersed locations cannot be wired locally due to differences in protocols and communication parameters. This requires laying long communication cables, which wastes materials and time. Furthermore, instrument replacement requires rewiring and system parameter adjustment, making the operation complex.
The system employs a multi-instrument serial port data acquisition system, which has active acquisition and protocol conversion capabilities. By dynamically binding the configured acquisition interface parameters, it supports instruments with different communication parameters and protocols to access the bus nearby. The system acquires data in real time and converts it into Modbus RTU protocol. It also supports Bluetooth configuration parameters, eliminating the need for rewiring and wiring debugging.
It reduced the amount of networking materials and engineering work, improved data acquisition efficiency, simplified system configuration and maintenance, reduced labor time consumption, and enabled the convenience of remote configuration.
Smart Images

Figure CN121644584A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of Internet of Things (IoT) technology, specifically a multi-instrument serial port data acquisition system and method. Background Technology
[0002] Currently, when implementing energy metering instrument data acquisition projects, the instruments are usually connected to the acquisition gateway or acquisition conversion device in a "daisy-chain" manner using the 485 interface. The instruments connected to each daisy-chain bus are usually required to have the same communication protocol and communication parameter type. The number of instruments connected depends on the acquisition frequency of the host computer or the physical link distance.
[0003] If a site contains a variety of instruments with different protocols and communication parameters that cannot be modified, and given the existing data acquisition equipment, devices with the same communication parameters and protocols are typically connected to a single bus or conversion device. However, the number of devices connected to a single bus of the acquisition equipment cannot exceed the acquisition cycle limit. Therefore, due to the constraints of instrument IoT distribution and instrument acquisition cycle indicators, the "nearest connection" principle often cannot be followed, leading to the need to lay longer 485 communication cables, resulting in waste of communication cables, acquisition equipment interfaces, and construction costs.
[0004] After the on-site network data collection is completed, if instruments need to be replaced, it is usually necessary to rewire and re-network, and adjust system parameters using configuration tools or software such as laptops. If the equipment to be adjusted is installed in a high or inconvenient location, various safety permits need to be applied for and multiple people need to accompany the operation. This not only wastes materials and time, but also causes inconvenience to the on-site workers.
[0005] Therefore, how to reduce the construction and material consumption of heterogeneous instruments in dispersed locations under network data acquisition conditions, reduce the need for rewiring due to instrument replacement, and simplify the difficulty of close-range configuration has become an important challenge that urgently needs to be solved. Summary of the Invention
[0006] To address the aforementioned technical problems, this invention provides a multi-instrument serial port data acquisition system and method. The acquisition system possesses active acquisition and protocol conversion capabilities. By dynamically binding configured acquisition interface parameters, the system supports the connection of instruments with different communication parameters and protocols according to the principle of proximity to the bus. The system can acquire data from various instruments on the bus in real time and uniformly convert four common industry protocols and the Modbus protocol into the Modbus RTU protocol, enabling upper-layer devices to obtain the acquired data from all instruments on the bus in a single read, thereby improving response speed and reducing the requirements on the upper-layer bus and acquisition devices. When instruments are changed, only the acquisition system parameters need to be reconfigured, without the need for rewiring and renetworking. Furthermore, the acquisition system supports parameter configuration via Bluetooth, eliminating the need for on-site wiring, debugging, or other complex operations, thus reducing materials and labor time.
[0007] The technical solution adopted by the present invention to achieve the above objectives is as follows:
[0008] A method for acquiring data via serial port of multiple instruments includes the following steps:
[0009] The mobile app configures the data collection parameters;
[0010] Data interaction occurs between the mobile device and the data acquisition device.
[0011] The data acquisition device collects and stores the data.
[0012] The mobile device configures the collection parameters, including the following steps:
[0013] Read the current parameter configuration information on the device;
[0014] Configure the Modbus RTU slave address, function code, byte order, and CRC order of the local machine;
[0015] Configure the communication interface layer parameters, instrument link layer parameters, and variable application layer parameters of each instrument under the bus in sequence;
[0016] The configuration information is generated into a JSON format configuration file and sent to the data acquisition device via Bluetooth.
[0017] The data interaction between the mobile terminal and the data acquisition device includes the following steps:
[0018] 1) The data acquisition device receives data sent from the mobile terminal and determines whether the received data is a JSON format configuration file. If it is configuration data, proceed to step 2); otherwise, proceed to step 3).
[0019] 2) Parse the distributed JSON configuration file, generate and store the configuration parameters for each module, and write the parameter configuration to the ModbusRTU slave station.
[0020] 3) Determine if the received data is a command to report a configuration file. If it is a command, proceed to step 4); otherwise, do not process it.
[0021] 4) Read the various collection configurations and report them to the mobile device via Bluetooth according to the JSON configuration file format.
[0022] The data acquisition and storage process at the acquisition device includes the following steps:
[0023] (1) Read the successfully parsed parameter data, and according to the uncollected instruments in the read configuration file, read the communication interface layer parameters of the instrument that should be executed, and complete the serial port parameter settings on the device side.
[0024] (2) Based on the current instrument link layer parameters and variable application parameters, call the instrument protocol, generate query frames according to the task order and send them;
[0025] (3) Determine whether a response frame has been received within the timeout period. If a response frame has been received, proceed to step (4); otherwise, assume there is no response and proceed to step (5).
[0026] (4) Parse the received response frame according to the variable application parameters and the instrument protocol, and store the parsing result in the corresponding ModbusRTU slave register according to the mapped data format;
[0027] (5) Determine whether all query frames in the current instrument have been sent. If they have been sent, proceed to step (6); otherwise, return to step (2).
[0028] (6) Determine whether the data acquisition of the instrument in this task cycle is completed. If it is completed, proceed to step (2); otherwise, return to step (1).
[0029] (7) Determine whether the ModbusRTU slave is enabled. If not, enable the northbound ModbusRTU slave of the current device; otherwise, reset all instrument acquisition flags in the configuration file to incomplete, continue to execute the acquisition task of the next cycle, and return to step (1).
[0030] The timeout range is the product of the number of timeouts and the timeout duration set in the instrument link layer parameters.
[0031] A multi-instrument serial port data acquisition system includes: a mobile terminal and a data acquisition device terminal, wherein:
[0032] The mobile device includes:
[0033] The data acquisition parameter configuration module is used to configure the data acquisition parameters and generate a JSON file to be sent to the data acquisition system device.
[0034] The data acquisition device includes:
[0035] The Bluetooth communication module is used for data exchange between the mobile device and the data acquisition device.
[0036] The configuration storage module is used to parse JSON files, generate and store the configuration parameters of each module, and write the configuration parameters of ModbusRtu slave stations.
[0037] The protocol storage module is used to store various types of protocols and specifications supported by the data acquisition system.
[0038] The ModbusRTU slave module is used to receive relevant configuration parameters and data writes, configure parameters, enable control and prepare data for the data acquisition system, and provide a ModbusRTU access interface to the outside world.
[0039] The main control module is used to manage the various modules and interact with them.
[0040] The main control module for data acquisition specifically performs the following tasks: configuring communication interface layer parameters, generating and sending acquisition query frames, receiving and parsing response data frames, and mapping data to Modbus RTU slave modules.
[0041] The present invention has the following beneficial effects and advantages:
[0042] 1. Compatibility and Resource Conservation: The data acquisition system supports the access of instruments with different communication parameters and protocols to the bus by dynamically binding the configured acquisition interface parameters. This makes the system compatible with various types of instruments, reduces the amount of networking materials and engineering work, and meets the needs of various application scenarios.
[0043] 2. High-efficiency data acquisition and conversion: The system supports the unified conversion of four types of industry protocols and the Modbus protocol into the Modbus RTU protocol. Furthermore, the system acquires data from various instruments on the bus in real time, allowing northbound devices to obtain all instrument data on the bus in a single read. This significantly improves data acquisition efficiency, reduces data transmission latency, enhances system response speed, and lowers the performance requirements for the upper-layer bus and acquisition devices.
[0044] 3. Simplified system configuration and maintenance: When tables change, only the parameters of the data acquisition system need to be reconfigured, without the need for rewiring or renetworking. This greatly reduces the complexity of system adjustment and maintenance, saving human and material resources.
[0045] 4. Convenient remote configuration and debugging: The data acquisition system supports parameter configuration via Bluetooth, which eliminates the need for technicians to approach the equipment for wiring, debugging, or other complex operations. This greatly improves the convenience of configuration and debugging and reduces material consumption and labor time. Attached Figure Description
[0046] Figure 1 A schematic diagram of the data acquisition system of this invention;
[0047] Figure 2 Workflow diagram of the data acquisition parameter configuration software of this invention;
[0048] Figure 3 Flowchart of the interaction between the device and the parameter acquisition configuration software of this invention;
[0049] Figure 4 The device-side data acquisition and storage flowchart of this invention;
[0050] Figure 5 A standard instrument network wiring diagram;
[0051] Figure 6 This invention includes an instrument networking circuit diagram;
[0052] Figure 7 The present invention provides a mapping diagram for converting multi-device variables into a global Modbus RTU variable. Detailed Implementation
[0053] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments.
[0054] This invention provides a multi-instrument serial port data acquisition system, applied to data acquisition equipment, characterized in that the multi-instrument serial port data acquisition system is as follows: Figure 1 As shown, it includes:
[0055] The data acquisition parameter configuration software is located on the mobile terminal of the data acquisition system, and the Bluetooth communication module, configuration storage module, protocol storage module, Modbus RTU slave module, and data acquisition master control module are located on the device terminal of the data acquisition system.
[0056] The collected parameters include Modbus RTU slave station, communication interface layer, instrument link layer, and variable application layer.
[0057] The data acquisition parameter configuration software enables detailed configuration of the data acquisition parameters on the device side and generates a JSON file of the configuration information, which is then sent to the data acquisition system device side. Specifically, this includes configuring Modbus RTU slave parameters, configuring communication interface layer parameters, instrument link layer parameters, configuring variable application parameters, and the specific configuration items for each of the above configuration processes.
[0058] The configuration items for Modbus RTU slave parameters include: local slave address, function code, byte order, and CRC order;
[0059] The configuration items for configuring the communication interface layer parameters include: baud rate, data bits, stop bits, and parity bits;
[0060] The configuration items for configuring the instrument link layer parameters include: instrument protocol type, instrument address, timeout time, number of timeouts, inter-frame interval, protocol function code, and CRC check order;
[0061] The configuration items for the application layer parameters of the configuration variables include: variable offset address, data length, data type, byte order, precision information, variable mapping address, and variable mapping data type;
[0062] The Bluetooth communication module is used to enable contactless two-way data transmission between mobile devices and other devices.
[0063] The configuration management module is used to parse the JSON configuration file sent by the data acquisition parameter configuration software via Bluetooth, generate and store the configuration parameters of each module, and write the configuration parameters of the ModbusRTU slave station.
[0064] The protocol storage module is used to store various types of protocols and specifications supported by the data acquisition system, including CJT188, DLT645-1997, DLT645-2007, DLT698.45 protocols and ModbusRTU and ModbusASCII protocols.
[0065] The Modbus RTU slave module is used to receive relevant configuration parameters and data writes, complete the configuration of local slave address, function code, byte order, CRC order parameters, enable control and data preparation, and provide Modbus RTU access interface to the outside world.
[0066] The main acquisition module is responsible for the management, coordination, and overall control of the entire system. Its main functions include data interaction with various modules, configuration of communication interface layer parameters, generation and transmission of acquisition query frames, reception and parsing of response data frames, and mapping and storing the parsed data into the Modbus RTU slave modules.
[0067] A multi-instrument serial port data acquisition method includes a mobile terminal acquisition parameter configuration software workflow, a device-side interaction workflow with the acquisition parameter configuration software, and an acquisition and storage workflow.
[0068] The workflow of the mobile terminal parameter acquisition and configuration software is as follows: Figure 2 As shown, it includes the following steps:
[0069] S1: Power on the system device. Open the mobile device's parameter acquisition and configuration software interface, search for Bluetooth, select and connect to the system device's Bluetooth;
[0070] S2: In the parameter configuration software interface, click the command to read the configuration file, read the current parameter configuration information of the device, and display it in the interface;
[0071] S3: Configure the ModbusRTU slave address, function code, byte order and CRC order of the device;
[0072] S4: Configure the communication interface layer parameters, instrument link layer parameters, and variable application layer parameters of each instrument on the bus in sequence;
[0073] S5: Click the "Generate Configuration File" button to generate a JSON format configuration file from the entered configuration information;
[0074] S6: Click the "Send Configuration File" button to send the JSON format configuration file to the system device.
[0075] The interaction process between the device and the parameter configuration software is as follows: Figure 3 As shown, it includes the following steps:
[0076] S11: The Bluetooth module is waiting to receive data from the parameter configuration software;
[0077] S12: The main control module determines whether the received data is a JSON format configuration file. If it is configuration data, S13 is executed; otherwise, S15 is executed.
[0078] S13: The configuration management module processes configuration information, parses the issued JSON configuration file, generates and stores the configuration parameters of each module, and writes the parameter configuration to the ModbusRTU slave station. After all this is completed, S14 is executed.
[0079] S14: System restart;
[0080] S15: The main control module determines whether the received data is a command to report a configuration file. If it is a command to report, then execute S16; otherwise, do not process it.
[0081] S16: The configuration management module reads various collection configurations and reports them to the parameter configuration software on the mobile terminal via the Bluetooth module system in JSON configuration file format.
[0082] Furthermore, the parameter configuration of the Modbus RTU slave includes writing the local slave address, function code, byte order, and CRC order.
[0083] The device-side data acquisition and storage process is as follows: Figure 4As shown, it includes the following steps:
[0084] S21: The main control module first reads the successfully parsed parameter data from the configuration management module;
[0085] S22: The main control module sorts the instruments that have not been acquired in the read configuration file, reads the communication interface layer parameters of the instrument that should be executed, and completes the serial port parameter settings on the device side.
[0086] S23: Based on the current instrument link layer parameters and variable application parameters, call the instrument protocol in the protocol storage module, generate query frames according to the task order, and send them;
[0087] S24: The main control module determines whether a response frame has been received within the timeout period. If a response frame is received, proceed to S25; otherwise, it is considered that there is no response, and proceed to S26.
[0088] S25: The main control module parses the received response frame according to the variable application parameters and the instrument protocol, and stores the parsing results in the corresponding ModbusRTU slave register according to the mapped data format;
[0089] S26: The main control module determines whether all query frames in the current instrument have been sent. If they have been sent, it means that the current device has completed the acquisition and then executes S27; otherwise, it means that the current device has not yet completed the acquisition and then executes S23 to continue the acquisition task of the current device.
[0090] S27: The main control module determines whether the data acquisition of the instruments in this task cycle is complete. If it is complete, execute S28; otherwise, it means that there are still instruments that have not been acquired. Execute S22 and continue to execute the acquisition tasks of other devices.
[0091] S28: The acquisition master control module determines whether the Modbus RTU slave station is enabled. If it is not enabled, proceed to S29; otherwise, proceed to S30.
[0092] S29: The acquisition master control module enables the northbound Modbus RTU slave station of the current device;
[0093] S30: The main control module resets all instrument acquisition flags in the configuration file to incomplete, and continues to execute the acquisition task for the next cycle, executing S22.
[0094] Furthermore, the so-called communication interface layer parameters include baud rate, data bits, stop bits, and parity bits.
[0095] Furthermore, the so-called task order refers to the arrangement order of multiple query frames for a device in the configuration file.
[0096] Furthermore, the so-called timeout range refers to the product of the number of timeouts and the timeout duration set in the instrument link layer parameters.
[0097] Furthermore, enabling a Modbus RTU slave means that the current system allows external devices to read data from the Modbus RTU slave and generate response data on the device side. When the slave is not enabled, the device will not send any response data.
[0098] Example
[0099] The factory's energy metering instruments mainly include water, electricity, gas, and heat meters, distributed throughout the factory according to the pipeline and line layout. In practical applications, the instruments whose data are collected typically need to be converted and networked, and then connected to the data acquisition gateway through network conversion equipment. That is, there is usually a device-network-gateway structure.
[0100] In this example, the instruments are generally dispersed, but relatively clustered in some areas. There are three different types of instruments in a certain area of the site: a steam totalizer, a gas meter, and an electricity meter.
[0101] The integrator uses Modbus RTU protocol with byte order ABCD. The baud rate range is 1200-9600, with 8 data bits, 1 stop bit, and NONE parity. Data collected includes: cumulative flow, instantaneous flow, temperature, and pressure. The corresponding instrument protocol point table is as follows:
[0102] Table 1. Parameter Points of a Certain Integrator
[0103] address Data types describe illustrate 0006H floating point Instantaneous mass t / h 0008H hexadecimal fixed point Cumulative quality t 000AH floating point temperature ℃ 000CH floating point pressure MPa
[0104] The gas meter uses Modbus RTU protocol, with byte order ABCD. The baud rate is 9600, with 7 data bits, 2 stop bits, and a null parity bit. Data collected includes: standard condition cumulative flow, standard condition instantaneous flow, temperature, and pressure. The corresponding meter protocol point table is as follows:
[0105] Table 2. Parameter Points of a Gas Meter
[0106] address Data types describe illustrate 204 Double Standard condition cumulative flow <![CDATA[m 3 ]]> 210 Float Standard instantaneous flow <![CDATA[m 3 / h]]> 212 Float pressure kPa 214 Float temperature ℃
[0107] The meter uses the DLT645-2007 protocol with a baud rate of 2400, 8 data bits, 1 stop bit, and EVEN parity bit. Data collected includes: total positive active energy and total active power. The corresponding meter protocol points comply with the DLT645-2007 protocol.
[0108] Because these three instruments have inconsistent protocols and communication parameters, they typically need to be connected separately to their respective RS-485 buses to the upstream device, making it impossible to form a daisy-chain network. Figure 5As shown. In this embodiment, the solution of the present invention supports connecting the 485 interfaces of three instruments in series using a data cable, and uniformly connecting them to the upper-level device through the data acquisition system equipment terminal, such as... Figure 6 As shown.
[0109] After completing the connection between the bus and the device, the operator still needs to configure the device parameters by performing the following operations:
[0110] 1) Power on the system device. Open the mobile device's parameter acquisition configuration software interface, search for Bluetooth, select and connect to the system device's Bluetooth.
[0111] 2) In the parameter configuration software interface, click "Issue Read Command" to read the current parameter configuration information of the device.
[0112] 3) Configure the Modbus RTU slave address of this machine to 01, the function code to 03, the byte order to ABCD (high byte first), and the CRC order to BA (low byte first).
[0113] 4) First, configure the communication interface layer parameters of the integrator. Configure the baud rate to the default value of 9600, the data bits to 8, the stop bits to 1, and the parity bit to NONE.
[0114] 5) Configure the integrator's link layer parameters, set the instrument protocol type to ModbusRTU, the instrument address to the same table display value as 2, the timeout time to 3000ms, the timeout count to 1, the inter-frame interval to 100ms, the protocol function code to 03, and the CRC check sequence to BA.
[0115] 6) Configure the application layer parameters for the totalizer variables, including:
[0116] Instantaneous parameters: offset address is 6, data type is Float, byte order is ABCD; mapping address is 0, mapping data type is Float;
[0117] Cumulative parameters: offset address is 8, data type is UnsignedLong, byte order is ABCD; mapping address is 2, mapping data type is Float;
[0118] Temperature parameters: offset address is 10, data type is Float, byte order is ABCD; mapping address is 4, mapping data type is Float;
[0119] Pressure parameters: Offset address is 12, data type is Float, byte order is ABCD; mapping address is 6, mapping data type is Float.
[0120] 7) Next, configure the communication interface layer parameters of the gas meter, setting the baud rate to 9600, data bits to 7, stop bits to 2, and parity bits to NONE.
[0121] 8) Configure the gas meter link layer parameters, set the meter protocol type to ModbusRTU, the meter address to the default value of 1, the timeout time to 3000ms, the number of timeouts to 1, the inter-frame interval to 100ms, the protocol function code to 03, and the CRC check sequence to BA.
[0122] 9) Configure the integrator variable application layer parameters, including:
[0123] Instantaneous parameters: offset address is 204, data type is Double, byte order is ABCD; mapping address is 8, mapping data type is Double;
[0124] Cumulative parameters: Offset address is 210, data type is Float, byte order is ABCD; Mapping address is 12, mapped data type is Float;
[0125] Temperature parameters: offset address is 212, data type is Float, byte order is ABCD; mapping address is 14, mapping data type is Float;
[0126] Pressure parameters: offset address is 214, data type is UnsignedLong, byte order is ABCD; mapping address is 16, mapping data type is Float.
[0127] 10) Finally, configure the communication interface layer parameters of the meter, setting the baud rate to 2400, data bits to 8, stop bits to 2, and parity bits to EVEN.
[0128] 11) Configure the gas meter link layer parameters, configure the meter protocol type as DLT645-2007, the meter address as displayed on the meter and the meter nameplate value as 000000000006, the timeout time as 3000ms, the number of timeouts as 1, and the inter-frame interval as 100ms.
[0129] 12) Configure the application layer parameters for the totalizer variables, including:
[0130] Forward active power parameters: the mapped address is 18, and the mapped data type is Float;
[0131] Active power parameters: Mapped address is 20, and the mapped data type is Float.
[0132] 13) Click the "Generate Configuration File" button to generate a JSON format configuration file from the entered configuration information.
[0133] 14) Click the "Send Configuration File" button to send the JSON format configuration file to the device system.
[0134] After receiving the completed configuration, the device restarts and executes the data acquisition and storage process:
[0135] 1) The main control module first reads the parsed parameter data from the configuration management module.
[0136] 2) The main control module reads the communication interface layer parameters of the totalizer according to the uncollected meters in the configuration file, in the order of totalizer, gas meter, and electricity meter, and completes the serial port parameter settings on the device side.
[0137] 3) Based on the instrument link layer parameters and variable application parameters of the integrator, call the instrument protocol in the protocol storage module, generate one query frame in the order of tasks, with the format: 02 03 00 06 00 08A4 3E, and send it.
[0138] 4) A response frame is received within the timeout range, with the following format: 02 03 10 3F 48EF 35 00 00 66 5F43 2EB3 33 3D 97 58E2 D7 AA.
[0139] 5) The main control module parses the received response frames according to the variable application parameters and instrument protocol, converting the UnsignedLong type 00 00 66 5F to the Float type 46CC BE 00, and stores the parsing result in the corresponding ModbusRTU slave register. For example:
[0140] Register addresses 0-1 are stored in 3F48 EF35;
[0141] Store 46CC BE00 at register address 2-3;
[0142] Register addresses 4-5 are stored in 432E B333;
[0143] Register addresses 6-7 are stored in 3D97 58E2.
[0144] 6) If the main control module determines that all query frames in the current instrument have been sent and the data acquisition of the instrument in this task cycle has not been completed, it will execute the acquisition process of the next instrument.
[0145] 7) Read the communication interface layer parameters of the gas meter and complete the serial port parameter settings on the device side.
[0146] 8) Based on the meter link layer parameters and variable application parameters of the gas meter, call the meter protocol in the protocol storage module, generate one query frame in the order of tasks, with the format: 01 03 00CC 00 0C 85F0, and send it.
[0147] 9) A response frame is received within the timeout range, with the following format: 01 03 18 41 38 33ED 20 00 00 0000 0000 00 41 72 3D 71 3D DD 49 52 41F0 A3 D7 2E 75.
[0148] 10) The main control module parses the received response frames according to the variable application parameters and instrument protocol, and stores the parsing results in the corresponding Modbus RTU slave register. For example:
[0149] Register addresses 8-11 are filled with 4138 33ED 2000 0000;
[0150] Register addresses 12-13 are stored in 4172 3D71;
[0151] Register addresses 14-15 are stored in 3DDD 4952;
[0152] Register addresses 16-17 are stored in 41F0 A3D7.
[0153] 11) If the main control module determines that all query frames in the current instrument have been sent and the data acquisition of the instrument in this task cycle has not been completed, it will execute the acquisition process of the next instrument.
[0154] 12) Read the communication interface layer parameters of the electricity meter and complete the serial port parameter settings on the device side.
[0155] 13) Based on the meter link layer parameters and variable application parameters of the meter, call the meter protocol in the protocol storage module, generate the first query frame according to the task order, with the format: 68 06 00 00 00 00 00 6811 04 33 33 3433B8 16, and send it.
[0156] 14) A response frame is received within the timeout period, in the following format: 68 06 00 00 00 00 00 68 91 0833 3334 33 8C 38 87 46CD 16.
[0157] 15) The main control module parses the received response frame according to the variable application parameters and instrument protocol, converts the result 135405.59 into a Float type 48 04 3B 66, and stores the parsing result in the corresponding ModbusRTU slave register. For example, register address 18-19 stores 4804 3B66.
[0158] 16) The main control module determines that the query frame in the current instrument has not been completely sent, generates the second query frame with the format: 68 06 00 00 00 00 00 68 11 04 33 33 36 35BC 16, and sends it.
[0159] 17) A response frame is received within the timeout period, in the following format: 68 06 00 00 00 00 00 68 91 0733 3336 35 5A C8 58B9 16.
[0160] 18) The main control module parses the received response frame according to the variable application parameters and instrument protocol, converts the result 25.9527 into a Float type 41CF 9F 21, and stores the parsing result in the corresponding ModbusRTU slave register. For example, register address 20-21 is stored in 41CF 9F21.
[0161] 19) The main control module determines that the instrument's data acquisition task has been completed, and the data acquisition for this task cycle has been completed. This achieves the mapping of Modbus RTU protocol for three different types of instruments, such as... Figure 7 As shown.
[0162] 20) The main control module resets all instrument acquisition flags in the configuration file to "incomplete" and continues to execute the acquisition task for the next cycle. At the same time, it enables any Modbus RTU slaves that are not currently active.
[0163] After the ModbusRTU slave station is enabled, the host computer can send commands to read all the collected instrument point data through the device's northbound 485 interface, according to the configured ModbusRTU protocol parameters and register mapping table. For example, the host computer can send an inquiry command: 01 03 00 00 00 16C4 04.
[0164] The device will send the following response: 01 03 2C 3F 48EF 35 46CC BE 00 43 2E B3 33 3D97 58E241 38 33ED 20 00 00 00 41 72 3D 71 3D DD 49 52 41F0 A3 D7 4804 3B 66 41CF 9F21 51CC, returning all collected data at once, thus achieving the data that previously required four queries.
[0165] Building upon this example, when replacing the electricity meter with one that supports the DLT645-2007 protocol infrared interface, simply use mobile parameter configuration software via Bluetooth to change the baud rate configuration in the communication interface layer parameters to 1200. This will enable normal data acquisition without the need for rewiring or using other debugging tools.
Claims
1. A method for multi-instrument serial port data acquisition, characterized in that, It comprises the following steps: The mobile terminal configures the collection parameters; The mobile terminal and the collection device terminal interact with each other; The collection device terminal collects and stores data.
2. The method of claim 1, wherein, The mobile terminal configures the collection parameters, which comprises the following steps: Read the current parameter configuration information of the device terminal; Configure the ModbusRTU slave address, function code, byte sequence and CRC sequence of the local machine; Configure the communication interface layer parameters, instrument link layer parameters and variable application layer parameters of each instrument under the bus in turn; Generate a JSON format configuration file from the configuration information and deliver it to the collection device terminal through Bluetooth.
3. The method of claim 1, wherein, The mobile terminal and the collection device terminal interact with each other, which comprises the following steps: 1) The collection device terminal receives the data delivered by the mobile terminal and judges whether the received data is a JSON format configuration file. If it is configuration data, step 2) is executed, otherwise step 3) is executed. 2) Analyze the delivered JSON configuration file to generate configuration parameters for each module and store them, and write the parameters of the ModbusRTU slave station; 3) Judge whether the received data is a report configuration file command. If it is a report command, step 4) is executed, otherwise it is not processed. 4) Read each collection configuration and report it to the mobile terminal in JSON configuration file format through Bluetooth.
4. The method of claim 1, wherein, The collection device terminal collects and stores data, which comprises the following steps: (1) Read the parsed parameter data and sort the instruments that have not been collected according to the configuration file. Read the communication interface layer parameters of the current instrument and complete the serial port parameter setting of the device terminal; (2) According to the instrument link layer parameters and variable application parameters of the current instrument, call the instrument protocol, generate inquiry frames and send them according to the task sequence; (3) Judge whether a response frame is received within the timeout range. If a response frame is received, step (4) is executed; otherwise, it is considered that there is no response, and step (5) is executed. (4) According to the variable application parameters and instrument protocol, analyze the received response frame and store the analysis result in the corresponding ModbusRTU slave register in the mapping data format; (5) Judge whether all inquiry frames in the current instrument have been sent. If they have been sent, step (6) is executed; otherwise, return to step (2). (6) Judge whether the data collection of the current instrument is completed. If it is completed, step (2) is executed, otherwise return to step (1). (7) Judge whether the ModbusRTU slave station is enabled. If it is not enabled, enable the northbound ModbusRTU slave station of the current device; otherwise, reset the collection flags of all instruments in the configuration file to incomplete and continue to execute the collection task of the next period, returning to step (1).
5. The method of claim 4, wherein, The timeout range is the product of the timeout times and timeout time set in the instrument link layer parameters.
6. A multi-meter serial data acquisition system, comprising: It comprises: A mobile terminal and a data collection device terminal, wherein: The mobile terminal comprises: A collection parameter configuration module for configuring collection parameters and generating a JSON file to deliver to the collection system device terminal; The collection device terminal comprises: A Bluetooth communication module for data interaction between the mobile terminal and the collection device terminal; A configuration storage module is configured to parse a JSON file, generate and store configuration parameters of each module, and configure and write Modbus Rtu slave parameters; A protocol storage module is configured to store each type of protocol supported by the data acquisition system; A Modbus RTU slave module is configured to receive related configuration parameters and data, configure parameters of the data acquisition system, enable control and data preparation, and provide a Modbus RTU access interface externally; An acquisition master module is configured to manage each module and interact with each module.
7. A multi-meter serial data acquisition system according to claim 6, wherein, The acquisition master module specifically performs: communication interface layer parameter configuration, generation and sending of acquisition inquiry frames, reception and data analysis of response data frames, and data mapping to the Modbus RTU slave module.