CN108694826B - Infrared encoding and decoding method - Google Patents
Infrared encoding and decoding method Download PDFInfo
- Publication number
- CN108694826B CN108694826B CN201810686679.2A CN201810686679A CN108694826B CN 108694826 B CN108694826 B CN 108694826B CN 201810686679 A CN201810686679 A CN 201810686679A CN 108694826 B CN108694826 B CN 108694826B
- Authority
- CN
- China
- Prior art keywords
- value
- pulse width
- data
- infrared
- characteristic
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 27
- 238000004458 analytical method Methods 0.000 claims abstract description 3
- 230000001105 regulatory effect Effects 0.000 claims abstract description 3
- 238000012545 processing Methods 0.000 claims description 8
- 238000005457 optimization Methods 0.000 claims description 7
- 238000010606 normalization Methods 0.000 claims description 6
- 238000012163 sequencing technique Methods 0.000 claims description 5
- 230000000295 complement effect Effects 0.000 claims 1
- 230000006835 compression Effects 0.000 abstract description 4
- 238000007906 compression Methods 0.000 abstract description 4
- 238000004891 communication Methods 0.000 abstract description 2
- 230000005540 biological transmission Effects 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000006467 substitution reaction Methods 0.000 description 2
- 229910002056 binary alloy Inorganic materials 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G08—SIGNALLING
- G08C—TRANSMISSION SYSTEMS FOR MEASURED VALUES, CONTROL OR SIMILAR SIGNALS
- G08C23/00—Non-electrical signal transmission systems, e.g. optical systems
- G08C23/04—Non-electrical signal transmission systems, e.g. optical systems using light waves, e.g. infrared
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Optical Communication System (AREA)
Abstract
The invention relates to the technical field of infrared communication, in particular to an infrared data coding and decoding method. The method searches characteristic values by regulating and optimizing the infrared data, and performs encoding and decoding through the characteristic values, and is based on waveform encoding, high in compression ratio, free of specific protocol, free of specific data type analysis, simple and efficient in decoding process.
Description
Technical Field
The invention relates to the technical field of infrared communication, in particular to a coding and decoding method in infrared data transmission control.
Background
With the progress of science and technology and the development of society, electrical apparatus and digital science and technology article that the family was equipped with are more and more, no matter be traditional TV set, air conditioner, water heater, digital DVD, projecting apparatus, still present intelligent TV, the box all is furnished with the traditional handheld infrared remote controller that corresponds one by one, and a remote controller generally can only control an equipment, and compatibility is poor, and the user uses the operation inconvenience.
Nowadays, the internet technology is popularized and matured, the internet of things is hot, so that the smart home market has a wide market prospect, various home smart infrared remote control terminals controlled by mobile phones and the like appear in the market, data is required to be transmitted by using the mobile phones, especially the solar brand air conditioners are different from the common television remote control, the original infrared data has more than 1k bytes and more than 3k multi-data information, if the original data is directly transmitted without processing codes, the very high requirement on transmission bandwidth is provided, WIFI is probably sufficient, and more low-bandwidth and low-power-consumption transmission protocols such as Zigbee and the like are used in the smart home field of the internet of things. Moreover, infrared data of various electrical equipment manufacturers generally conform to PPM (RC-5 code) and PWM (NEC code) protocols, but basically derivative extension is carried out on the basis, so that infrared waveforms of specific manufacturers are different, and the existing protocols cannot be directly applied. Therefore, there is a need for an infrared data encoding and decoding method that can compress infrared raw data for transmission and is also suitable for infrared waveforms of almost all manufacturers in the market.
Disclosure of Invention
The invention aims to solve the problem of providing an infrared encoding and decoding method, which can compress and encode infrared original data to be beneficial to transmission, and transmit the infrared original data to terminal equipment for decoding and transmitting or upload background equipment for decoding and matching waveforms.
The technical scheme adopted by the invention for solving the problems is as follows: the infrared encoding and decoding method comprises the following steps:
(1) acquiring original infrared data: capturing corresponding original pulse width value data by using infrared waveform analysis equipment;
(2) and regulating and optimizing: after the original pulse width value is rounded, taking the first pulse width value in the rounded data as a matching value to be sequentially compared with each of the subsequent pulse width values, if the ratio is 0.9-1.1 and the level polarities are consistent, replacing the matching value with the first pulse width value, and if the level polarities are not consistent, maintaining the original value, and completing the first regularization optimization until the last comparison of the pulse width values is completed; then, the second pulse width value of the normalized data is used as a matching value and processed by the same method to finish the second regularization processing, and so on until the final regularization processing is finished;
(3) counting and sequencing times: counting the occurrence times of various pulse widths in the data after the normalization and optimization, and sequencing to find out the pulse width value with the occurrence times exceeding 5 times;
(4) finding out a characteristic value: finding out a characteristic value T1 by using an approximate greatest common divisor method in the pulse width values selected in the step (3);
(5) and binary coding: removing characteristic values T1 from the data normalized and optimized in the step (2), finding out the number of characteristic values contained in each pulse width value, and respectively expressing the number by using '1' and '0' of corresponding numbers, dividing the number, rounding up by rounding up, directly removing the data less than 0.5, and complementing 1byte by using '0' for the last less than 8 bits;
(6) and finishing the coding: converting the codes completed in the step (5) into corresponding systems and carrying the characteristic value T1 to be provided for application protocols;
(7) and decoding: after the encoding is finished, the encoded data is transmitted to corresponding equipment through Zigbee or wifi and the like for decoding, and the original waveform can be decoded and analyzed only according to the characteristic value T1 and the binary value of the data.
Further, the "approximate greatest common divisor" method in the step (4) is performed as follows: finding out the minimum pulse width value T1 as denominator to divide with all values respectively, if the multiple interval is within the range of integral multiple + -20%, then T1 is taken as characteristic value T1, and most of the infrared waveforms meet the characteristic, if more than 1 out of range, then T1/2 is taken as denominator to divide with all values, if the multiple interval is within the range of integral multiple + -20%, then T1/2 is taken as characteristic value T1, if more than 1 out of range, then T1/4 is taken as characteristic value T1 directly.
Further, the infrared waveform analyzing device in the step (1) includes an infrared waveform analyzer and the like.
Further, the step (2) further includes a step of directly skipping the next matching value if the second pulse width value of the normalized data is equal to the previous value.
Compared with the prior art, the invention has the following beneficial effects: the minimum pulse width is used as a characteristic value to carry out soft coding on infrared data, interference signals such as burrs and the like are eliminated, and the ultra-long code is compressed, for example, the waveform length of a Japanese air conditioner can reach 500ms, the data coded by the method of the invention is about 120 bytes, compared with the original data which is nearly 3000 bytes, the compression ratio reaches 1: 25; and the method is based on waveform coding, avoids specific protocols, does not need to specifically analyze whether the data are boot codes, address codes, functional codes and the like, and has simple and efficient decoding process.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a diagram of an infrared raw waveform of an embodiment of the present invention.
FIG. 2 is a flow chart of the encoding steps of an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. 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.
Example 1.
As shown in fig. 1 to 2, an infrared encoding and decoding method in an embodiment of the present invention includes the following steps:
s1, acquiring original infrared data: an infrared original waveform and corresponding original pulse width data are captured by an infrared waveform analyzer and other equipment, and H and L in front of the pulse width value respectively represent high-level and low-level pulses.
S2, regularizing and optimizing: after the original pulse width value is rounded, taking the first pulse width value in the rounded data as a matching value to be sequentially compared with each of the subsequent pulse width values, if the ratio is 0.9-1.1 and the level polarities are consistent, replacing the matching value with the first pulse width value, and if the level polarities are not consistent, maintaining the original value until the first regularization optimization is completed after the last pulse width value is compared; then, the second pulse width value of the normalized data is used as a matching value, when the matching value is selected, if the matching value with the same value is used, the next matching value is directly skipped, the processing is performed in the same way, the second normalization processing is completed, and the like, until the final normalization processing is completed, as shown in S2 in fig. 2, H4472 is used as the matching value at first, the 3 values optimized for the first time are normalized to be H4472, and the data after the normalization optimization is completed is shown in the right side box of S2 in fig. 2.
S3, counting and sorting times: and counting the occurrence times of various pulse widths in the data after the normalization and optimization, sequencing, and finding out the pulse width value with the occurrence times exceeding 5 times.
S4, finding out characteristic values: finding out a characteristic value T1 from the pulse width values selected in the step S3 by using an approximate greatest common divisor method, wherein the approximate greatest common divisor method comprises the following steps of finding out a minimum pulse width value T1 as a denominator and dividing the minimum pulse width value by all values, taking T1 as the characteristic value T1 if the multiple intervals are within an integral multiple +/-20%, most infrared waveforms conform to the characteristic, and taking T1/2 as the denominator and dividing all values if more than 1 exceeding range exists for individual special waveforms, taking T1/2 as the characteristic value T1 if the multiple intervals are within the integral multiple +/-20%, and directly taking T1/4 as the characteristic value T1 if more than 1 exceeding range exists; in this embodiment, the minimum value T1 is 530, and divided by the other 2 to satisfy the range of integral multiple ± 20%, so T1 is T1; for more specific waveforms, such as H600, L410, 205 is taken as the eigenvalue.
S5, binary coding: removing the eigenvalue T1 from the data normalized in step S2, finding out the eigenvalue number contained in each pulse width value, and respectively representing the eigenvalue number by "1" and "0" of the corresponding number, dividing the number, and rounding (small number exists after dividing the longer pulse width value such as infrared boot code, etc., and rounding does not affect infrared performance, and the data code should adopt signature matching, and has a small error), and for the direct removal smaller than 0.5, it should be some interference signals such as glitches, etc., and make up 1byte by "0" for the last less than 8 bits (1 byte).
S6, completing coding: the encoding completed in step S5 is converted into corresponding binary system and provided with the characteristic value T1 for the application protocol to use.
S7, decoding: after the encoding is finished, the data are transmitted to corresponding equipment for decoding through Zigbee or wifi and the original waveform can be decoded and analyzed only according to the characteristic value T1 and the binary code value of the data. For example, in this embodiment T1 ═ 530us, the transmitted data is {0xFF, 0x00, 0xA2, … … }, and the binary value corresponding to 0xFF is BIN:11111111, so the first is high and the length is 530us × 8 ═ 4240us, the second 0x00 is decoded into L4240 of low, and the third 0xA2 (BIN: 10100010) is decoded into [ H530, L530, H530, L1590, H530, L530]6 pulse width values. The similarity between the first H4240 and the original data is H4240/H4472-95%, and the decoding reduction rate of each pulse width value is specifically shown in table 1.
In the embodiment of the invention, the original waveform length reaches approximately 140ms, and the actual data 31 bytes after being coded by the method of the invention has a compression ratio of 1:11 compared with the original data 328 bytes (calculated by 4 bytes with one pulse width value). The method is based on waveform coding, can realize coding compression on RC-5 codes, NEC codes or other special formats, and has low pressure loss rate and simple and clear decoding process.
Original value | H4472.1 | L4486.7 | L530.5 | H568.2 | L1620.9 |
Decoding a reduced value | H4240 | L4240 | L530 | H530 | L1590 |
Degree of similarity | 95% | 94% | 99% | 93% | 98% |
Table 1: pulse width value reduction rate calculation table of the embodiment of the invention
It should be noted that the above detailed description of the technical solution of the present invention with the help of preferred embodiments is illustrative and not restrictive. After reading the description of the present invention, a person skilled in the art may modify the technical solutions described in the embodiments or make equivalent substitutions for some technical features, and these modifications or substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
Claims (3)
1. An infrared encoding and decoding method is characterized by comprising the following steps:
(1) acquiring original infrared data: capturing corresponding original pulse width data by using infrared waveform analysis equipment, wherein H and L in front of the pulse width data respectively represent high-level and low-level pulses;
(2) and regulating and optimizing: after the original pulse width value is rounded, taking the first pulse width value in the rounded data as a matching value to be sequentially compared with each of the subsequent pulse width values, if the ratio is 0.9-1.1 and the level polarities are consistent, replacing the matching value with the first pulse width value, and if the level polarities are not consistent, maintaining the original value, and completing the first regularization optimization until the last comparison of the pulse width values is completed; then, the second pulse width value of the normalized data is used as a matching value and processed by the same method to finish the second regularization processing, and so on until the final regularization processing is finished;
(3) counting and sequencing times: counting the occurrence times of various pulse widths in the data after the normalization and optimization, and sequencing to find out the pulse width value with the occurrence times exceeding 5 times;
(4) finding out a characteristic value: finding out a characteristic value T1 by using an approximate greatest common divisor method in the pulse width values selected in the step (3);
(5) and binary coding: removing characteristic values T1 from the data normalized and optimized in the step (2), finding out the number of characteristic values contained in each pulse width value, respectively using '1' and '0' of corresponding numbers to represent high-level and low-level pulses, dividing the number, rounding up by rounding up, and using '0' to complement 1byte for direct removal less than 0.5 and for final less than 8 bits;
(6) and finishing the coding: converting the codes completed in the step (5) into corresponding systems and carrying the characteristic value T1 to be provided for application protocols;
(7) and decoding: after the encoding is finished, the encoded data is transmitted to corresponding equipment through Zigbee or wifi for decoding, and the original waveform can be decoded and analyzed only according to the characteristic value T1 and the binary value of the data;
the approximate greatest common divisor method in the step (4) is carried out according to the following steps: finding out the minimum pulse width value T1 as denominator to divide with all values respectively, if the multiple interval is within the range of integral multiple + -20%, then T1 is taken as characteristic value T1, and most of the infrared waveforms meet the characteristic, if more than 1 out of range, then T1/2 is taken as denominator to divide with all values, if the multiple interval is within the range of integral multiple + -20%, then T1/2 is taken as characteristic value T1, if more than 1 out of range, then T1/4 is taken as characteristic value T1 directly.
2. The ir encoding/decoding method according to claim 1, wherein the ir waveform analyzing device in step (1) comprises an ir waveform analyzer.
3. The ir encoding/decoding method according to claim 1, wherein the step (2) further comprises the step of directly skipping the next matching value if the second pulse width value of the warped data is equal to the previous value.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810686679.2A CN108694826B (en) | 2018-06-28 | 2018-06-28 | Infrared encoding and decoding method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810686679.2A CN108694826B (en) | 2018-06-28 | 2018-06-28 | Infrared encoding and decoding method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108694826A CN108694826A (en) | 2018-10-23 |
CN108694826B true CN108694826B (en) | 2020-06-05 |
Family
ID=63851301
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810686679.2A Active CN108694826B (en) | 2018-06-28 | 2018-06-28 | Infrared encoding and decoding method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108694826B (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111260910B (en) * | 2020-02-24 | 2021-08-27 | 珠海荣邦智能科技有限公司 | Control method, device and circuit of infrared transmitting tube |
CN111817725B (en) * | 2020-08-21 | 2024-10-11 | 济南赛英立德电子信息股份有限公司 | Efficient compression algorithm for air conditioner infrared remote control code library |
CN113850988B (en) * | 2020-12-24 | 2022-09-27 | 广东朝歌智慧互联科技有限公司 | Key value correction method, device, equipment and computer readable medium |
CN112330948B (en) * | 2021-01-04 | 2021-04-27 | 杭州涂鸦信息技术有限公司 | Infrared remote control code matching method and device, computer equipment and readable storage medium |
CN114120466B (en) * | 2021-11-22 | 2024-07-16 | 浙江嘉科电子有限公司 | Encoding and decoding device and method for patrol information exchange |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105070035A (en) * | 2015-08-25 | 2015-11-18 | 无锡力芯微电子股份有限公司 | Real-time compression method and device for infrared remote control code stream |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TWI389064B (en) * | 2008-12-09 | 2013-03-11 | Mstar Semiconductor Inc | A decoding method and apparatus for infrared remote control commands |
CN105306062B (en) * | 2015-11-23 | 2019-06-14 | 青岛海信电器股份有限公司 | A kind of coding and storing method of infrared data, device and coding/decoding method |
CN105654707A (en) * | 2016-01-22 | 2016-06-08 | 宁波三星医疗电气股份有限公司 | Infrared code identification method |
CN107564266B (en) * | 2017-08-25 | 2021-05-14 | 广东美的制冷设备有限公司 | Remote controller code learning method and remote controller learning device |
-
2018
- 2018-06-28 CN CN201810686679.2A patent/CN108694826B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105070035A (en) * | 2015-08-25 | 2015-11-18 | 无锡力芯微电子股份有限公司 | Real-time compression method and device for infrared remote control code stream |
Also Published As
Publication number | Publication date |
---|---|
CN108694826A (en) | 2018-10-23 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108694826B (en) | Infrared encoding and decoding method | |
WO2017016107A1 (en) | Household appliances infrared remote waveform replication learning method and system | |
CN103023511A (en) | Applied compressed encoding method and device | |
CN110445860B (en) | Message sending method, device, terminal equipment and storage medium | |
CN101017574A (en) | Huffman decoding method suitable for JPEG code stream | |
CN101201970A (en) | Self-adaptive decoding method for wireless remote control receiving chip | |
CN101667843B (en) | Methods and devices for compressing and uncompressing data of embedded system | |
CN116506073A (en) | Industrial computer platform data rapid transmission method and system | |
CN104079950A (en) | Video output processing method, device and system and video receiving processing method, device and system | |
CN101299611A (en) | Data compression method based on set run | |
CN115065732B (en) | Data transmission method, device, electronic setting and storage medium | |
CN110324094B (en) | Sound wave communication method and device, storage medium and electronic device | |
CN106448128B (en) | Infrared remote control data processing method and system | |
CN107564266B (en) | Remote controller code learning method and remote controller learning device | |
CN107526986B (en) | RFID label anti-collision method and system | |
CN103475877B (en) | Video transmission method and system | |
CN202721771U (en) | Television system with audio recognition function | |
CN103731241B (en) | Encoding system and method for improving spectrum efficiency of communication system | |
CN102422541B (en) | Method, device and system of coding, and method, device and system of decoding | |
CN112954456B (en) | Video data processing method, terminal and computer readable storage medium | |
CN112260699B (en) | Attribute communication coding and decoding method, coding device, decoding device and system | |
CN116074408A (en) | Quotation data recovery method and device | |
CN106982199B (en) | Manchester code communication protocol self-adaption method based on FPGA and CPLD | |
CN105141960B (en) | A kind of method that information transfer is carried out based on JPEG2000 compressed bit streams | |
CN109872522B (en) | Algorithm for decompressing infrared code based on sample index |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |