A kind of high reliability data transmission method and device based on dual-tone multifrequency sound wave
Technical field
The present invention relates to wireless communication technology, relate in particular to a kind of high reliability data transmission method and device based on dual-tone multifrequency sound wave.
Background technology
At present, communication modes between mobile phone or between mobile phone and computer is more, comprise bluetooth, wireless network and other near-field communication modes, but these communication modes have higher and specific requirement to hardware configuration, the process of setting up communication is comparatively loaded down with trivial details, hardware and software cost is higher, and coverage rate is narrow, is not easy to carry out the mutual transfer of data higher to the reliability requirement of transfer of data such as secret data that pass between mobile phone on-site payment and mobile phone.
Publication number is the patent application of CN101247183A, discloses a kind of high frequency waveforms of a certain frequency that adopts in conjunction with horizontal component, expresses 1,0 numerical value, realizes the method for ultrasonic communication.The cooperation transformation of the method based on hardware module, adopts MCU (Micro Control Unit is called for short micro-control unit) interrupt mode to read envelope parameters at transmitting terminal, sends high frequency analog signals; Receiving terminal analog circuit to microphone analog signal amplify, bandpass filtering, envelope detection and Shape correction, obtain low-frequency square-wave signal, be then decoded as binary data.Before communication information, increase a high level start bit, by receiving terminal analog circuit, judge whether this start bit high level signal continues 4~9 milliseconds, to judge whether to receive communication information; While accepting communication information, receiving terminal MCU opens interrupters, data bit is for " 0 " to be read as low level, and high level data bit is " 1 ".But when actual use ultrasonic wave carries out data communication, the loudspeaker of mobile phone, computer accessory, the audio frequency range of microphone are narrower, sensitvity constraint, and affected by environmental noise, easily there is sound wave distortion, while causing transfer of data, error rate is too high, can not reach the real requirement of high reliability data transmission.The method of this Patent Application Publication, adopts binary mode coded data, and the amount of information of per unit transmission data is few, and during big data quantity transmission, the probability that meets wave distortion is high; The judgement of " 0 ", " 1 " numerical value simply just determines by level, and when environmental noise impact is larger, the high low value distortion rate of level is high, and the threshold value of low and high level boundary changes greatly with environmental impact, cannot accurately arrange; When the judgement of certain bit data goes wrong, cannot verification error correction, make mistakes for one, can cause whole message to be made mistakes; The physique of mobile phone, computer has cured when dispatching from the factory, and the cost of transforming again circuit during application is too high.The method is difficult to meet the real requirement that mobile phone, computer carry out the transfer of data of high reliability.
Dual-tone multifrequency (Dual Tone Multi Frequency is called for short DTMF) is the signaling method of being developed by Bell Laboratory, and the analog of telephone line transmission dialing information by voice-bearer is widely used in telephone communication.DTMF is comprised of high frequency group and low frequency group, and high frequency group and low frequency group respectively comprise 4 frequencies.A high-frequency signal and a low frequency signal stack form a composite signal, represent a numeral, so dtmf signal have 16 codings.If traditional DTMF mode is directly applied in to audio frequency of mobile terminal data communication aspect, there are some problems below: 1, in transmission, have the dialing tone that can be heard, the dialing tone of long period can allow user uncomfortable; 2, (the International Telephone and Telegraph Consultative Committee of CCITT, abbreviation CCITT) stipulate 10 keys of pressing at most per second, be the shortest 100MS of being of each key time slot, the actual duration of its sound intermediate frequency is at least 45MS, be not more than 55MS, in the other times of time slot, keep mourning in silence, when therefore button produces double-audio signal, two a period of times in sigtnal interval in succession, this mode that is applicable to hardware decoder is difficult to be processed by the software of the mobile terminals such as mobile phone; 3,, after microphone location, the impact of environmental noise will cause the judgement of quiet period inaccurate; 4, do not consider check sum error correction.
If adopt the mode of single-tone multifrequency acoustic signals, transmit data, its shortcoming is in each time period, and single-frequency signals can only represent a numerical value, and the data volume of unit transmission is not enough, cause the time of transfer of data to lengthen, be more subject to environmental noise impact and occur mistake.
Summary of the invention
Goal of the invention: in order to overcome the deficiencies in the prior art, the invention provides a kind of high reliability data transmission method and device based on dual-tone multifrequency sound wave, do not changing on the physique of terminal and the basis of operating system, utilizing the loudspeaker of terminal and the transfer of data that microphone is realized high reliability.
Technical scheme: the high reliability data transmission method based on dual-tone multifrequency sound wave of the present invention, comprises the steps:
A high reliability data transmission method based on dual-tone multifrequency sound wave, comprises the steps:
(1) first by data generating unit, calculate the check value that needs transmission data, give and need transmission data to add verification beginning flag and check value, form partial data;
(2) again by dual-tone multifrequency information coding unit to the partial data obtaining in step (1), contrast coding rule, be transformed in corresponding dual-tone multifrequency superposed signal, according to sending duration, form continuous dual-tone multifrequency superposed signal information;
(3) by dual-tone multifrequency sound wave transmitting element, control sound-producing device and send continuously acoustic signals according to dual-tone multifrequency superposed signal information, and constantly circulation, until be transmitted or arrive time-out time;
(4) by dual-tone multifrequency sound wave receiving element, control the acoustic signals that listening device short distance reception sound-producing device sends, until the audio-frequency information receiving reaches length requirement, preserve the complete audio-frequency information receiving, and the initial value of setting period i is 0;
(5) by dual-tone multifrequency information decoding unit, the complete audio-frequency information of preserving is calculated to parsing, contrast the coding rule identical with step (2), complete audio-frequency information is divided into the time slice of respective number by sending duration length, according to amplitude size sequence, choosing two frequencies in each time slice and resolving the dual-tone multifrequency superposed signal consisting of it is respective value, forms one group of partial data; By data verification units, this partial data is carried out to verification, judge that whether verification is successful, if the determination result is YES, completes the transfer of data of dual-tone multifrequency sound wave;
(6) if the determination result is NO in step (5), judge whether period i=n sets up, if the determination result is YES, and the data transmission fails of multifrequency sound wave, wherein, n is greater than 1 natural number;
(7), if the determination result is NO in step (6), preserve again i=i+1 after the original position of the complete audio-frequency information receiving in step (4) being offset to a shift time length backward; Return to step (5), described shift time length is the 1/n of sending duration length.
Said method can also adopt computer software method to realize.
In described step (1), data generating unit can adopt CRC (Cyclic Redundancy Check, cyclic redundancy check (CRC)) check addition calculates the check value that needs transmission data, can also be other checking algorithms, as bcc (block check character exclusive or check method), parity check (Parity Check) etc.; Verification beginning flag can be " 0F ".
Frequency of sound wave scope corresponding in described step (2) within the scope of 16KHz~22KHz, the sound in this frequency range, the mankind are difficult to discover, but the loudspeaker of mobile phone, computer, microphone etc. but can be processed.
Coding rule in described step (2) can adopt PCM (Pulse-code modulation, pulse code modulation) audio coding, the pcm audio most mobile phones of coding and computer can both be supported, simultaneously in conjunction with multiple compaction algorithms method, can reduce data volume and transmission quantity.Pcm audio coding is a kind of number method of analog signal, and it is divided into several sections by the intensity of signal according to same spacing, then uses unique digital mark.In step (2), by the encoded conversion of partial data of pcm audio, in step (4), by pcm audio, encode and preserve the audio-frequency information receiving.
In described step (3), acoustic signals sends with sine waveform.
The acoustic signals sample frequency that listening device receives in described step (4) 44.1KHz or more than, the acoustic signals within the scope of 16KKHz~22KHz can be rebuild out completely from sample.
A kind of for realizing the device of the above-mentioned high reliability data transmission method based on dual-tone multifrequency sound wave, comprise and be connected with sound-producing device to send the transmitting terminal of acoustic signals and to be connected with listening device to receive the receiving terminal of acoustic signals, described transmitting terminal comprises data generating unit, dual-tone multifrequency information coding unit and dual-tone multifrequency sound wave transmitting element, and described receiving terminal comprises dual-tone multifrequency sound wave receiving element, dual-tone multifrequency information decoding unit and data verification units;
Described data generating unit, calculates the check value that needs transmission data, gives and needs transmission data to add verification beginning flag and check value, forms partial data;
Described dual-tone multifrequency information coding unit, each numerical value of the partial data that data generating unit is generated is transformed in corresponding dual-tone multifrequency superposed signal, according to sending duration, form continuous dual-tone multifrequency superposed signal information, realize the corresponding conversion of data and dual-tone multifrequency acoustic signals;
Described dual-tone multifrequency sound wave transmitting element, the dual-tone multifrequency superposed signal information that control sound-producing device obtains by dual-tone multifrequency information coding cell translation is sent acoustic signals continuously;
Described dual-tone multifrequency sound wave receiving element, controls listening device and receives the acoustic signals that sound-producing device sends, and preserve information;
Described dual-tone multifrequency information decoding unit, the information that dual-tone multifrequency sound wave receiving element is preserved is calculated, is decoded;
Described data verification units, carries out verification to decoded data.
Described sound-producing device is that loudspeaker or other can send the hardware module of sound wave, and described listening device is that microphone or other can receive the hardware module of sound wave.
Beneficial effect: a kind of high reliability data transmitting device and method thereof based on double frequency multifrequency sound wave provided by the invention, low to hardware requirement, only need to be equipped with loudspeaker, microphone just can carry out transfer of data, can on mobile phone, computer, use, be conducive to realize fast, at low cost application and service; When dual-tone multifrequency information decoding, after employing multistep calculations of offset, relatively gather the method for value, the difficult problem that effective address signal start bit is searched; When data generation and data verification, adopt checksum algorithm to guarantee data consistency.
Accompanying drawing explanation
Fig. 1 is the structural representation of apparatus of the present invention.
Fig. 2 is the flow chart of the inventive method.
Embodiment
Below in conjunction with accompanying drawing, the present invention is further described.
Be illustrated in figure 1 a kind of high reliability data transmitting device based on double frequency multifrequency sound wave, comprise the transmitting terminal that is connected with loudspeaker and the receiving terminal that is connected with microphone, described transmitting terminal is mobile phone or computer, and receiving terminal is also mobile phone or computer; Described transmitting terminal comprises data generating unit, dual-tone multifrequency information coding unit and dual-tone multifrequency sound wave transmitting element, and described receiving terminal comprises dual-tone multifrequency sound wave receiving element, dual-tone multifrequency information decoding unit and data verification units.
Described data generating unit, calculates the check value that needs transmission data, gives and needs transmission data to add verification beginning flag and check value, forms partial data; Described dual-tone multifrequency information coding unit, each numerical value of the partial data that data generating unit is generated is transformed in corresponding dual-tone multifrequency superposed signal, according to sending duration, form continuous dual-tone multifrequency superposed signal information, realize the corresponding conversion of data and dual-tone multifrequency acoustic signals; Described dual-tone multifrequency sound wave transmitting element, the dual-tone multifrequency superposed signal information that control loudspeaker obtain by dual-tone multifrequency information coding cell translation is sent acoustic signals continuously.
Described dual-tone multifrequency sound wave receiving element, controls microphone and receives the acoustic signals that loudspeaker send, and preserve information; Described dual-tone multifrequency information decoding unit, the information that dual-tone multifrequency sound wave receiving element is preserved is calculated, is decoded; Described data verification units, carries out verification to decoded data.
Be illustrated in figure 2 a kind of high reliability data transmission method based on dual-tone multifrequency sound wave, definition sending duration is 40ms, keep acting in agreement of transmitting terminal and receiving terminal, and data encoding unit and data decode unit adopt identical coding rule, concrete transmitting step is as follows:
(1) by data generating unit, adopt CRC check method to needing transmission data to add verification beginning flag and check value, form partial data.Adopt 16 system modes to define partial data, 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E and 16 numerical value of F, corresponding one by one with 16 groups of double-tone frequencies respectively, in this example, coding schedule corresponding to dual-tone multifrequency superposed signal is as shown in table 1.
The stack of table 1 dual-tone multifrequency is good corresponding coding schedule first
Low frequency/high frequency |
18100 |
18400 |
18700 |
19000 |
16100 |
0 |
1 |
2 |
3 |
16400 |
4 |
5 |
6 |
7 |
16700 |
8 |
9 |
A |
B |
17000 |
C |
D |
E |
F |
According to table 1, can learn the superposed signal corresponding to the dual-tone multifrequency superposed signal of each numerical value, as shown in table 2.
Table 2 is corresponding to the superposed signal of the dual-tone multifrequency superposed signal of each numerical value
The partial data length that each multifrequency sound wave sends is 14, wherein front 8 for needing transmission data, 2 verification beginning flags that are predefined, 4 is check value, the verification beginning flag in this example is " 0F "; As shown in table 3 is the partial data simple examples table of a dual-tone multifrequency.
The partial data simple examples table of a dual-tone multifrequency of table 3
(2) to the partial data obtaining in step (1), by the coding rule of the dual-tone multifrequency information coding unit table of comparisons 1, be transformed in corresponding dual-tone multifrequency superposed signal, according to sending duration, form continuous dual-tone multifrequency superposed signal information, this corresponding frequency of sound wave scope is within the scope of 16KHz~22KHz;
(3) by dual-tone multifrequency sound wave transmitting element, control loudspeaker and send continuously acoustic signals according to dual-tone multifrequency superposed signal information, and constantly circulation, until be transmitted or arrive time-out time;
(4) acoustic signals sending by microphone short distance reception loudspeaker, until the audio-frequency information receiving reaches length requirement, preserves the complete audio-frequency information receiving, and the initial value of setting period i is 0;
(5) by dual-tone multifrequency information decoding unit, the complete audio-frequency information of preserving is calculated to parsing, contrast the coding rule identical with step (2), complete audio-frequency information is divided into the time slice of respective number by sending duration length, according to amplitude size sequence, choosing two frequencies in each time slice and resolving the dual-tone multifrequency superposed signal consisting of it is respective value, forms one group of partial data; By data verification units, this partial data is carried out to verification, judge that whether verification is successful, if the determination result is YES, completes the transfer of data of dual-tone multifrequency sound wave;
(6) if the determination result is NO in step (5), judge whether period i=n sets up, if the determination result is YES, and the data transmission fails of multifrequency sound wave, wherein, n is greater than 1 natural number;
(7), if the determination result is NO in step (6), preserve again i=i+1 after the original position of the complete audio-frequency information receiving in step (4) being offset to a shift time length backward; Return to step (5), described shift time length is the 1/n of sending duration length.
The coding rule adopting in this example is pcm audio coding, in step (2) by the encoded conversion of partial data of pcm audio, in step (4), by pcm audio, encode and preserve the audio-frequency information receiving, simultaneously in conjunction with multiple compaction algorithms method, to reduce data volume and transmission quantity.
Acoustic signals sends with sine waveform in described step (3), and the sine wave that generates dual-tone multifrequency stack depends on parameter: two sine wave freuqencies, sample frequency, bit depth, and as 16100HZ+18100HZ, 44.1K sample frequency, 16 bit depth.Use sin function can generate sine wave output voice data, sin function calculates the sine value of a radian.The stepping radian value computing formula of each sampled point is: (2* π)/(sample frequency/sine wave freuqency).In two frequencies, maximum intensity value and the minimal intensity value of 16 bit depth voice datas of each frequency are respectively 16383 and-16384.Calculate the stepping radian sine value of the sampled point of each frequency in two frequencies and the product of intensity level, two product values are added, will be filled in the data field of PCM form with value, just completed the modulation of the audio volume control of stack.This example adopts said method to generate the Wave data of dual-tone multifrequency stack.
Signal drop causes producing the noise that people's ear can be heard when avoiding converting between frequency, the touch-tone signal of each transmission is in the cycle, intermediate intensity value is the highest, the intensity value of left end is increased to the highest successively by zero, the intensity value of right-hand member successively by the highest be reduced to minimum, realize smooth transformation, avoid producing noise.
Transmitting terminal sends acoustic signals continuously by dual-tone multifrequency superposed signal information, and loop play, until be transmitted or overtime.
The dual-tone multifrequency superposed signal information that receiving terminal obtains recording detects, and calculates the double-tone frequency of the audio signal in each duration section, and contrast coding rule is determined corresponding numerical value.According to nyquist sampling theorem, " if signal is band limit, and sample frequency is higher than one times of signal bandwidth, and so, continuous signal originally can be rebuild out completely from sample." the recording sample frequency that adopts of this example is 44.1K or higher frequency, and the ultrasonic signal of 16K-22K HZ can be rebuild out completely from sample.
To the frequency spectrum analysis of signal, can judge frequency information, in this example, receiving terminal adopts for the Frequency and Amplitude value of audio signal and calculates not only effectively but also Goertzel algorithm fast the analysis of signal spectrum.
In this example, during decoded data, take the single frequency duration is that the audio-frequency information of every 40 milliseconds is 1 frame, and during 14 partial datas transmission, once complete recording is totally 600 milliseconds, represents that the information of 14 frame partial datas adds that 1 vertical shift retains information; Every 1 frame information to 14 frame informations calculate to be resolved, and in coding rule, 8 frequencies range value in this frame, for avoiding a frame to cause erroneous judgement across two signal periods, while calculating range value, only participates in the audio-frequency information of first 20 milliseconds of every frame in computing; The front 3 large frequencies of range value after sequence, are designated as frequency 1, frequency 2, the frequency 3 of this frame.
After the Frequency and Amplitude value of 14 frames has been calculated, by the frequency of each frame 1, numerical value corresponding to frequency 2 combination, form 14 complete data and carry out verification.If verification failure, order is replaced frequency 1, numerical value corresponding to frequency 2 combination with frequency 1, frequency 3 combinations and frequency 2, the numerical value corresponding to frequency 3 combinations of each frame successively again, forms 14 complete data and carries out verification.
If the start bit of complete audio-frequency information is improper, one frame may be across two signal periods, to cause the erroneous judgement of Frequency and Amplitude value, if so still verification failure, the original position of complete audio-frequency information is offset to 10 milliseconds backward, re-execute this step, repeat altogether 4 times, until verification succeeds or skew number of times all execute.Alternative combination of frequency participates in computing, can effectively improve Data Analysis success rate, eliminates the impact of environmental noise, sensitivity of microphone.For avoiding erroneous judgement and reducing operand, for the calculation step of 4 different start bits, can gather respectively peak frequency range value summation, the data of the step that a verification summation is first 2, ignore after summation the data of the step of 2.
For 14 partial datas of each group, the method for calibration of every group of data is as follows: circulation searching verification beginning flag, the position rearrangement reaction data that occur by verification beginning flag, move to data forefront by verification beginning flag data backward.At this moment, first 4 is check value, the 5th to the 12nd 8 bit data for needing to transmit, and whether the check value that calculates 8 bit data equals front 4 bit check values; If equate, show that this 8 bit data is the data that correct need transmit, transfer of data is successfully completed; If unequal, continue other check values of respectively organizing data of cycle calculations and whether equate.By the verification of 4 bit check values, guaranteed the accuracy of data.
The above is only the preferred embodiment of the present invention; be noted that for those skilled in the art; under the premise without departing from the principles of the invention, can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.