Data recording method for simultaneously recording CAN protocol data and Modbus protocol data

文档序号:189820 发布日期:2021-11-02 浏览:9次 中文

阅读说明:本技术 一种同时记录CAN协议数据与Modbus协议数据的数据记录方法 (Data recording method for simultaneously recording CAN protocol data and Modbus protocol data ) 是由 邹斐 马亮 王岩 徐广野 闫昌盛 王元龙 张震宇 杨健 毛冬岩 马森 白若忱 于 2021-07-26 设计创作,主要内容包括:本发明的目的在于提供一种同时记录CAN协议数据与Modbus协议数据的数据记录方法,当数据记录仪处于数据记录状态时,处理器同时从CAN接收模块获取到CAN数据以及CAN中断信号,以及从Modbus接收模块获取Modbus数据以及Modbus状态,Modbus接收模块在主函数中被调用,为轮询模式,即固定每一秒请求Modbus获取数据,CAN接收模块由CAN中断调用,每当有新的CAN数据,数据记录仪跳出Modbus接收模块进入中断对CAN数据进行记录,当完成CAN数据接受后再次回归Modbus接收模块进行Modbus信号记录,从而实现同时记录CAN协议与Modbus协议数据。本发明可以支持多信号协议的系统数据记录,减少了数据记录仪使用个数,降低了使用成本。与此同时,还保证了多信号协议数据记录的时间戳的一致性,提高了数据的可靠性。(The invention aims to provide a data recording method for simultaneously recording CAN protocol data and Modbus protocol data, when a data recorder is in a data recording state, a processor simultaneously acquires CAN data and a CAN interrupt signal from a CAN receiving module, and acquires Modbus data and a Modbus state from the Modbus receiving module, the Modbus receiving module is called in a master function and is in a polling mode, namely, each second request for Modbus to acquire data is fixed, the CAN receiving module is called by CAN interrupt, when new CAN data exist, the data recorder jumps out of the Modbus receiving module to enter interrupt to record the CAN data, and returns to the Modbus receiving module again to record Modbus signals after the CAN data are received, so that the CAN protocol and Modbus protocol data are recorded simultaneously. The invention can support the system data recording of a multi-signal protocol, reduces the number of data recorders and reduces the use cost. Meanwhile, the consistency of the time stamps of the multi-signal protocol data records is ensured, and the reliability of the data is improved.)

1. A data recording method for simultaneously recording CAN protocol data and Modbus protocol data is characterized in that: when the data record appearance is in the data logging state, the treater acquires CAN data and CAN interrupt signal from CAN receiving module simultaneously, and acquire Modbus data and Modbus state from Modbus receiving module, Modbus receiving module is called in the master function, for the polling mode, fixed every second requests Modbus promptly and acquires data, CAN receiving module is interrupted by the CAN and calls, whenever there is new CAN data, the data record appearance jumps out Modbus receiving module and gets into the interrupt and take notes the CAN data, return Modbus receiving module once more and carry out Modbus signal record after accomplishing CAN data and accept, thereby realize simultaneously recording CAN agreement and Modbus agreement data.

2. The data recording method for simultaneously recording CAN protocol data and Modbus protocol data according to claim 1, wherein the data recording method comprises the following steps: the recording method of the CAN transmitting-receiving module comprises the following steps: and the CAN receives the interrupt, stores the received CAN data into the buffers, switches to the other buffer after one of the CAN data is stored fully, stores the fully stored buffer into the SD card in the back main function and clears the buffer.

3. The data recording method for simultaneously recording CAN protocol data and Modbus protocol data according to claim 1 or 2, wherein the data recording method comprises the following steps: the recording method of the Modbus transceiver module comprises the following steps: modbus carries out operation on next step by according to the status flag bit at every turn, and four states are application data, wait, data processing and data storage respectively, only when data are completely received, the data application next time can be proposed after the inside is judged to be effective and the storage finishes to avoid appearing Modbus data record and Modbus data receiving conflict.

Technical Field

The present invention relates to a data recording method.

Background

The existing data recorder only CAN record one kind of data, namely CAN protocol data or Modbus protocol data, and the corresponding data recorder must be used for one kind of data protocol. For a system using both CAN and Modbus protocols, two data recorders must be used to record data of different protocols. Secondly, because the two protocols are recorded by different data recorders, the data time of the two recorded CAN and Modbus protocols is deviated, so that the reference of the recorded data is reduced.

Disclosure of Invention

The invention aims to provide a data recording method for simultaneously recording CAN protocol data and Modbus protocol data.

The purpose of the invention is realized as follows:

the invention discloses a data recording method for simultaneously recording CAN protocol data and Modbus protocol data, which is characterized by comprising the following steps of: when the data record appearance is in the data logging state, the treater acquires CAN data and CAN interrupt signal from CAN receiving module simultaneously, and acquire Modbus data and Modbus state from Modbus receiving module, Modbus receiving module is called in the master function, for the polling mode, fixed every second requests Modbus promptly and acquires data, CAN receiving module is interrupted by the CAN and calls, whenever there is new CAN data, the data record appearance jumps out Modbus receiving module and gets into the interrupt and take notes the CAN data, return Modbus receiving module once more and carry out Modbus signal record after accomplishing CAN data and accept, thereby realize simultaneously recording CAN agreement and Modbus agreement data.

The present invention may further comprise:

1. the recording method of the CAN transmitting-receiving module comprises the following steps: and the CAN receives the interrupt, stores the received CAN data into the buffers, switches to the other buffer after one of the CAN data is stored fully, stores the fully stored buffer into the SD card in the back main function and clears the buffer.

2. The recording method of the Modbus transceiver module comprises the following steps: modbus carries out operation on next step by according to the status flag bit at every turn, and four states are application data, wait, data processing and data storage respectively, only when data are completely received, the data application next time can be proposed after the inside is judged to be effective and the storage finishes to avoid appearing Modbus data record and Modbus data receiving conflict.

The invention has the advantages that: compared with the traditional data recording scheme, the data recording method for simultaneously recording the CAN protocol data and the Modbus protocol data CAN support the system data recording of a multi-signal protocol, reduces the number of data recorders and reduces the use cost. Meanwhile, the consistency of the time stamps of the multi-signal protocol data records is ensured, and the reliability of the data is improved.

Drawings

FIG. 1 is a schematic diagram of an interface of a data recording method according to the present invention;

FIG. 2 is a flow chart of switching between CAN reception and Modbus reception modules;

FIG. 3 is a flow chart of a recording method for recording CAN protocol data;

FIG. 4 is a flow chart of a recording method for recording Modbus protocol data.

Detailed Description

The invention will now be described in more detail by way of example with reference to the accompanying drawings in which:

referring to fig. 1-4, a schematic diagram of a signal interface of the data recording method for simultaneously recording the CAN protocol data and the Modbus protocol data according to the present invention is shown in fig. 1, when the data recorder is in a data recording state, the processor CAN simultaneously obtain the CAN data and the CAN interrupt signal from the CAN receiving module, and obtain the Modbus data and the Modbus state from the Modbus receiving module. The CAN interrupt signal and the Modbus state signal provide information for the data recorder when to record two data. Referring to fig. 2, the Modbus receiving module is called in the master function, which belongs to the polling mode, i.e. requests the Modbus to obtain data every second. And the CAN receiving module is called by CAN interruption, and when new CAN data exist, the data recorder CAN jump out of the Modbus receiving module to enter interruption for recording the CAN data, and the data recorder returns to the Modbus receiving module again to record Modbus signals after the CAN data is received. By using the scheme, the invention realizes the function of simultaneously recording CAN protocol and Modbus protocol data.

For actually recording data, the problem of data receiving and recording file storage conflict needs to be solved. Fig. 3 illustrates a recording method of the CAN transceiver module, in which the CAN receives an interrupt to store the received CAN data in a buffer with a length of 400, and when one of the buffers is full, the buffer is switched to another buffer, and then the master function stores the full buffer in the SD card and clears the buffer. In other words, the method ensures that the CAN data CAN be recorded when the SD card is used for storing data. Fig. 4 illustrates a recording method of the Modbus transceiver module, where the Modbus performs the next operation according to the status flag bit each time, and the four statuses are respectively application data, waiting, data processing or data storage. Only when the data is completely received, the internal judgment is effective and the next data application can be provided after the storage is finished. Therefore, the condition that Modbus data records conflict with Modbus data receiving does not occur.

6页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:固态硬盘的管理方法和固态硬盘

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类