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
state
square
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
CSG Smart Electrical Technology Co Ltd
CSG Smart Science and 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

A kind of infrared carrier wave communication code method and system
Technical field
The present invention relates to field of communication technology, in particular to a kind of infrared carrier wave communication code method and system.
Background technique
In the field of communications, wired and wireless two kinds of communication modes are broadly divided into, wherein wire communication is influenced by material Transmission range is shorter, and wireless communication is mainly transmitted by modes such as radio, but radio communication will receive electromagnetism Energy interference.And with the development of infrared technique, the appearance of various infrared ray transmitter and receiver sensors, so that Infrared Wireless Communication It is gradually burning hot.
Summary of the invention
The purpose of the present invention is to provide a kind of flexibly and effectively infrared communication coding methods.
In order to achieve the above object, on the one hand, using a kind of infrared carrier wave communication code method, comprising:
Obtain data to be sent;
The beginning flag position that a logic is 0 is added for data, with for indicating that data start to transmit, circulation time in order The data are gone through, each byte content is parsed, obtain 0/1 bit stream;
After each byte content of the data is parsed, obtained all 0/1 bit stream statistic behaviors are changed Duration, and be stored in int array element;
The duration of data bit state each in int array variation is compared with 38K square-wave cycle, obtains each data The 38K square of position is to carry out data transmission.
Further, described to loop through the data in order, each byte content is parsed, 0/1 ratio is obtained Spy's stream, comprising:
Each byte step-by-step of the data parse and parsing result is added to start bit;
Check bit sum stop position is added to data bit according to the data content, obtains 0/1 bit stream.
Further, after each byte content in the data is parsed, to obtained all 0/1 bit streams The duration of statistic behavior variation, and be stored in int array, comprising:
Judgement is compared to the adjacent data position in all 0/1 bit streams;
If the state of adjacent data position is identical, the duration of every data bit state variation is calculated, and by data bit shape The duration of state variation is accumulated on current int array element;
If the state of adjacent data position is not identical, array index is shifted, and current state is counted on to new int array In element.
Further, duration T=1000000/Baud of the data bit state variation, Baud indicate baud rate.
Further, described that the duration of data bit state each in int array variation and 38K square-wave cycle are carried out pair Than obtaining the 38K square of each data bit to carry out data transmission, comprising:
Corresponding cycle T 1=1000000/38000 is obtained according to the square wave frequency of infrared identification;
The square wave number Num=sent needed for being calculated according to the int array each data bit state duration Codes [i]/T1, to obtain square wave data, wherein Num indicates the square wave number that is calculated, and codes indicates every section when continuing Between, i indicates i-th section;
Obtained square wave data are sent.
On the other hand, a kind of infrared carrier wave communication code system is provided, comprising: data acquisition module, parsing module, array Element constructs module and sending module;
Data acquisition module is for obtaining data to be sent;
Parsing module be used for be data add a logic be 0 beginning flag position, be used for indicate that data start to transmit, The data are looped through in order, each byte content is parsed, and obtain 0/1 bit stream;
Array element constructs module and is used for after each byte content of the data is parsed, to all 0/ obtained The duration of 1 bit stream statistic behavior variation, and be stored in int array element;
The duration that sending module is used to change data bit state each in int array and 38K square-wave cycle carry out pair Than obtaining the 38K square of each data bit to carry out data transmission.
Further, the parsing module includes the first adding unit and the second adding unit:
First adding unit is used to carry out each byte step-by-step of the data to parse and be added to parsing result Beginning position;
Second adding unit is used to that check bit sum stop position to be added to data bit according to the data content, obtains one 0/1 bit stream.
Further, the array element building module includes judging unit and array element construction unit;
Judging unit is for being compared judgement to the adjacent data position in all 0/1 bit streams;
When state of the array element construction unit in adjacent data position is identical, holding for every data bit state variation is calculated The continuous time, and the duration of state change is accumulated on current int array element;
And the state in adjacent data position is not identical, and array index is shifted, and current state is counted on to new int In array element.
Further, duration T=1000000/Baud of the data bit state variation, Baud indicate baud rate.
Further, the sending module includes that period computing unit, square wave Data Computation Unit and square wave data are sent Unit;
Period computing unit is used to obtain corresponding cycle T 1=1000000/38000 according to the square wave frequency of infrared identification;
Square wave Data Computation Unit is used to calculate required hair according to the int array each data bit state duration Square wave number Num=codes [the i]/T1 sent, to obtain square wave data, wherein Num indicates the square wave number being calculated, Codes indicates every section of duration, and i indicates i-th section;
Square wave data transmission unit is for sending obtained square wave data.
Compared with prior art, there are following technical effects by the present invention: the present invention, which uses, patrols data to be transmitted addition ' 0 ' is collected for indicating the beginning of data transmission, is parsed by way of handling data step-by-step and increases check bit after data The mode for stopping bit flag obtaining 11 0/1 bit streams of every byte data;Continued by what is changed according to each data bit state Time and 38K square-wave cycle compare to obtain the 38K square of every data, and then guarantee accurate complete transmission number According to.
Detailed description of the invention
With reference to the accompanying drawing, specific embodiments of the present invention will be described in detail:
Fig. 1 is a kind of flow diagram of infrared carrier wave communication code method;
Fig. 2 is a kind of structural schematic diagram of infrared carrier wave communication code system.
Specific embodiment
In order to further explain feature of the invention, reference should be made to the following detailed description and accompanying drawings of the present invention.Institute Attached drawing is only for reference and purposes of discussion, is not used to limit protection scope of the present invention.
As shown in Figure 1, including the following steps S1-S4 present embodiment discloses a kind of infrared carrier wave communication code method:
S1, data to be sent are obtained;
S2, the beginning flag position that a logic is 0 is added for data, followed in order for indicating that data start to transmit Ring traverses the data, parses to each byte content, obtains 0/1 bit stream;
S3, all 0/1 bit stream statistic behaviors change after each byte content of the data is parsed, to obtaining The duration of change, and be stored in int array element;
S4, the duration of data bit state each in int array variation and 38K square-wave cycle are compared, is obtained each The 38K square of data bit is to carry out data transmission.
Stop it should be noted that data step-by-step is handled using coding mode and adds corresponding check bit sum by the application Position is transmitted, to realize the function of infrared carrier wave communication.
Further, in above-mentioned steps S2, the data are looped through in order, and each byte content is parsed, Obtain 0/1 bit stream, comprising:
Each byte step-by-step of the data parse and parsing result is added to start bit;
Check bit sum stop position is added to data bit according to the data content, obtains 0/1 bit stream.
Further, all to what is obtained after each byte content of the data is parsed in above-mentioned steps S3 The duration of 0/1 bit stream statistic behavior variation, and be stored in int array, including step S31-S33:
S31, judge whether the adjacent data position in all 0/1 bit streams is equal;
It should be noted that because each data bit of bit stream only has two states 0 and 1, directly judge whether it is equal, Can determine whether adjacent data position is equal.
If the state of S32, adjacent data position are equal, the duration for this state that adds up, and it is stored in current int array On element;
For example: be exactly that data bit state is constant, then the time for this state that constantly adds up, such as 10001010 this 8 A mode bit, every bit duration are 1ms, then the int array time obtained is 1ms, 3ms, 1ms, 1ms, 1ms, 1ms.
If the state of S33, adjacent data position is not identical, array index is shifted, and by current state duration statistics Into new int array element.
It should be noted that since the final square wave format that the identical data bit of state is sent is identical, so first with according to wave Special rate calculates the duration of every data bit, and state is then judged by the comparison of adjacent data position to be whether identical, if phase Together, then it adds up on current array element (duration), if it is different, then shifting array index, and current state is continued Time counts in new array element.
Specifically, duration T=1000000/Baud of the data bit state variation, Baud indicate baud rate.
Specifically, to the further conversion method of element in int array codes [1000] are as follows: according to the square wave of infrared identification Frequency acquisition corresponds to cycle T 1=1000000/38000, calculates required transmission further according to each state duration of int array Square wave number Num=codes [i]/T1, obtain square wave data, wherein Num indicates the square wave number that is calculated, codes table Show every section of duration, i indicates i-th section, obtained square wave data are finally sent to infrared transmitter and realize infrared carrier wave The function of communication.
As shown in Fig. 2, the present embodiment discloses a kind of infrared carrier wave communication code system, comprising: data acquisition module 10, solution Analyse module 20, array element building module 30 and sending module 40;
Data acquisition module 10 is for obtaining data to be sent;
Parsing module 20 be used for be data add a logic be 0 beginning flag position, be used for indicate that data start to pass It is defeated, the data are looped through in order, each byte content is parsed, and obtain 0/1 bit stream.Wherein, the parsing Module 20 includes the first adding unit and the second adding unit:
First adding unit is used to carry out each byte step-by-step of the data to parse and be added to parsing result Beginning position;
Second adding unit is used to that check bit sum stop position to be added to data bit according to the data content, obtains one 0/1 bit stream.
Array element constructs module 30 and is used for after each byte content of the data is parsed, all to what is obtained The duration of 0/1 bit stream statistic behavior variation, and be stored in int array.Wherein, the array element constructs module 30 Including judging unit and array element construction unit;
Judging unit is for being compared judgement to the adjacent data position in all 0/1 bit streams;
When state of the array element construction unit in adjacent data position is identical, holding for every data bit state variation is calculated Continuous time, duration T=1000000/Baud of data bit state variation, Baud indicate baud rate, and by state change Duration is accumulated in current int array element;
And the state in adjacent data position is not identical, and array index is shifted, and current state is counted on to new int In array element.
The duration and 38K square-wave cycle that sending module 40 is used to change data bit state each in int array carry out Comparison, obtains the 38K square of each data bit to carry out data transmission.Wherein,
Sending module 40 includes period computing unit, square wave Data Computation Unit and square wave data transmission unit;
Period computing unit is used to obtain corresponding cycle T 1=1000000/38000 according to the square wave frequency of infrared identification;
Square wave Data Computation Unit is used to calculate required hair according to the int array each data bit state duration Square wave number Num=codes [the i]/T1 sent, to obtain square wave data, wherein Num indicates the square wave number being calculated, Codes indicates every section of duration, and i indicates i-th section;
Square wave data transmission unit is for sending obtained square wave data.
It should be noted that the application method can be realized by raspberry pie, specifically:
(1) data content for needing to send by the host computer interface software input of raspberry pie, clicks " transmission " order, tree Certain kind of berries group obtains the data of upper computer software interface input.
(2) raspberry pie first adds the beginning flag position that a logic is ' 0 ' after getting data, indicates to start data Transmission.Data content is looped through in order again, after step-by-step is parsed (totally 8) and is added to start bit, finally according to number After check bit sum stop position is added to data bit according to content, one 11 0/1 bit streams are obtained.
(3) after all data are parsed, to all 0/1 bit stream of storage, data bit state variation is calculated Duration T=1000000/Baud, Baud indicate baud rate.Then judged by the comparison of adjacent bit state for whether phase Together, if they are the same, then it adds up on current array element (duration), if it is different, then shift array index, and by current shape State counts in new array element.
(4) square wave frequency that every section in int array of duration is converted into infrared identification is obtained into corresponding cycle T 1= The square wave number Num=codes of transmission needed for 1000000/38000, int array each data bit state duration calculates Int array data is converted into the square wave data of 38K, and is transferred to infrared emission by raspberry pie CPU pin by [i]/T1 Device carries out data transmission.
The application is by the interface operation of raspberry pie, so that the data content of Infrared Transmission is more flexible, raspberry pie interface is defeated Enter to transmit data and the identifiable 38K rectangular wave of infrared receiver is converted to by specific mode, to realize infrared load Wave communication.
The foregoing is merely presently preferred embodiments of the present invention, is not intended to limit the invention, it is all in spirit of the invention and Within principle, any modification, equivalent replacement, improvement and so on be should all be included in the protection scope of the present invention.

Claims (10)

1. a kind of infrared carrier wave communication code method characterized by comprising
Obtain data to be sent;
The beginning flag position that a logic is 0 is added for data, to loop through institute in order for indicating that data start to transmit Data are stated, each byte content is parsed, obtain 0/1 bit stream;
After each byte content of the data is parsed, to holding for obtained all 0/1 bit stream statistics state of each bit The continuous time, and it is stored in int array element;
The duration of data bit state each in int array variation is compared with 38K square-wave cycle, obtains each data bit 38K square is to carry out data transmission.
2. infrared carrier wave communication code method as described in claim 1, which is characterized in that described in the searching loop in order Data parse each byte content, obtain 0/1 bit stream, comprising:
Each byte step-by-step of the data parse and parsing result is added to start bit;
Check bit sum stop position is added to data bit according to the data content, obtains 0/1 bit stream.
3. infrared carrier wave communication code method as claimed in claim 2, which is characterized in that each word in the data After the completion of saving Context resolution, to the duration of obtained all 0/1 bit stream statistic behaviors variation, and it is stored in int array In, comprising:
Judgement is compared to the adjacent data position in all 0/1 bit streams;
If the state of adjacent data position is identical, the duration of every data bit state variation is calculated, and data bit state is become The duration of change is accumulated on current int array element;
If the state of adjacent data position is not identical, array index is shifted, and by current state duration statistics to new int Array element.
4. infrared carrier wave communication code method as claimed in claim 3, which is characterized in that the data bit state variation is held Continuous time T=1000000/Baud, Baud indicate baud rate.
5. infrared carrier wave communication code method as claimed in claim 4, which is characterized in that described to each data in int array The duration of position state change compares with 38K square-wave cycle, obtains the 38K square of each data bit to carry out data It sends, comprising:
Corresponding cycle T 1=1000000/38000 is obtained according to the square wave frequency of infrared identification;
The square wave number Num=codes sent needed for being calculated according to the int array each data bit state duration [i]/T1, to obtain square wave data, wherein Num indicates the square wave number being calculated, and codes indicates every section of duration, i table Show i-th section;
Obtained square wave data are sent.
6. a kind of infrared carrier wave communication code system characterized by comprising data acquisition module, parsing module, array element Construct module and sending module;
Data acquisition module is for obtaining data to be sent;
Parsing module be used for be data add a logic be 0 beginning flag position, be used for indicate that data start to transmit, by suitable Sequence loops through the data, parses to each byte content, obtains 0/1 bit stream;
Array element constructs module and is used for after each byte content of the data is parsed, to obtained all 0/1 ratios The duration of special stream statistics state change, and it is stored in int array element;
The duration that sending module is used to change data bit state each in int array compares with 38K square-wave cycle, obtains To each data bit 38K square to carry out data transmission.
7. infrared carrier wave communication code system as claimed in claim 6, which is characterized in that the parsing module adds including first Add unit and the second adding unit:
First adding unit is used to carry out parsing to each byte step-by-step of the data and parsing result is added to start bit;
Second adding unit is used to that check bit sum stop position to be added to data bit according to the data content, obtains described in one 0/1 bit stream.
8. infrared carrier wave communication code system as claimed in claim 7, which is characterized in that the array element constructs module packet Include judging unit and array element construction unit;
Judging unit is for being compared judgement to the adjacent data position in all 0/1 bit streams;
When array element construction unit is identical for state in adjacent data position, calculate every data bit state variation it is lasting when Between, and the duration of state change is accumulated in current int array element;
And the state in adjacent data position is not identical, and array index is shifted, and current state is counted on to new int array Element.
9. infrared carrier wave communication code system as claimed in claim 8, which is characterized in that the data bit state variation is held Continuous time T=1000000/Baud, Baud indicate baud rate.
10. infrared carrier wave communication code system as claimed in claim 9, which is characterized in that the sending module includes the period Computing unit, square wave Data Computation Unit and square wave data transmission unit;
Period computing unit is used to obtain corresponding cycle T 1=1000000/38000 according to the square wave frequency of infrared identification;
What square wave Data Computation Unit was sent needed for being used to be calculated according to the int array each data bit state duration Square wave number Num=codes [i]/T1, to obtain square wave data, wherein Num indicates the square wave number being calculated, codes table Show every section of duration, i indicates i-th section;
Square wave data transmission unit is for sending 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
Yuan et al. A Coexistence Model of IEEE 802.15. 4 and IEEE 802.11 b/g
CN105704252B (en) Bluetooth low energy device data transmission method and device
CN104488348A (en) Method, apparatus, and computer program product for adaptive device discovery in wireless networks
CN102238608A (en) Wireless device testing method based on wireless ad hoc network
CN108040339A (en) Offline network-building method and its system based on LoRa
CN104391586B (en) A kind of input through keyboard detection method and detecting system based on mobile terminal
CN110445548A (en) A kind of infrared carrier wave communication code method and system
He et al. An accurate Markov model for slotted CSMA/CA algorithm in IEEE 802.15. 4 networks
Huang et al. A compact and cost-effective BLE beacon with multiprotocol and dynamic content advertising for IoT application
Zhang et al. A blind adaptive tuning algorithm for reliable and energy-efficient communication in IEEE 802.15. 4 networks
CN102970737B (en) A kind of contention resolution of the wireless network transmissions based on constructive interference and system
Zhang et al. Topology performance analysis of zigbee network in the smart home environment
CN106330397B (en) method and device for realizing data interaction by ZigBee and Modbus RTU (remote terminal Unit) protocols
Davut et al. The comparison of energy consumption of different topologies in multi-hop wireless sensor networks
Schmidt et al. Bit error distribution and mutation patterns of corrupted packets in low-power wireless networks
Hernandez Wireless process control using IEEE 802.15. 4 protocol
KR20150080997A (en) Multiple tactical datalink message processing method using markup language
CN102665241A (en) Wireless sensor network (WSN) node parameter configuration method based on ZigBee protocol stack (ZStack)
Amin et al. A Simulation Model of IEEE 802.15. 4 GTS Mechanism and GTS Attacks in OMNeT++/MiXiM+ NETA.
Hu et al. Efficient modeling and performance analysis for IEEE 802.15. 4 with coloured petri nets
Yuan et al. Performance Research of ALOHA Protocol
Salles et al. Performance study of IEEE 802.15. 4 for industrial maintenance applications
CN106921956A (en) The method of automatic configuration on wireless network card equipment based on wireless network
CN113395730A (en) Internet of things terminal network parameter reporting method and device and storage medium
Pattanaik et al. Performance analysis of modified IEEE 802.15. 4e MAC for wireless sensor networks

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