Background technology
Existing infrared remote-controlled signal has all adopted certain signal encoding mode, adopts binary form as infrared signal commonly used, and difference only is the different of the length of signal time and figure place.Signal encoding mode commonly used has:
1. pulse code
According to the mode of pulse duration different coding, what company of Sony (SONY) adopted is exactly this coded system.
2. space coding
According to the mode that interpulse period, the length difference was encoded, what company of Panasonic (Panasonic) adopted is exactly this coded system, also often is called as the REC-80 mode.
3. transform coding
According to the change mode of encoding of pulse and blanking time order, Philips (Philips) company makes in this way, is also referred to as the RC-5 mode.
By last finding, the infrared coding mode that different companies provides all is not quite similar, and the principle of coding is of all kinds, does not have unified format.
In the application of some infrared control, as universal remote control, multimedia equipment centralized control, system integration engineering etc., usually need by the self-control infrared launcher multiple devices to be carried out remote control, this just need reappear the remote signal of equipment, and usual way has two kinds:
1. directly adopt the coded system of former form
Adopt this coded system, all will write special-purpose collection identification software and output drive software to each form, workload is big, and is difficult to all forms of limit, adds new form and constantly produces, and makes it to adopt the equipment interoperability of this method very poor.
2. get off the pulse of infrared remote-controlled signal and blanking time, restore in order when needing remote control equipment with the precision sample record of agreement.
Shortcoming: the control signal data amount is big, occupy very big memory headroom, and relevant hardware cost improves greatly, and data do not reflect the feature of infrared signal and the correlation between the different key.
The coded system that the present invention creates is applicable to the infrared remote-controlled signal of various forms, can be reduced to minimum to the signal data piezometric, memory space is significantly reduced, and can intuitively reflect the characteristic of infrared signal, conveniently is transplanted in the other system.
Summary of the invention
The object of the present invention is to provide a kind of new infrared coding recording method, this mode can adapt to emerging coded system when containing the coded system that in the past occurred, the infrared control signal of different forms is expressed with unified coded system.
The objective of the invention is to be achieved through the following technical solutions, a kind of coding method that is applicable to various form infrared control signal may further comprise the steps:
1). defined feature sign indicating number, definition PPM, RC-5, arteries and veins position coding, pulse code and self-defined five kinds of infrared remote-controlled signal types;
2). image data, with the data bit and the gap digit of single-chip microcomputer acquisition and recording infrared remote control data, between sampling period, adjust the signal sampling frequency automatically, under distortionless prerequisite, the data of gathering are compressed;
3). the specified data type, whether single-chip microcomputer belongs to PPM, RC-5, arteries and veins position coding or pulse code data type according to the data content judgment data after compressing, if all features of the data fit of gathering type, just can determine that this organizes the type of infrared data; If do not meet the feature of all common types, just belong to customization type;
4). improve the condition code data, the type of data is put into first byte of condition code, the every data of all the other in the calculated characteristics sign indicating number;
5). conclude numeric data code, numeric data code does not adopt fixing system, when specified data yardage value, judges that earlier the kind of signal pulse is that pulsewidth is counted N, the N=2 binary system; The quaternary is used in 3≤N≤4; Octal system is used in 5≤N≤16, so analogizes; According to the signal pulsewidth of each type, analyze the numeric data code numerical value that draws this section sampled data again; After the data analysis of whole group was intact, the data that obtain were exactly the numeric data code of this group infrared control signal.
We adopt unified coded system to note the infrared remote-controlled signal coding, and the advantage of doing like this is:
1, has versatility.Infrared remote-controlled signal is resolved into condition code to this programme and two parts of data value are described, and adopts such coded system coded system commonly used before can be compatible, again can the emerging coding method of self adaptation, and make various coding obtain integrating.
2, the infrared signal coded system is adjusted automatically, adopts the binary coding mode as most signal data, also has the quaternary or other.If write down infrared control signal with fixed sampling frequency, guarantee the sampling precision of little pulse width signal again, data volume can be very big.Our coded system is provided with " sampling time coefficient " this parameter, just data volume has been compressed in this step of signal sampling.In the step that feature is concluded, system is unfixing in advance, but confirms according to the concrete condition of data.These two steps guarantee can realize the compression of data with the maximal pressure shrinkage under the distortionless prerequisite of data.Data are after overcompression, and data volume is little.
3, preferentially discern modal infrared coding type, increase work efficiency.For common PPM type coding and RC-5 type coding etc., we will preferentially discern, and keep its coding characteristic, and the efficient of coding is further improved.
Embodiment
The specific embodiment of the invention is described below with reference to the accompanying drawings.
Read the pulse of infrared remote-controlled signal and the width at interval by single-chip microcomputer, data are temporarily stored in the core buffer.The scheme of concluding according to condition code draws the condition code of this remote signal, calculates the concrete numerical value of function control code again.
(1) record of pulsewidth
Infrared encoded signal is made of a string high-low level, it during no signal high level, start bit is certainly for low. and each high-low level all has individual saltus step when changing, the time interval of noting between each saltus step just equals to know each pulse and width at interval. writing time, mode at interval was a lot, can use the cycle detection method, external interrupt method etc. between sampling period, introduce the notion of " sampling time coefficient ", automatically adjust the signal sampling frequency, promptly under distortionless prerequisite, the time data of gathering is compressed, reduce the memory headroom that data occupy, improve subsequent data simultaneously and analyze the spent time. suppose that we are placed on the sampling numerical value in each time interval in the data array.
(2) scheme of condition code conclusion
The conclusion of condition code at first is to judge preferentially whether infrared signal is four kinds of common type.Every kind of type of coding all has its notable attribute, if all features of the data fit of gathering type, we just can determine that this organizes the type of infrared data; If do not meet the feature of all common types, just it be classified as the 5th type---" customization type ".Such design helps increasing work efficiency, and intuitively reacts type of coding.
The concrete condition code scheme of formulating is as follows:
1.01 be PPM normal data area definition:
Address characteristic parameter byte number remarks
00h 01 1 type of codings
01h function control code figure place 1
02h function control code byte number 1
03h04h start bit low level 2
05h06h start bit high level 2
07h index pulse 1
The pulsewidth of 08h 01 data 0
The pulsewidth of 09h 11 data 1
0ah0bh interval 2
The registered function of 0ch several 1
0dh sampling time coefficient 1 is used for the time reduction
2.02 be RC-5 normal data area definition
00h 02 1
01h low level burst pulse 1
02h low level broad pulse 1
03h high level burst pulse 1
04h high level broad pulse 1
The registered function of 05h several 1
3.05 arteries and veins position coding is expression: the width of each yard position is identical, represents " 1 ", " 0 " with the width of high level lasting time.Condition code is defined as follows:
00h 05
01h low level burst pulse
02h low level broad pulse
03h high level burst pulse
04h high level broad pulse
05h 06h initial pulse low level
07h 08h initial pulse high level
09h function control code figure place
0ah function control code byte number
The registered function number of 0bh
0ch sampling time coefficient
4.06 pulse code: the time width that every bit code makes zero is identical, represents " 1 ", " 0 " with the time length that high level continues, and is defined as follows:
00h 06
01h function control code figure place
02h function control code byte number
03h start bit low level
04h start bit high level
05h return-to-zero-time width
06h 0
07h 1
08h at interval
The registered function number of 09h
0ah sampling time coefficient
5.07 be customization type, the byte number of condition code is different with the difference of control code.
00h 07
01h function control code figure place
02h function control code byte number
03h low-level data number of types (m)
04h high level data number of types (n)
The initial low level of 05h
The initial high level of 06h
07h low level 1
07h+m low level m
07h+m+1 high level 1
07h+m+n high level n
The registered function number of 07h+m+n+1
The 07h+m+n+2 sampling time
As above, we place the categorical data of condition code on the position of the 00h of condition code, and we can know the implication of each byte in the length of condition code of the type and the condition code according to the data of this byte.
Specific implementation such as Fig. 1, at first whether our judgment data is rc-5 type (the concrete judgment mode of rc-5 type such as Fig. 2). if not rc-5 type infrared coding mode, then judge whether to exist index pulse, the judgement of index pulse is with data (i+2), data (i+4), ... and data (i) compares, see and whether equate (promptly in certain error range). if equate, illustrate and have index pulse, there is index pulse just can further judge whether judgement concrete steps such as Fig. 3 for PPM type coding mode .PPM type coding mode. if do not have index pulse or be not the PPM categorical data, further whether the return-to-zero-time of judgment data equates, the judgement principle of the judgement of return-to-zero-time and index pulse is identical, just the data of judging become data (i+3), data (i+5), ... etc. data whether within the error range of data (i+1). return-to-zero-time equates, the characteristic value 00 byte assignment of these group infrared coding data is 06, i.e. the 6th type coded system. if return-to-zero-time is also unequal, judge then whether the arteries and veins bit width equates. the judgment mode whether the arteries and veins bit width equates promptly is to see whether data (i)+data (i+1) and data (i+2)+data (i+3) equate. equates, then is defined as 05 category feature data; Otherwise be classified as 07 type is the customization type data.
We can see the concrete steps that rc-5 type infrared coding is judged from Fig. 2.The feature of Rc-5 type infrared coding is that data bits equals 14, and infrared encoded signal does not have initial pulse.Each arteries and veins bit time of data be fix for 1.778ms, pulse or blanking time are at 1/4 to 3/4 arteries and veins bit time width.Thus, we know that also the compression ratio of data is 1: 2
4, the coefficient of promptly sampling is 4.Meet above-mentioned feature infrared coding we think the rc-5 type.
Fig. 3 is the conclusion mode of PPM type infrared coding.The feature of PPM type infrared coding is: gap digit width identical (promptly having index pulse); Data are binary data, and numerical value " 0 " and " 1 " are to distinguish with the width of pulse.So can be at first judge according to whether having gap digit whether coding is the PPM type; Whether the judgment data position is binary again, and the concrete width numerical value of pulse of calculated data " 0 " and data " 1 " representative; Also to analyze start bit information, gap digit information, repetitive mode etc. in addition.
(2) customization type condition code, numeric data code generating algorithm
Here introduce the generalization procedure of " customization type ".The original formation of condition code is concluded according to " type 5 " (i.e. " customization type ").But in order to raise the efficiency, make condition code more directly perceived, we consider that the judgement of infrared coding mode commonly used is preferential when design, so the characteristic value of four kinds of common coded systems is optimized again, be classified as certain particular type, for the infrared remote coding that does not belong to four kinds of common type features, we are classified as it " customization type ".
Table 1 is the conclusion mode of self-defined infrared coding.
Array of data data
0?1?2?3?4?5?6?7?8?9?10?11?12?13?14?15?16?17?…
12 |
14 |
12 |
15 |
24 |
32 |
20 |
42 |
36 |
42 |
20 |
48 |
25 |
15 |
12 |
32 |
36 |
36 |
… |
|
a
0 | 0 | 0 | 0 | 1 | 1 | 2 | 2 | 3 | 2 | 2 | 3 | 1 | 0 | 0 | 1 | 3 | 4 | … |
|
000 000 000 000 001 0
01 010 010011 010 01
0 011 001 000 000 001
011 100Seven bytes of 00 02 52 69 32 01 70----function code numerical value, totally 54
Array of data data--represents pulse and the width at interval that we write down.
The temporarily providing room that array a---section and array of data are isometric is used for calculating the concrete numerical value of pulse.
Judge the odd bits (being low-level data) of array earlier:
Array a length and sampled data equal in length, which type every this level of record belongs to. and every of array a is initialized as sky, for start bit, judgement has, can first assignment a (0)~a (3) be that ffh. is afterwards with a (i) assignment j (j>=0), data (I) and data (I+2) with array of data, data (I+4), data (I+6), data compare, if data are in error range, be j then in the relevant position of the array a record content identical with the I position, after array of data has scanned one time, start anew again, first data are empty odd positions in the searching a array, with its content assignment is j+1, take out the data of array of data relevant position again. in array of data, seek the data value that equates with it, and, continue search and judge a (i) the assignment j+1 identical with that data correspondence position, up to searching the full number group. cycle detection, it is empty not having data in array a.
Can judge even bit (being high level data) equally.
Note low-level pulse width number and high level pulsewidth number.Because customization type will contain all unknown forms, can't represent the various different shapes of signal with binary 2 states.The present invention adopts original creation " system floats ", and promptly numeric data code does not adopt fixing system.When specified data yardage value, judge that earlier the pulsewidth of signal is counted N, the N=2 binary system; The quaternary is used in 3≤N≤4; Octal system is used in 5≤N≤16, so analogizes.The signal encoding data volume is minimized.According to number the data among the array a are converted to N system data, according to concrete numeric shift, put into hexadecimal byte again, obtain the concrete numerical value of the performance data sign indicating number of this guidance command like this.
(3) about the judgement of repetition pulse:
For repetition pulse, when data acquisition, if the pulse duration of record surpasses after a certain particular value, we think that this time represent an interval, and set of pulses emission announcement is with paragraph.Next the pulse of back, decidable interval is repetition pulse or another group of concrete data value.If the repetition flag pulse is then noted.If data, then judgment data with the last period data whether identical, data difference, record data then, and make sign; Identical, then think repetition, mark repeats.The definition of condition code 00 byte in concrete sign mode such as the ppm coded system:
01: the expression one piece of data, there is blanking time, in statu quo retransmit after blanking time.
11: the pulse of table repetition flag is arranged after the expression one piece of data
21: all there is start bit at the expression two ends, and the two groups of data in front and back are inequality;
41: the two groups of data differences in front and back, and divide the difference that has or not start bit;
(4) other attentions
Relatively the time, key is whether the pulse duration of expression data bit is consistent in the condition code of difference in functionality key, can be only compares according to first section data value.During the infrared signal reduction, take out condition code according to the type of first byte definition, according to sampling coefficient recovery time length, the data value correspondence according to control code goes out corresponding level signal at last again.
The foregoing description is used for the present invention that explains, rather than limits the invention, and in the protection range of spirit of the present invention and claim, any modification and change to the present invention makes all fall into protection scope of the present invention.