Multi-channel energy spectrum data serialization compression and reduction method
Technical Field
The invention relates to the technical field of nuclear physics experiments, nuclear instruments and electronics, in particular to a multi-channel energy spectrum data serialization compression and reduction method.
Background
In various fields of nuclear physics experiments, nuclear technology applications, and the like (for example, alpha spectrum measurement in radioactive aerosol measurement), a multichannel energy spectrum analyzer (multichannel analyzer for short, MCA, also called multichannel pulse amplitude analyzer in the field of electronics) is often required to digitize energy signals of photons and particles deposited in a detector to obtain multichannel energy spectrum data. Through multi-channel energy spectrum analysis, physical quantities such as related nuclide content or related nuclear radiation exposure rate can be measured. The energy spectrum data is generally acquired by control circuits (called lower computers) such as a microcontroller MCU (microprogrammed control unit), a singlechip and the like, and transmitted to an energy spectrum analysis microcomputer (called an upper computer) with higher operation performance in real time (not more than once per second) or at regular time (every minute, hour or once every day). In order to reduce the number of wires between the upper and lower computers, the transmission is generally performed in a serial manner.
In recent years, with the improvement of the technical process of the nuclear radiation detector, the comprehensive indexes such as energy resolution, the highest counting rate and the like are greatly improved. Therefore, the number of analysis tracks of the multi-channel spectrum analyzer requiring subsequent adaptation is up to 16384 tracks, and the counting capacity of each track should be up to 16 bits. In addition, at least 1bit of start bit and stop bit is needed in serial transmission. If the entire line data is required to be transmitted once per second, the bit rate of transmission is theoretically at least: 16384 × (16+2) ═ 294912 bps. This has greatly exceeded the standard for maximum bit rates of 110592bps for serial transmission such as RS-232. Therefore, the invention is a method which has simple algorithm, is suitable for being realized in a single chip microcomputer or a microcontroller, can compress multi-channel spectrum data before serial transmission and can be quickly and completely restored at a data receiving party, and has very important practical value.
Disclosure of Invention
The invention aims to provide a method for compressing and restoring multi-channel energy spectrum data in a serialized mode, wherein the algorithm is simple and suitable for being realized in a single chip microcomputer or a microcontroller, the multi-channel energy spectrum data can be compressed before serial transmission, and can be quickly and completely restored at a data receiving party.
In order to achieve the purpose, the invention provides the following technical scheme: a multi-channel energy spectrum data serialization compression and reduction method comprises a multi-channel energy spectrum data channel address and count value coding method and a coding data transmission omission method.
Preferably, the method for encoding the multichannel energy spectrum data channel address and the count value comprises the following steps: recoding up to 20bit addresses of each track in the multichannel energy spectrum data and up to 20bit count values of the track plus a header into 8 groups of 8bit binary numbers, which comprises:
4 sets of 8-bit address data A0-A3;
4 sets of 8bit count rate data D0 through D3;
each group of 8-bit data has a maximum of 3 bits, identified by headers 000 to 111 as D3 to A0, respectively.
Preferably, the method for omitting coded data transmission includes:
3 omission rules can be adopted during coded data transmission;
for lanes with a count of zero, all 8 groups of codes may be omitted from non-transmission;
the track address coding or the counting value coding, the preposed zero can omit non-transmission;
when the channel address of the channel is transmitted as the previous channel address plus 1, the channel address coding can be omitted and not transmitted.
Compared with the prior art, the invention has the beneficial effects that:
1. the method for compressing and restoring the multi-channel energy spectrum data in a serialized mode effectively reduces the actual data transmission amount by adopting a unique method for encoding the multi-channel energy spectrum data channel address and the counting value to be matched with an encoding data transmission omitting method, and aiming at the characteristic that in real-time multi-channel energy spectrum measurement, the smaller the data transmission time interval is, the more the channels with zero counting are, so that the effect of lossless compression is achieved.
2. The multi-channel energy spectrum data serialization compression and reduction method only relates to the most basic binary digit operation and logic judgment of a microcomputer and a microcontroller, has low requirement on the operational capability of a data transmission upper computer, and can completely recover the compressed multi-channel energy spectrum data in a reverse direction; the method is realized by completely using software without extra hardware circuit support, reduces the data transmission amount, improves the real-time performance of data transmission, improves the reliability due to reduction of total code error amount, and has good popularization prospect in the application fields of indoor and outdoor multi-channel gamma energy spectrum analysis, multi-element X fluorescence analysis, energy spectrum radon measurement, energy spectrum aerosol measurement and the like.
Detailed Description
The following examples will explain the present invention in detail, however, the present invention is not limited thereto. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the embodiment of the invention: a multi-channel energy spectrum data serialization compression and reduction method is provided, which comprises a multi-channel energy spectrum data channel address and count value coding method and a coding data transmission omission method.
The coding method of the multi-channel energy spectrum data track address and the counting value is characterized in that the up to 20bit track address of each channel in the multi-channel energy spectrum data and the up to 20bit counting value of the channel are added with a header to be recoded into 8 groups of 8-bit binary numbers; see attached table 1 for coding methods.
TABLE 1 energy spectrum data channel address and counting value coding method table
For example: 20-bit track address data binary numbers AB 0-AB 19 are split into 4 groups of 5-bit binary numbers AB 0-AB 4, AB 5-AB 9, AB 10-AB 14, AB 15-AB 19 and the like, and 011, 010, 001 and 000 identification headers are added before the 5 groups of the binary numbers respectively; if the actual track address is less than 20 bits, the compatibility can be realized by complementing 0 at a high bit; similarly, 20-bit count value binary numbers DB 0-DB 19 are split into 4 groups of 5-bit binary numbers such as DB 0-DB 4, DB 5-DB 9, DB 10-DB 14 and DB 15-DB 19, and 111, 110, 101 and 100 identification headers are respectively added before the 5 groups of binary numbers; if the actual count value is less than 20 bits, the compatibility can be realized by complementing 0 at a high bit; in this way, the 20bit track addresses AB0 through AB19 for each track, along with the count binary numbers DB0 through DB19 for the track 20bit, may be re-encoded as 8 binary numbers a0 through A3, along with C0 through C3, and then the 8 binary numbers may be transmitted to the serial port in the order of "first track address encoding, then count encoding" and "first high, then low".
Before transmission, according to the following 3 rules, the corresponding encoded data of the track address or the count value can be omitted from non-transmission, thereby greatly reducing the data amount of actual transmission; the core idea of the method is that 3 omission rules can be adopted during the transmission of the coded data, including: (1) for lanes with a count of zero, all 8 groups of codes may be omitted from non-transmission; (2) the track address coding or the counting value coding, the preposed zero can omit non-transmission; (3) when the channel address of the channel is transmitted as the previous channel address plus 1, the channel address coding can be omitted and not transmitted.
In summary, the following steps: according to the multi-channel energy spectrum data serialization compression and reduction method provided by the invention, a unique multi-channel energy spectrum data channel address and count value coding method is adopted to be matched with an encoding data transmission omission method, and the actual data transmission quantity is effectively reduced by aiming at the characteristics that in real-time multi-channel energy spectrum measurement, the smaller the data transmission time interval is, the more channels with zero count are, so that the lossless compression effect is achieved; the method only relates to the most basic binary digit operation and logic judgment of a microcomputer and a microcontroller, has low requirement on the operational capability of a data transmission upper computer, and can completely recover compressed multi-channel energy spectrum data in a reverse direction on the upper computer; the method is realized by completely using software without extra hardware circuit support, reduces the data transmission amount, improves the real-time performance of data transmission, improves the reliability due to reduction of total code error amount, and has good popularization prospect in the application fields of indoor and outdoor multi-channel gamma energy spectrum analysis, multi-element X fluorescence analysis, energy spectrum radon measurement, energy spectrum aerosol measurement and the like.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.