CN110445548A - A kind of infrared carrier wave communication code method and system - Google Patents

A kind of infrared carrier wave communication code method and system Download PDF

Info

Publication number
CN110445548A
CN110445548A CN201910815591.0A CN201910815591A CN110445548A CN 110445548 A CN110445548 A CN 110445548A CN 201910815591 A CN201910815591 A CN 201910815591A CN 110445548 A CN110445548 A CN 110445548A
Authority
CN
China
Prior art keywords
data
bit
duration
square wave
bits
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.)
Pending
Application number
CN201910815591.0A
Other languages
Chinese (zh)
Inventor
朱小丽
姚同生
赵鑫
徐大超
秦明辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
KEDA INTELLIGENT TECHNOLOGY Co Ltd
KEDA INTELLIGENT ELECTRICAL TECHNOLOGY Co Ltd
Original Assignee
KEDA INTELLIGENT TECHNOLOGY Co Ltd
KEDA INTELLIGENT ELECTRICAL TECHNOLOGY Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by KEDA INTELLIGENT TECHNOLOGY Co Ltd, KEDA INTELLIGENT ELECTRICAL TECHNOLOGY Co Ltd filed Critical KEDA INTELLIGENT TECHNOLOGY Co Ltd
Priority to CN201910815591.0A priority Critical patent/CN110445548A/en
Publication of CN110445548A publication Critical patent/CN110445548A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04BTRANSMISSION
    • H04B10/00Transmission systems employing electromagnetic waves other than radio-waves, e.g. infrared, visible or ultraviolet light, or employing corpuscular radiation, e.g. quantum communication
    • H04B10/50Transmitters
    • H04B10/516Details of coding or modulation
    • H04B10/524Pulse modulation

Landscapes

  • Physics & Mathematics (AREA)
  • Electromagnetism (AREA)
  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Optical Communication System (AREA)

Abstract

The invention discloses a kind of infrared carrier wave communication code method and system, belong to the communications field, including obtaining data to be sent;The beginning flag position that a logic is 0 is added for data, the data is looped through in order, each byte content is parsed, obtain 0/1 bit stream;After each byte content of data is parsed, to the duration of obtained all 0/1 bit stream statistics state of each bit, and it is stored in int array;The duration of data bit state each in int array variation is compared with 38K square-wave cycle, obtains the 38K square of each data bit to carry out data transmission.Data step-by-step is handled using coding mode and adds corresponding check bit sum stop position and transmitted by the present invention, to realize the function of infrared carrier wave communication.

Description

Infrared carrier communication coding method and system
Technical Field
The invention relates to the technical field of communication, in particular to an infrared carrier communication coding method and system.
Background
In the field of communications, two communication modes, namely wired communication and wireless communication, are mainly divided, wherein the wired communication is influenced by materials and has a short transmission distance, and the wireless communication is mainly transmitted by radio and the like, but the wireless communication is interfered by electromagnetic energy. With the development of infrared technology, various infrared transmitting and receiving sensors are available, so that infrared wireless communication is gradually heated.
Disclosure of Invention
The invention aims to provide a flexible and effective infrared communication coding method.
In order to achieve the above object, in one aspect, an infrared carrier communication encoding method is adopted, including:
acquiring data to be sent;
adding a start zone bit with the logic of 0 to data to indicate that the data starts to be transmitted, circularly traversing the data in sequence, and analyzing the content of each byte to obtain 0/1 bit streams;
after the analysis of the content of each byte of the data is completed, counting the duration of state change of all obtained 0/1 bit streams, and storing the duration in an int array element;
and comparing the duration of the state change of each data bit in the int array with the 38K square wave period to obtain a 38K square wave form of each data bit so as to send data.
Further, the sequentially and circularly traversing the data, parsing the content of each byte, and obtaining 0/1 bit streams, includes:
analyzing each byte of the data according to bits and adding an analysis result to a start bit;
adding check bits and stop bits to data bits according to said data content resulting in one of said 0/1 bit streams.
Further, after the parsing of each byte content of the data is completed, counting the duration of state change of all obtained 0/1 bit streams, and storing the duration in an int array, including:
comparing and judging adjacent data bits in all 0/1 bit streams;
if the states of the adjacent data bits are the same, calculating the duration of the state change of each data bit, and accumulating the duration of the state change of the data bits on the current int array element;
and if the states of the adjacent data bits are different, shifting the array subscript, and counting the current state into a new int array element.
Further, the duration T of the state change of the data bit is 1000000/Baud, and Baud represents the Baud rate.
Further, the comparing the duration of the state change of each data bit in the int array with the 38K square wave period to obtain a 38K square wave form of each data bit for data transmission includes:
acquiring a corresponding period T1-1000000/38000 according to the square wave frequency of infrared identification;
calculating the number Num of square waves required to be sent to code [ i ]/T1 according to the state duration of each data bit of the int array to obtain square wave data, wherein Num represents the number of the square waves obtained through calculation, codes represents the duration of each section, and i represents the ith section;
and sending the obtained square wave data.
In another aspect, an infrared carrier communication encoding system is provided, including: the system comprises a data acquisition module, an analysis module, an array element construction module and a sending module;
the data acquisition module is used for acquiring data to be transmitted;
the analysis module is used for adding an initial zone bit with the logic of 0 to the data to indicate that the data starts to be transmitted, circularly traversing the data in sequence, and analyzing the content of each byte to obtain 0/1 bit streams;
the array element construction module is used for counting the duration of state change of all obtained 0/1 bit streams after the analysis of each byte content of the data is completed, and storing the duration in an int array element;
the sending module is used for comparing the duration of the state change of each data bit in the int array with the 38K square wave period to obtain a 38K square wave form of each data bit so as to send data.
Further, the parsing module includes a first adding unit and a second adding unit:
the first adding unit is used for analyzing each byte of the data according to bits and adding an analysis result to the initial bit;
the second adding unit is used for adding the check bit and the stop bit to the data bit according to the data content to obtain the 0/1 bit stream.
Further, the array element construction module comprises a judgment unit and an array element construction unit;
the judging unit is used for comparing and judging adjacent data bits in all 0/1 bit streams;
the array element construction unit is used for calculating the state change duration of each data bit when the states of adjacent data bits are the same, and accumulating the state change duration on the current int array element;
and when the states of the adjacent data bits are different, shifting the array subscript, and counting the current state into a new int array element.
Further, the duration T of the state change of the data bit is 1000000/Baud, and Baud represents the Baud rate.
Further, the sending module comprises a period calculating unit, a square wave data calculating unit and a square wave data sending unit;
the period calculating unit is used for acquiring a corresponding period T1-1000000/38000 according to the square wave frequency of the infrared identification;
the square wave data calculation unit is used for calculating the number Num of square waves required to be sent to code [ i ]/T1 according to the state duration of each data bit of the int array so as to obtain square wave data, wherein Num represents the number of the square waves obtained through calculation, codes represents the duration of each segment, and i represents the ith segment;
the square wave data sending unit is used for sending the obtained square wave data.
Compared with the prior art, the invention has the following technical effects: the method adopts the mode that logic '0' is added to data to be transmitted to represent the start of data transmission, and an 11-bit 0/1 bit stream of each byte of data is obtained by analyzing the data in a bit processing mode and adding a check bit stop bit mark after the data; the 38K square wave form of each data bit is obtained by comparing the duration of the state change of each data bit with the 38K square wave period, so that the data can be transmitted accurately and completely.
Drawings
The following detailed description of embodiments of the invention refers to the accompanying drawings in which:
fig. 1 is a flow chart diagram of an infrared carrier communication encoding method;
fig. 2 is a schematic structural diagram of an infrared carrier communication encoding system.
Detailed Description
To further illustrate the features of the present invention, refer to the following detailed description of the invention and the accompanying drawings. The drawings are for reference and illustration purposes only and are not intended to limit the scope of the present disclosure.
As shown in fig. 1, the present embodiment discloses an infrared carrier communication encoding method, which includes the following steps S1-S4:
s1, acquiring data to be sent;
s2, adding a start zone bit with a logic of 0 for the data to indicate that the data starts to be transmitted, circularly traversing the data in sequence, and analyzing the content of each byte to obtain 0/1 bit stream;
s3, counting the duration of state change of all obtained 0/1 bit streams after the analysis of each byte content of the data is completed, and storing the duration in an int array element;
and S4, comparing the state change duration of each data bit in the int array with the 38K square wave period to obtain a 38K square wave form of each data bit so as to send data.
It should be noted that, in the present application, a coding method is used to perform bit processing on data and add corresponding check bits and stop bits for transmission, so as to implement the function of infrared carrier communication.
Further, in the step S2, the step of traversing the data in a sequential and cyclic manner, and parsing the content of each byte to obtain 0/1 bit streams includes:
analyzing each byte of the data according to bits and adding an analysis result to a start bit;
adding check bits and stop bits to data bits according to said data content resulting in one of said 0/1 bit streams.
Further, in the above step S3, after the parsing of each byte content of the data is completed, counting the duration of the state change of all obtained 0/1 bit streams, and storing the duration in the int array, including steps S31-S33:
s31, judging whether the adjacent data bits in all 0/1 bit streams are equal or not;
it should be noted that, because each data bit of the bit stream has only two states 0 and 1, it can be directly determined whether the data bits are equal, i.e., it can be determined whether the adjacent data bits are equal.
S32, if the states of the adjacent data bits are equal, accumulating the duration of the state and storing the duration in the current int array element;
for example, the following steps are carried out: that is, the state of the data bit is not changed, the time of the state is continuously accumulated, for example, 10001010, 8 state bits, the duration of each bit is 1ms, and the obtained int array time is 1ms, 3ms, 1ms, 1ms, 1 ms.
And S33, if the states of the adjacent data bits are different, shifting the array subscript, and counting the current state duration to the new int array element.
It should be noted that, since the final square wave formats sent by the data bits with the same state are the same, the duration of each data bit is calculated according to the baud rate, and then the comparison between the adjacent data bits is used to determine whether the states are the same, if so, the states are accumulated on the current array element (duration), and if not, the array subscript is shifted, and the current state duration is counted in a new array element.
Specifically, the duration T of the state change of the data bit is 1000000/Baud, and Baud represents the Baud rate.
Specifically, the method for further converting the elements in the int array codes [1000] is as follows: acquiring a corresponding period T1 ═ 1000000/38000 according to the square wave frequency of infrared identification, calculating the number Num ═ codes [ i ]/T1 of square waves required to be sent according to the duration time of each state of an int array to obtain square wave data, wherein Num represents the number of the square waves obtained through calculation, codes represents the duration time of each section, i represents the ith section, and finally sending the obtained square wave data to an infrared emitter to realize the function of infrared carrier communication.
As shown in fig. 2, the present embodiment discloses an infrared carrier communication encoding system, which includes: the system comprises a data acquisition module 10, an analysis module 20, an array element construction module 30 and a sending module 40;
the data obtaining module 10 is configured to obtain data to be sent;
the parsing module 20 is configured to add a start flag bit with a logic of 0 to the data to indicate that the data starts to be transmitted, and loop through the data in sequence to parse the content of each byte to obtain 0/1 bit streams. The parsing module 20 includes a first adding unit and a second adding unit:
the first adding unit is used for analyzing each byte of the data according to bits and adding an analysis result to the initial bit;
the second adding unit is used for adding the check bit and the stop bit to the data bit according to the data content to obtain the 0/1 bit stream.
The array element construction module 30 is configured to count the duration of state change of all obtained 0/1 bit streams after the parsing of each byte content of the data is completed, and store the duration in the int array. The array element constructing module 30 includes a judging unit and an array element constructing unit;
the judging unit is used for comparing and judging adjacent data bits in all 0/1 bit streams;
the array element construction unit is used for calculating the state change duration of each data bit when the states of adjacent data bits are the same, wherein the state change duration T of each data bit is 1000000/Baud, Baud represents the Baud rate, and the state change duration is accumulated in the current int array element;
and when the states of the adjacent data bits are different, shifting the array subscript, and counting the current state into a new int array element.
The sending module 40 is configured to compare the duration of the state change of each data bit in the int array with the 38K square wave period, and obtain a 38K square wave form of each data bit to send data. Wherein,
the transmitting module 40 includes a period calculating unit, a square wave data calculating unit and a square wave data transmitting unit;
the period calculating unit is used for acquiring a corresponding period T1-1000000/38000 according to the square wave frequency of the infrared identification;
the square wave data calculation unit is used for calculating the number Num of square waves required to be sent to code [ i ]/T1 according to the state duration of each data bit of the int array so as to obtain square wave data, wherein Num represents the number of the square waves obtained through calculation, codes represents the duration of each segment, and i represents the ith segment;
the square wave data sending unit is used for sending the obtained square wave data.
It should be noted that the method of the present application can be implemented by means of a raspberry pie, specifically:
(1) data content needing to be sent is input through upper computer interface software of the raspberry pi, a sending command is clicked, and the raspberry pi acquires data input through the upper computer interface software.
(2) After obtaining the data, the raspberry pi adds an initial flag bit with logic '0' to indicate that data transmission is started. And then, circularly traversing the data content in sequence, analyzing according to the bit (totally 8 bits) and adding the bit to the start bit, and finally adding the check bit and the stop bit to the data bit according to the data content to obtain a bit stream with 11 bits 0/1.
(3) After all data parsing is completed, for all 0/1 stored bitstreams, the duration of the data bit state change T is calculated to be 1000000/Baud, Baud representing Baud rate. And then judging whether the states are the same or not by comparing adjacent bits, if so, accumulating the states on the current array element (duration), and if not, shifting the array subscript and counting the current state into a new array element.
(4) Converting the duration of each segment in the int array into the square wave frequency of infrared identification to obtain a corresponding period T1 ═ 1000000/38000, calculating the number Num ═ codes [ i ]/T1 of square waves required to be sent according to the duration of each data bit state of the int array, converting the int array data into 38K square wave data, and transmitting the 38K square wave data to an infrared transmitter through a raspberry CPU pin for data sending.
According to the method and the device, the data content of infrared transmission is more flexible by means of interface operation of the raspberry group, the raspberry group interface inputs transmission data and converts the transmission data into 38K rectangular waves which can be identified by an infrared receiver in a specific mode, and therefore infrared carrier communication is achieved.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (10)

1. An infrared carrier communication encoding method, comprising:
acquiring data to be sent;
adding a start zone bit with the logic of 0 to data to indicate that the data starts to be transmitted, circularly traversing the data in sequence, and analyzing the content of each byte to obtain 0/1 bit streams;
after the analysis of the content of each byte of the data is completed, counting the duration of each bit state of all obtained 0/1 bit streams, and storing the duration in an int array element;
and comparing the duration of the state change of each data bit in the int array with the 38K square wave period to obtain a 38K square wave form of each data bit so as to send data.
2. The infrared carrier communication encoding method of claim 1, wherein said cycling through said data in sequence, parsing each byte of content, resulting in an 0/1 bit stream, comprises:
analyzing each byte of the data according to bits and adding an analysis result to a start bit;
adding check bits and stop bits to data bits according to said data content resulting in one of said 0/1 bit streams.
3. The infrared carrier communication coding method of claim 2, wherein the step of counting the duration of state change of all obtained 0/1 bit streams after the completion of the parsing of each byte content of the data and storing the duration in an int array comprises:
comparing and judging adjacent data bits in all 0/1 bit streams;
if the states of the adjacent data bits are the same, calculating the duration of the state change of each data bit, and accumulating the duration of the state change of the data bits on the current int array element;
and if the states of the adjacent data bits are different, shifting the array subscript, and counting the current state duration to a new int array element.
4. The infrared carrier communication coding method of claim 3, wherein the duration of the change of state of the data bit T is 1000000/Baud, Baud representing Baud rate.
5. The infrared carrier communication coding method of claim 4, wherein the comparing the duration of the state change of each data bit in the int array with the 38K square wave period to obtain the 38K square wave form of each data bit for data transmission comprises:
acquiring a corresponding period T1-1000000/38000 according to the square wave frequency of infrared identification;
calculating the number Num of square waves required to be sent to code [ i ]/T1 according to the state duration of each data bit of the int array to obtain square wave data, wherein Num represents the number of the square waves obtained through calculation, codes represents the duration of each section, and i represents the ith section;
and sending the obtained square wave data.
6. An infrared carrier communication encoding system, comprising: the system comprises a data acquisition module, an analysis module, an array element construction module and a sending module;
the data acquisition module is used for acquiring data to be transmitted;
the analysis module is used for adding an initial zone bit with the logic of 0 to the data to indicate that the data starts to be transmitted, circularly traversing the data in sequence, and analyzing the content of each byte to obtain 0/1 bit streams;
the array element construction module is used for counting the duration of state change of all obtained 0/1 bit streams after the analysis of each byte content of the data is completed, and storing the duration in an int array element;
the sending module is used for comparing the duration of the state change of each data bit in the int array with the 38K square wave period to obtain a 38K square wave form of each data bit so as to send data.
7. The infrared carrier communication coding system of claim 6, wherein the parsing module comprises a first adding unit and a second adding unit:
the first adding unit is used for analyzing each byte of the data according to bits and adding an analysis result to the initial bit;
the second adding unit is used for adding the check bit and the stop bit to the data bit according to the data content to obtain the 0/1 bit stream.
8. The infrared carrier communication coding system of claim 7, wherein the array element construction module comprises a judgment unit and an array element construction unit;
the judging unit is used for comparing and judging adjacent data bits in all 0/1 bit streams;
the array element construction unit is used for calculating the state change duration of each data bit when the states of adjacent data bits are the same, and accumulating the state change duration in the current int array element;
and when the states of the adjacent data bits are different, shifting the array subscript, and counting the current state to a new int array element.
9. An infrared carrier communication coding system as claimed in claim 8, wherein the duration of the data bit state change T is 1000000/Baud, Baud representing Baud rate.
10. The infrared carrier communication coding system of claim 9, wherein the transmission module comprises a period calculation unit, a square wave data calculation unit, and a square wave data transmission unit;
the period calculating unit is used for acquiring a corresponding period T1-1000000/38000 according to the square wave frequency of the infrared identification;
the square wave data calculation unit is used for calculating the number Num of square waves required to be sent to code [ i ]/T1 according to the state duration of each data bit of the int array so as to obtain square wave data, wherein Num represents the number of the square waves obtained through calculation, codes represents the duration of each segment, and i represents the ith segment;
the square wave data sending unit is used for sending the obtained square wave data.
CN201910815591.0A 2019-08-30 2019-08-30 A kind of infrared carrier wave communication code method and system Pending CN110445548A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910815591.0A CN110445548A (en) 2019-08-30 2019-08-30 A kind of infrared carrier wave communication code method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910815591.0A CN110445548A (en) 2019-08-30 2019-08-30 A kind of infrared carrier wave communication code method and system

Publications (1)

Publication Number Publication Date
CN110445548A true CN110445548A (en) 2019-11-12

Family

ID=68438568

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910815591.0A Pending CN110445548A (en) 2019-08-30 2019-08-30 A kind of infrared carrier wave communication code method and system

Country Status (1)

Country Link
CN (1) CN110445548A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111009111A (en) * 2019-12-12 2020-04-14 上海龙旗科技股份有限公司 Data coding modulation method and system based on SPI bus

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105261199A (en) * 2015-09-21 2016-01-20 深圳市天海基业科技有限公司 Infrared data coding and decoding method and apparatus thereof
CN105869383A (en) * 2016-04-13 2016-08-17 北京精益理想科技有限公司 Infrared data processing method, infrared instruction calling method and infrared instruction calling system
US20190159323A1 (en) * 2015-10-23 2019-05-23 Lutron Electronics Co., Inc. Multiple location load control system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105261199A (en) * 2015-09-21 2016-01-20 深圳市天海基业科技有限公司 Infrared data coding and decoding method and apparatus thereof
US20190159323A1 (en) * 2015-10-23 2019-05-23 Lutron Electronics Co., Inc. Multiple location load control system
CN105869383A (en) * 2016-04-13 2016-08-17 北京精益理想科技有限公司 Infrared data processing method, infrared instruction calling method and infrared instruction calling system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111009111A (en) * 2019-12-12 2020-04-14 上海龙旗科技股份有限公司 Data coding modulation method and system based on SPI bus
CN111009111B (en) * 2019-12-12 2021-08-27 上海龙旗科技股份有限公司 Data coding modulation method and system based on SPI bus

Similar Documents

Publication Publication Date Title
Fang et al. Design and simulation of UART serial communication module based on VHDL
Shi et al. LoRaBee: Cross-technology communication from LoRa to ZigBee via payload encoding
CN102355382A (en) Method for analyzing and triggering controller area network (CAN) bus
CN102681954B (en) Using bus inversion to reduce simultaneous signal switching
CN102625423A (en) Wireless communication system and wake up method thereof
CN102804728B (en) For the treatment of the method and apparatus of packet
KR102148757B1 (en) Method and apparatus for transmitting/receiving data in a communication system
CN102739352A (en) Transition interval coding for serial communication
CN104052577A (en) Signal transmission processing method and device and video data transmission method and system
CN204965470U (en) Optical cable information management system based on cloud label
CN110445548A (en) A kind of infrared carrier wave communication code method and system
CN101599821A (en) A kind of packet loss rate of tire pressure monitoring system method of measurement and device
CN103414663A (en) Morse signal self-adaptive recognition method based on backtracking
CN104796938A (en) Micropower wireless communication error rate detection analyzer
CN102509431A (en) Wireless alarm terminal and method for realizing control on transmission of wireless alarm signals
US20130016762A1 (en) Data communication system, method of optimizing preamble length, and communication apparatus
CN102307078B (en) Method for realizing MVB/WTB frame data real-time decoding by utilizing oscilloscope
CN110300113A (en) Data transmission method and device, storage medium
CN204741451U (en) Digit intercom and data processing device thereof
CN105228151A (en) A kind of method and apparatus of quick transmission air message
Popov Optimization of Communication Protocols for Data Transfer in Highly Noisy Environments
CN104902350A (en) Digital interphone and data processing device and data transmitting method thereof
CN208938320U (en) A kind of wireless communication apparatus based on LORA wireless module
CN1976264A (en) Long-distance monitoring method and system based on short message
CN107359963B (en) Data transmission method and terminal

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20191112

RJ01 Rejection of invention patent application after publication