Realization of PT2262 decoding principle by single chip microcomputer

Source: Internet
Author: User

1. Ask modulation :

"Amplitude shift keying" is also known as "amplitude keying", or "open key Control" (on-off keying), so it is also recorded as Ook signal. Ask is a relatively simple method of modulation. The amplitude shift keying (ASK) is equivalent to the amplitude modulation in the analog signal, except that the binary digital is multiplied by the carrier signal. Amplitude shift is the frequency, phase as a constant, and the amplitude as a variable, the information bit is transmitted by the amplitude of the carrier. Binary amplitude keying (2ASK), because the modulation signal only 0 or 12 levels, the result of multiplying is equivalent to the carrier frequency or shutdown, or connected, its practical significance is when the modulated digital signal is "1", the transmission of the carrier, when the modulated digital signal is "0", the carrier is not transmitted. The general carrier signal is the cosine signal, and the modulated signal is the conversion of the digital sequence into a unipolar baseband rectangular pulse sequence, and the function of this on-off keying is to multiply this output with the carrier, you can move the spectrum near the carrier frequency.

2. Several cycles :

2.1, Clock cycle: Also known as the oscillation period or the crystal period, defined as the reciprocal of the clock frequency, that is, the inverse of the oscillation frequency of the crystal oscillator, calculated as: T (Time) =1/f (OSC). The clock cycle is the most basic and smallest unit of time in a computer. In a clock cycle, the CPU only completes one of the most basic actions. For some kind of MCU, if the clock frequency of 1MHZ is used, the clock period is 1us.

2.2, the state cycle: the state period is twice times the oscillation period. The oscillation period is also called the crystal period, and the oscillation period is the basic time unit of the MCU. The oscillation pulse becomes the clock signal by two times, and the period of the clock signal is called the state period. If the oscillator frequency of the clock crystal is Fosc, then the state period of the clock signal is tosc= (1/fosc). (That is, twice times the inverse of the oscillation frequency). For example: The crystal oscillator frequency is 12MHZ, then the clock cycle tosc= (1/12us).

2.3, Machine cycle: The basic operating cycle of single-chip microcomputer. In the computer, in order to facilitate management, the implementation of an instruction is often divided into several stages, each phase of the completion of a work. For example, taking instructions, memory reads, Memory writes, and so on, each of these tasks is called a basic operation. A single-chip microcomputer completes a basic operation during an operating cycle.

2.4. Instruction cycle: The time required to execute an instruction is usually composed of several machine cycles. Different instructions, the number of machine cycles required is also different. For some simple single-byte instructions, in the take instruction period, the instruction is removed to the instruction register, immediately decoding execution, no longer require other machine cycle. For some more complex instructions, such as transfer instructions, multiplication instructions, two or more than two machine cycles are required.

In summary: a machine cycle = 6 status cycles = 12 clock cycles.

3, bit code :

The basic unit of the infrared encoded waveform is divided into AD (address code, data code) bit and sync (sync code) bit, each "bit" waveform is composed of two pulse cycles, each pulse period contains 16 clock cycles. The bit code uses two pulse signals to denote a coded value, wherein two successive narrow pulses denote the encoded value "0"; two continuous wide pulses denote the encoded value "1"; a narrow pulse and a wide pulse denote "F", which is the "dangling" of the address code. That is, each bit is represented by 2bit: 00 or 01 or 10 means 0 yards; 11 means 1 yards.

As shown in the figure below, the encoded signal emitted by the encoding chip PT2262 the pulse waveform after the shaping circuit. By: Address code, data code, synchronization code composition. Address codes and data codes are expressed in different widths of pulses, two narrow pulses denote "0", two wide pulses denote "1", a narrow pulse and a wide pulse denote "F", i.e. "dangling" of the address Code; The synchronization code is a long low-level interval, and the following image shows the PT2262 encoding diagram:

As shown above, each signal sent by the transmitter will carry a multi-uncorrupted set code loadline, each encoding loadline value is the same, the binary value is 0b010101010101010100001100, the corresponding hexadecimal code value is: 0x55550c. As can be seen from the graph, the period of the transmission code is equal, but the pulse width is different (the ratio of wide pulse to narrow pulse is 3:1). The low-level time of the synchronization code is about 8 times times that of this period.

Decoding the key is to identify the synchronization code, and then to the back of the loadline pulse width to identify, you can solve the code. PT2262 at least 4 sets of loadline are emitted per launch, each group of Loadline consists of 25 pulses, the first 24 pulses are address and data, the last pulse and a low level interval compose the synchronization code.

4, single-chip microcomputer decoding ideas :

Let's talk about how to decode it with 51 single chip microcomputer. Because the program structure is not complex, the program flowchart is no longer drawn.

Infrared through the integration of the receiver module is sent to the MCU external interrupt 0, the microcontroller set external interrupt drop edge trigger (that is, the external interrupt 0 is the jump Edge trigger mode, from high to low negative jump triggered into the interrupt processing function for decoding operation);

First we set the T0 to 16-bit timer mode, working in the timing state, the initialization value is 0, at the crystal oscillator operating frequency is 11.0592MHz when the maximum count value of the time is: 71111us. Because the synchronization code period and the address data period are much smaller than the timer 0 timing time, where the timer 0 is working normally, it will not overflow;

The T1 is used as a delay to set its timing to 1ms (the T1 function is not used in this example);

After Ex0=1 (external interrupt 0 start) and ea=1 (enable all interrupts), when the falling edge arrives into the interrupt handler function, the T0 starts and stops timing under TR0 control;

When the falling edge is received, the current level state is judged first, the time width when the T0 timer is zeroed and the low level is detected, and the stop count is changed when the level state changes. The sum of TH0 and TL0 can be based on the time-width value of the low level to identify whether it is a synchronization code. Only the synchronization code is recognized first, and the subsequent pulse data is received for 24-bit decoding operation.

Determine the level width, if the detection is a synchronous code, in fact, more than 10ms may be the synchronization code. Initially find the synchronization code, according to the synchronization code low-level width to obtain a wide pulse low-level width value, according to the synchronization code low-level width to obtain a narrow pulse low-level width value, from the above PT2262 encoded format diagram can be seen, the synchronization code low-level duration is 32 times times the duration of the wide pulse low time, is the narrow pulse low-level duration of 10 (or 11) times, the subsequent 24-bit data of the wide, narrow pulse low duration of the width of the comparison, to meet a certain range, you can parse out the transmitter-sent encoding.

Note: Because the production of the receiver module manufacturers, the standard is different, I have encountered some modules to receive the signal reverse, it is necessary to find the time-wide high level to identify the initial synchronization code.

The following is a sample Code Description section:

/************************************************************************************************************** ******************************************************************

* File name: decode.c (zqjun@hk 2014-05)

* Description: With an external interrupt io foot with timer 0 to achieve the 2262 series encoded signal soft decoding, PT2262 output signal by LM358 shaping amplified by the SCM P3.2 port input, as a single chip microcomputer external interrupt source.

* Code: A0--A11 each bit in 2bit means: 0 yards: 00; 1 yards: 11

* Hardware: PT2262 transmitter module, Lm358+r25. Receiving module, STC89C52RC MCU

* Crystal oscillator: 11.0592MHz

Description

1, the PT2262 output code includes 8-bit address code, 4-bit data code, 1-bit synchronization code, a total of 13 bits, order: A0 A1-A10 A11 + Sync code + A0 A1-A10 A11 + synchronization code, four times in a row.

2, four oscillation period is 1 coded timing units, recorded as T, in addition to the synchronization code, only 2 categories of the coding in the combination of pulses named long pulses and short pulses, wherein: The long pulse is composed of 3T high, 1T Low, short pulse is composed of 1T high, 3T low level.

3, the synchronization code, by the 1T high level 31T low level combination (the actual test synchronization code low-level width basically above 10ms).

4, only need to measure low or high-level length, you can know whether it is a long or short pulse, more than 12T time without pulse changes may be synchronous code.

************************************************************************************************************ **********************************************************************/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.