Recently, in order to develop wireless data transmission projects, I read a lot of wireless data transmission and receiving materials. Among them, the wireless remote control module 315 is relatively cheap and widely used. below is the single-chip computer simulation 2272 software decoding;
In the wireless remote control field, PT2262/2272 is one of the most commonly used chips. However, due to the chip requirements for pairing, the use of the chip is greatly affected, based on the characteristics of the PT2262 waveform and the actual application, the author puts forward the software decoding methods and specific measures.
I. Overview
PT2262/2272 is a low-power and low-price general codec circuit manufactured by CMOS technology. It is one of the most commonly used chips for address encoding recognition in wireless communication circuits. PT2262/2272 can have a maximum of 12 (A0-A11) three-state address end pin (suspended, connected to high level, connected to low level), any combination can provide 531441 address code, PT2262 can have a maximum of 6 (D0-D5) data end pins, set the address code and data code serial output from the 17 feet.
PT2262/2272 must be paired with the same address code. When a communication machine needs to be added, the user has to turn to the technical staff or the manufacturer to set the same address code, which is relatively difficult for the customer to set, especially for those who do not understand electronics. As people have higher and higher requirements for operations, the use of PT2262/2272 pairs seriously restricts the convenience of use. People Constantly require the use of a kind of special tool that does not need to consult professionals, anyone can use convenient means to make up for the defects of PT2262/2272. This is PT2262 software decoding.
Ii. decoding principles
The above is a waveform of PT2262, you can see a group of character codes, each group of character codes are separated by Synchronous Code, so if we use single chip microcomputer software decoding,ProgramYou only need to determine the synchronization code, and then identify the pulse width of the subsequent code.
2262 at least four character sets of codes should be launched at each launch, 2272 only when the same address code and data code are detected two times in a row, the "1" in the data code will drive the corresponding data output end to the High Level and the drive VT end will be synchronized to the high level. Due to the characteristics of wireless transmission, the first group of code is very vulnerable to zero-level interference, and often produces codes, so the program can discard the processing.
Let's take a closer look at the waveform features of PT2262:
Oscillation frequency f = 2*1000*16/rosc (kΩ) kHz where ROSC is the oscillating resistance. Here we choose a common frequency f ≈ 10 kHz, ROSC = 3.3m Ω (same as below ). It is the correspondence between the oscillating frequency and the bitwise waveform: Synchronous terminal waveform:
PT2262 has three types of codes: 0, 1, and F ). 1. The data "0" sends the following code bits: 2. The data "1" sends the following code bits: 3. The data "F" sends the following code bits:
With the above specific waveforms, we can perform software decoding. T2262 sends the code at least four times each time. First, we can check the synchronization terminal with a width of 11 ms to start encoding and decoding only when there is a dock. If there is no dock, we will continue to wait. When receiving the terminal, check whether the terminal has been received. If not, discard the first encoded signal to prevent the error code.
From the code diagram, we can see that each codeword starts from low to high, to low, and then to high. For the convenience of detection, at the receiving end, we perform a 180 ° inverted phase for the encoded signal to convert the rising edge at the beginning of the bitwise to the falling edge, in this way, when MCS51 series single-chip microcomputer is used for decoding, the encoding can be intercepted in a timely manner by means of interruption. From the code diagram, we can also see that each codeword can be divided into two segments. We describe the bitwise Based on the Level Width in each segment:
The second part of the code bit indicates that the reverse code is 0, narrow, 00, 11, 1, width, 11, 00, F, narrow, 01, 10, invalid code, width, and 10, 01
Software Decoding Method 1 (Anti-code): the detection level starts from the first descent edge to about us. The detection level is marked as A1, and the second descent edge is detected. The latency is about us. The detection level is high and low, as A2, so that a bitwise can be translated and 12 bitwise can be detected continuously.
Software Decoding Method 2 (Anti-code): starts from the first descent edge, and constantly detects level changes. Once a level change occurs, the Level Width B1 is recorded immediately, continue recording the time until the second descent edge appears, record the interval B2 between the two descent edges, repeat the above steps, get B3, B4, and Judge B1, B2, B3, if B4 is within the permitted error range, it stores B1, B3 and translates a bitcode. Otherwise, it considers the error code as discarded. 12 consecutive digits are correctly detected.
The two decoding methods have their own advantages and disadvantages: Decoding Method advantages disadvantages 1 simple program, low CPU overhead decoding accuracy difference 2 complicated program, high CPU overhead decoding accuracy higher
To obtain high decoding accuracy, we recommend method 2 to avoid misunderstanding codes of a large number of interference signals.
Iii. Refer to decoding software
(Add1, Add2 is an 8-bit address, and dat0 is a 4-Bit Data Remote: CLR tr2; probe signal detection subroutine CLR receive; MoV dete_loop, #12; receives 12-bit code remo0: CLR dete_t_over; MoV 2nd, # 0feh; test 1st-bit Level Width mov tl2, #041 h; SETB tr2; remo1: jb rem, remo2; wait for High-Level JB dete_t_over, remo3; when the time limit is us, the error code ajmp remo1; remo2: mov A, 22. tested Low-Level Width. 0ff is a wide pulse, 0fe is a narrow pulse cjne A, # 0ffh, remo4; moV A, tl2; clr c; cjne A, #098 H, $ + 3; JNC remo3; over-width (over 1150us), exit clr c; cjne A, #020 H, $ + 3; JC remo3; The level is too narrow (less than 780us), exit setb c; ajmp remo5; remo3: ajmp remote_end; remo4: cjne A, # 0feh, remo3; MoV, tl2; clr c; cjne A, # 0c7h, $ + 3; JNC remo3; The level is too wide (beyond 450us), exit clr c; cjne A, #060 H, $ + 3; JC remo3; narrow level (less than 210us), exit clr c; remo5: mov A, dat0; storage level value rlc a; MoV dat0, A; MoV A, Add1; rlc; moV Add1, A; remo6: jnb rem, remo7; waiting for low-level JB dete_t_over, remo3; Pulse descent along the interval of us, timeout is considered to be the error code ajmp remo6; remo7: CLR tr2; CLR dete_t_over; MoV A, Th1; cjne A, # 0ffh, rem13; pulse interval is too small mov A, tl2; clr c; cjne A, #050 H, $ + 3; JC rem13; The level is too narrow (less than 1200us), exit mov 2's, # 0feh; test the 2nd-bit Level Width mov tl2, #041 h; SETB tr2; rem11: jb rem, rem12; wait for the high-level JB dete_t_over, rem13; when the time limit is us, the error code ajmp rem11; rem12: mov A, 22. test the Low-Level Width. 0fe indicates the wide pulse, 0ff is a narrow pulse cjne A, # 0ffh, rem14; MoV A, tl2; clr c; cjne A, #098 H, $ + 3; JNC rem13; exit clr c; cjne A, #020 H, $ + 3; JC rem13; exit setb c; ajmp rem15 if the level is too narrow (less than 1000us; rem13: ajmp remote_end; rem14: cjne A, # 0feh, rem13; MoV A, tl2; clr c; cjne A, # 0c7h, $ + 3; JNC rem13; when the level is too wide (exceeds 450us), exit clr c; cjne A, #060 H, $ + 3; JC rem13; when the level is too narrow (less than 210us), exit clr c; rem15: moV A, temp; storage level value rlc a; MoV temp, A; MoV A, Add2; rlc a; MoV Add2, A; rem16: jnb rem, rem18; low-level JB dete_t_over, rem13; Pulse descent along the interval of us, timeout is considered to be the error code ajmp rem16; rem17: ajmp remo0 rem18: CLR tr2; CLR dete_t_over; MoV, 2nd cjne A, # 0ffh, rem13; pulse interval is too small mov A, tl2; clr c; cjne A, #050 H, $ + 3; JC rem13; when the level is too narrow (less than 1200us), exit djnz dete_loop, rem17; rem19: mov dete_loop, #4; shift the received encoding left to four rem20: clr c; put the eight-bit password on the same byte mov A, dat0; rlc a; MoV dat0, A; MoV A, Add1; rlc a; MoV Add1, A; clr c; MoV, temp; rlc a; MoV temp, A; MoV A, Add2; rlc a; MoV Add2, A; djnz dete_loop, rem20 ;; encode 4-bit data from 4-bit high to 4-bit low; MoV A, dat0; Swap A; MoV dat0, A; MoV A, temp; Swap A; MoV temp, a; ANL dat0, # 0fh; SETB receive; remote_end:; CLR tr2 CLR remoting; ret;
4. Hardware anti-interference
The use of Single-Chip Microcomputer in wireless communication will cause serious interference to the communication system. I believe many technical staff will have the same troubles. If the hardware is improperly designed, the communication distance between the original hardware decoding will be 200 meters, and the software decoding may be only 10 meters, therefore, solving the hardware anti-interference problem can greatly reduce the software decoding error rate.
1. transceiver module: the commonly used early frequency is 47 MHz, which makes it difficult to solve the problem. It is recommended that the current national frequency of wireless remote control is 315 MHz.
2. Single-Chip Microcomputer oscillation frequency: We recommend that you use 12 MHz and 11.0592mhz crystals in a large number of MCS51 textbooks. These crystals can be used normally but cannot be used here, they can still produce large interference at around MHz. To solve the contradiction between the single-chip microcomputer running speed and electromagnetic interference, it is recommended to use a crystal with a frequency of 4 MHz or 3.58mhz.
3. Isolation: In order to effectively suppress the electromagnetic interference of the single-chip microcomputer on the receiving module, it is recommended to use ① Power Supply isolation; ② port isolation; port isolation can use a transistor or comparator. Practice shows that the effect of isolation is very obvious.
V. Conclusion
Software Decoding of PT2262 is useful in practical applications. If software decoding is used, the manufacturer no longer needs to provide support for the receiving and receiving devices to facilitate production and storage. For customers, software decoding is not required for help, manufacturers only need to add the automatic learning function to the software. Users can use this function by themselves. They only need to press the learning key to learn new communication devices, such as remote control. Currently, this software decoding has been used in a wireless alarm device. The customer reports that it is easy to use and has good results.