Background
With the birth and application of new concepts of urban development such as energy conservation and environmental protection, the LED lamp gradually becomes an essential lighting device for factories, shops and homes by virtue of higher energy efficiency and longer service life. In addition to the lighting function, LEDs have the capability of switching at high speed. Compared with the light sources of the existing lighting equipment such as fluorescent lamps, incandescent bulbs and the like, the LED visible light has the characteristic of easy modulation, so that the LED visible light can provide convenient data service for indoor users. Compared with a Radio Frequency (RF) based technology, such as a WIFI communication and Radio Frequency Identification (RFID) technology, VLC bandwidth resources are rich, power consumption is low, privacy is high, electromagnetic interference is avoided, and light is limited in a certain area due to the fact that the VLC bandwidth resources are blocked when the VLC bandwidth resources meet a wall in the transmission process, so that communication privacy is protected. The transmission distance is sacrificed, but the method has more outstanding value in real application such as families, shopping malls, parking lots and the like.
The smart phone is gradually popularized at present, the smart phone becomes a necessary living tool for people, and the function of the camera of the smart phone lays a material foundation for receiving light source signals. The mobile phone camera on the market at present basically uses a CMOS image sensor, the CMOS image sensor controls exposure by an electronic shutter, different electronic shutter modes including a rolling shutter mode and a global shutter exposure mode can be generated by different working modes and time sequences of the same structure array, and the current mobile phone camera basically adopts the rolling shutter exposure mode. In this manner, the CMOS image sensor array is exposed line by line and then read out line by line. Because the rolling frequency is faster than the LED flickering frequency, the exposed image is a fringe pattern with alternate light and shade. The scrolling frequency is determined by the camera itself, and the frequency is not changed, so that the desired code stripes can be displayed on the image by changing the flashing frequency of the LEDs.
Common coding methods are NRZ coding, manchester coding, and PPM coding. In the coding method based on data stream, a unit bright stripe represents a code 1, a unit dark stripe represents a code 0, if too much 0 occurs, the lamp may flicker, if the number difference between 0 and 1 is too large, the stability of illumination may be affected, and even the normal operation of the LED lamp circuit may be disturbed. And Manchester coding utilizes the jump direction of a signal to determine data, 2-bit coding is used for representing 1-bit data, the coding efficiency is only 50%, but the Manchester coding also ensures that the number of 1 and 0 is equal, and the Manchester coding can ensure that the 1 has 50% of the ratio no matter how the coding to be transmitted changes, thereby realizing balanced transmission. The PPM coding adopts carrier waves which are intermittent periodic light pulses, the positions of the pulses are controlled by coding through binary information of a source, and therefore the coding efficiency is only 50%.
Disclosure of Invention
The invention aims to provide a frequency modulation coding decoding and code spreading method for visible light communication aiming at the defects in the prior art, and provides a communication method of lighting equipment and mobile equipment with an image acquisition module on the basis of giving consideration to lighting and coding efficiency.
In order to achieve the purpose, the invention adopts the following technical scheme:
a frequency modulation coding decoding and code expanding method for visible light communication comprises the following steps: step one, encoding original data bits according to a frequency modulation method, adding a single communication head, and driving an LED to emit light to circularly transmit the code through an LED encoding driver. And step two, the image receiving module shoots the LED lamp to obtain a light and shade coding stripe image. And step three, the image processing module decodes according to the single communication header in the image to obtain the original data bit. Optionally, after the third step, the method further comprises: and fourthly, when the coding capacity generated by single-communication-head coding is too small and does not meet the requirement, long data meeting the capacity requirement can be constructed, the long data is divided into a plurality of sections of short data, each section of short data is subjected to frequency modulation coding and is added with different communication heads carrying sequence information, each section of short data is obtained after decoding, the short data is combined into original long data according to the sequence of the communication heads, and data spreading is achieved.
In the single communication head data coding method in the first step, the closing time of the LED lamp is fixed every time, namely the width of a dark stripe of a received image is not changed; the width of the bright stripes is changed by changing the turn-on time of the LED lamp, and the frequency change is represented. Using binary coding
Binary data representing "0", and the shortest can be "01"; encoding
The data "1" is represented, b > a, the shortest can be "011", the number of 1 in the code can be increased or decreased according to different scenes, but the stripe images of the data "0" and the data "1" are ensured to be distinguished.
In the step one, the single communication head is coded into
m>b>a, the shortest communication head may be set to "0111". Further, according to the decoding method in the third step, the widest bright stripe, namely the communication head characteristic area is found, and the unit bright stripe reference width can be obtained
Traversing from the communication head to the right, sequentially comparing with a reference width according to the absolute width of each bright stripe, obtaining a width scalar after normalization treatment, namely the number of 1 represented by each bright stripe, judging a data bit corresponding to the bright stripe representation according to the width scalar, traversing from the communication head to the left sequentially to obtain a left data bit, and combining the two groups of data to obtain original data;
optionally, when the coding capacity of the single-header coding is too small to meet the requirement, different headers can be used to provide sequence information to realize the combined spreading code of the multi-segment coding, for example, the header is
Time is indicative of a high-bit data head,

time represents a low-bit data head, and m is not equal to n; after each segment of code is decoded respectively, splicing two groups of data according to the sequence information of the communication head; when two continuous frame codes sent by the LED are codes of different sections, a bit of 0 code needs to be added between the two frame codes for distinguishing, and a dark stripe corresponding to a 00 code appears at the boundary of the two frame codes after the 0 code is added and is distinguished from a 0 code dark stripe in a data area. Further, when decoding is carried out according to the multi-communication head, whether the left end of the maximum dark stripe is a 00 coding dark stripe or not is judged, and if yes, the decoding is only allowed to be traversed rightwards; if not, a single header decoding technique, i.e., left-to-right bi-directional traversal decoding, may be applied. When more original data bits are available, the original data bits can be split into k segments according to the method, and k segments are set to be similar to the original data bits


The communication head of (1) represents the order of the communication head, provides the order information of the segmented data, and realizes the segmented encoding and decoding of the long dataCode and combining.
Compared with the prior art, the invention has the following obvious prominent substantive characteristics and remarkable technical progress: the NRZ encoding has a wide variation range of the luminous flux modulation rate with the change of the encoding, and complex encoding screening is required to ensure the luminous flux modulation rate, while the frequency modulation method uses fixed encoding instead of data "0" and "1" due to its own encoding characteristics, and the part that needs to be changed according to the situation is only the communication header part, and does not need to perform complex encoding screening to ensure the luminous flux modulation rate. The method has the advantages of uniformity in the decoding process, no need of table lookup for decoding, simplification of the table lookup step on the basis of meeting the requirement of illumination, and good consistency and simplicity.
Detailed Description
The embodiments of the invention, however, are not limited to the details of implementation and the features and advantages thereof as described below with reference to the preferred embodiments and the accompanying drawings.
The first embodiment is as follows: with reference to figures 1-5 of the drawings,
the frequency modulation coding decoding and code expanding method for visible light communication comprises the following operation steps: step one, encoding original data bits according to a frequency modulation method, adding a single communication head, and driving an LED to emit light to circularly transmit the code through an LED encoding driver. And step two, the image receiving module shoots the LED lamp to obtain a light and shade coding stripe image. And step three, the image processing module decodes according to the single communication header in the image to obtain the data bit. Step four, as shown in fig. 1, when the coding capacity generated by single header coding is too small and does not meet the requirement, long data required to meet the capacity requirement can be constructed, the long data is split into multiple sections of short data, each section of short data is subjected to frequency modulation coding and added with different communication headers carrying sequence information, each section of short data is obtained after decoding, and the short data is combined into original long data according to the sequence of the communication headers, so that data spreading is realized.
The following is a detailed description:
step one, the mobile phone camera in the market at present basically uses a CMOS image sensor, the CMOS image sensor controls exposure by an electronic shutter, and at present, a rolling shutter exposure mode is basically adopted. In this manner, the CMOS image sensor array is exposed row by row and then read out row by row as shown in fig. 2. Because the rolling frequency is faster than the LED flickering frequency, the exposed image is a fringe pattern with alternate light and shade. The scrolling frequency is determined by the camera itself, and the frequency is not changed, so that the desired code stripes can be displayed on the image by changing the flashing frequency of the LEDs. Therefore, the data desired to be transmitted is encoded in binary according to
Representing binary data of "0", the shortest being "01", encoding
The data "1" (b > a) can be "011" at the shortest time, but it is guaranteed that the data "0" can be distinguished from the data "1". In order to successfully realize decoding, a communication header must be provided to provide decoding start position information, and the present invention uses encoding into
Provides decoding start position information, but is required to be associated with encoding of data "1
The shortest communication head can be set to be '0111' by obviously distinguishing, and the LED coding driver drives the LED to emit light circularly to send the codeThe first step of the method is completed.
And step two, the mobile phone camera shoots the LED, and a fringe pattern with alternate light and shade is presented on the picture, as shown in figure 3. Then, image processing is performed on the picture, and decoding is performed.
Step three, after the image as shown in fig. 3 is obtained, the widest bright stripe can be found out obviously (to ensure the effectiveness of the bright stripe, that is, dark stripes must be arranged on both sides of the bright stripe to ensure the integrity of the data), so that it can be concluded that the region is the communication header portion, and according to the encoding of the communication header at first
The unit bright stripe reference width can be obtained
Traversing from the communication head to the right, sequentially finding effective bright stripes, sequentially comparing the effective bright stripes with a reference width according to the absolute width of each bright stripe, normalizing to obtain a width scalar (namely the number of 1 represented by each bright stripe), and judging the data value represented by the corresponding bright stripe according to the width scalar; traversing from the communication head to the left in sequence, finding out effective bright stripes on the left side to obtain data bits on the left side, combining the two groups of data, and removing overlapped parts to obtain original data;
optionally, step four, because the coding capacity of a single communication header is limited, in practical application, long data meeting the capacity requirement can be constructed, the long data is split into k segments, and k segments similar to the k segments are set
And each section of split short data is subjected to frequency modulation coding, different communication heads carrying sequence information are added respectively, and an LED coding driver drives an LED to emit light to circularly send the group of codes. When decoding, the position of the information is judged according to the number of 1 in the communication head code in each image, and the original data can be restored by combining a plurality of images in sequence after decoding.
In an environment where sufficient light is required, "011" is used to represent data "0",the scalar width is 2, data "1" is represented by "0111", the scalar width is 3, as shown in fig. 4, the "01111" is used as a single communication head, the variation range of the luminous flux modulation rate is 66.7% -75%, and the illumination requirement is met. On the basis, if a decimal number 231 is desired to be sent to the mobile phone end through the LED lamp, the binary data is {011100111}, a single communication header is added to the binary data and then the binary data is encoded into {01111,011,0111,0111,0111,011,011,0111,0111,0111}, and an image obtained by shooting the LED by the mobile phone is shown in fig. 5: effective stripe w
maxbThe unit bright stripe reference obtained based on the maximum bright stripe, i.e. the communication head feature region, is:
traversing from the communication head to the right, and obtaining the effective bright stripe as w
1b、w
2b、w
3b,w
4bFinding them and w
unitbThe width scalars of (a) are 2,3,3,3, respectively. Can obtain the product
Representing data of {0111 }. The communication head traverses leftwards to obtain the effective bright stripes w
9b~w
4bFind out them and
the width scalars are {3,3,3,2,2,3}, respectively, and can be obtained
The representative data is {100111}, and the two are expressed as w
1b~w
9bCombining, splicing and eliminating overlapped parts w
4bThen, the complete binary code can be obtained:
the binary data is {011100111}, and the decimal value is 231, so that the communication between the LED and the mobile phone is realized.
Example two: the present embodiment is substantially the same as the first embodiment, and is characterized in that: with reference to figure 6 of the drawings,
if the requirement of the working environment on illumination is not high, a '01' is used to represent a data bit '0', the width scalar is 1, a '011' is used to represent a data bit '1', and the width scalar is 2, as shown in fig. 6. When the shortest communication head '0111' is used, the light flux modulation rate can be changed within the range of 50% -66.7%, and the illumination effect can also be achieved. In this encoding case, since the number of stripes that can be photographed by a single image is fixed, using fewer stripes to represent one bit of data can lead to higher encoding capacity. The subsequent codec process is the same as in example 1. Therefore, the number of 1's in the code can be increased or decreased according to the actual use situation in exchange for high illumination or high code amount.
Example three: with reference to figures 7-8 of the drawings,
when the single-pattern coding amount does not meet the requirement, different communication heads can be used for representing different segments of data, for example, the communication head "01111" represents high-order data, and "011111" represents low-order data. However, if two sets of codes are spliced directly, the left side and the right side of the communication head may not be the same segment of coded data, and bidirectional traversal decoding cannot be performed. Therefore, when two continuous frames of codes sent by the LED are codes of different sections, a 0-bit code needs to be added between the two frames of codes for distinguishing, dark stripes corresponding to 00 codes appear at the code boundaries of the different sections after the 0 codes are added, the dark stripes are distinguished from the 0-code dark stripes in the data area, and the code patterns are shown in fig. 7 and 8. And during decoding, judging whether the left end of the effective maximum bright stripe is a 00 coding dark stripe or not, if so, only allowing to perform traversal decoding rightward, and if not, applying a single communication header decoding technology, namely performing bidirectional traversal decoding leftward and rightward. When the code is spread, it is impossible to know in advance whether the communication header is "01111" or "011111". The method adopted by the invention is that firstly, the narrowest bright stripe and the narrowest dark stripe of the interested area are compared, namely the width ratio of the unit dark stripe, the shortest bright stripe represents 11 or 111 according to the ratio, and the width w of the unit bright stripe is further obtainedunitb. According to wmaxbAnd wunitbThe ratio may determine the number of communication heads containing 1's.
In order to verify the feasibility of the multi-communication-head decoding technology and the code expanding method, the modulated lamp continuously and circularly transmits two sections of codes, and each section of code is continuously transmitted twiceEvery time one segment of code is transmitted for 2 times, a 0 bit code is added to distinguish another segment of code which is transmitted next. FIG. 7 shows a code segment with a communication header of "011111" and a communication data area of "101110110" and only from wmaxb2In the case where the communication head makes a one-way traversal to the right to acquire the code, fig. 8 shows a code segment with a communication head of "01111" and a communication data region of "111100111" and may be traversed from wmaxb1And the communication head is traversed in a left-right direction to acquire the condition of the code. In the spread code method, encoded data in which a communication header is specified to be "01111" is located at a high order. As shown in fig. 7, wmaxb2The unit of bright stripe is 5 times, the width of the dark stripe at the left end is 2 times of the unit of dark stripe, so the decoding traversal can only be performed to the right, and the corresponding binary data can be obtained as {101110110 }. As shown in fig. 8, wmaxb1The unit of bright stripe is 4 times, the width of the dark stripe at the left end is 1 time of the unit of dark stripe, therefore, the decoding traversal can be performed leftwards and rightwards, and the corresponding binary data is obtained as {111100111} by using the single-header decoding technology. Combining the two sets of codes yields binary long data as {111100111101110110 }.
Compared with the prior art, the coding and decoding processes of the invention are simpler, the coding and decoding are consistent, and the stripe width is determined and distinguished obviously, so that the error is not easy to occur. The single communication coding is fast and convenient, and the communication speed is high. When higher coding quantity is needed, better coding capacity can be obtained through spreading codes, and the practical application of the future related fields can be completely met.