Using single chip microcomputer to simulate 2262 software coding

Publisher:Wanderlust123Latest update time:2011-10-25 Source: 电子产品世界 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Overview

When using remote control encoding and decoding chips, the addresses of a pair of chips are required to be completely consistent. Therefore, when one remote control chip controls multiple decoding chips, multiple switches connected to the address end need to assist in action at the same time to change the address so that it is completely consistent with the address of the decoding chip to achieve the purpose of remote control.

If a microcontroller is used to replace the encoding chip, the function of changing the output waveform by multiple switch actions can be completed by software. At the same time, the microcontroller can be operated in power-down mode when idle, which not only makes operation simple but also saves energy.

Therefore, we designed a circuit which uses the cheap single-chip microcomputer AT89C2051 to replace the remote control coding chip PT2262 to realize the coding function, and simulated the remote control coding function with software.

2 Working Principle of PT2262

2.1 Pin Function

The functions of each pin of PT2262 are shown in Table 1.

2.2-bit pulse width

There are three ways to connect the address pin of PT2262, namely, floating (high impedance), high level and low level. The output waveforms of different connections are different, as shown in Figure 1. From the figure, we can see that if the oscillation period is a, the width of the narrow pulse is 4a and the interval is 12a; the width of the wide pulse is 12a and the interval is 4a, so the width of a complete bit pulse is 32a.

When in use, the oscillation resistance of PT2262 is about 4 times that of the paired decoding chip PT2272, that is, if the oscillation resistance of PT2272 is 470kΩ, the oscillation resistance of PT2262 can be 2MkΩ. Under this condition, after multiple experiments, it was found that the narrow pulse width emitted by PT2262 is about 250μs, the wide pulse is about 750μs, and the interval between two sets of data is about 6ms.

Figure 1 PT2262 bit pulse waveform

2.3 Encoding

PT2262 has a total of 12 address terminals. Each set of data transmitted consists of 12 bit pulses, in the order from A0, A1... to A11. Since each address terminal has 3 connection methods, there are 312 forms of waveforms output by the data terminal.

3 Software Design Methodology

Take the example of one PT2262 controlling eight lights through eight PT2272s.

3.1 Reset Processing

The problem that cannot be ignored when designing a program is that the program runs from unit 0000H after the first reset after connecting the battery and after the power-off reset when a key is pressed during normal operation. Therefore, different resets should be treated differently.

For the first reset, it can be assumed that all 8 lights are off, and the power-off reset should remember the on/off status of the 8 lights before power-off, so that the lights can be turned on and off accurately when the button is pressed again.

To achieve this goal, we have opened up a memory area in the CPU's RAM, namely 20H, 21H, and 22H, and stored the reset flag in these 3 bytes.

After the first reset, write 20H=55H, 21H=AAH, 22H=00H. The eight bits of 22H correspond to eight lights in order. When a light is turned on, the corresponding bit is sent to "1", and when it is turned off, it is sent to "0". The contents of 21H and 22H units must be checked for each reset. If 20H=55H, 21H=AAH, it means a power-off reset; if the above conditions are not met, it means the first reset. Since the RAM content is random during the first reset, the two-byte reset flag ensures the accuracy of the reset judgment.

3.2 Address encoding

Use 8 bits of 2EH and the upper 4 bits of 2FH to store the 12-bit address A0~A11 state, "1" represents high level, "0" represents low level. At this time, the maximum number of lights that can be controlled is 212. If the third state is required, just use two bits of a byte to represent it, such as "00", "01", and "10" to represent high, low level and high impedance state respectively. At this time, the maximum number of lights that can be controlled is 312.

We designed a circuit to control 8 lights. When using two states, the 9-bit code A3~A10 output by the microcontroller remains unchanged, so that the 9 address termination methods of the 8-chip decoder PT2272 of the 8 lights are completely consistent. A0~A2 determines the address code of the 8 lights, as shown in Table 2.

Each connection method corresponds to the corresponding decoder PT2272 of the receiving lamp. A11 also serves as the data D0 bit. When D0=1, the control lamp is turned on; otherwise, the control lamp is turned off.

3.3 Key-value reading

In order to save power, a 1 millisecond delay is set in the program. Within 1 millisecond, if a key is pressed, the key value will be processed. If no key is pressed, the power-saving state will be entered.

When processing key values, in order to prevent a key press from being processed repeatedly, you need to wait until the key press ends before processing.

There are two contents in key value processing. First, the switch flag bit of the light corresponding to the key is inverted. For example, if the flag byte is set to 23H, when the key AN0 is pressed, 23H.0 is inverted and the inverted result is sent to the storage bit of A11/D0. Then the code of the light corresponding to the key is sent to the storage bit of A0~A2 according to Table 2.

3.4 Analog pulse

The pulse sending program sends 12 consecutive "1", "0" or high-impedance data pulses according to the contents of 2EH and 2FH. The width of the pulse is achieved by delay. In the program, several delay subroutines can be compiled and called by the main program. It should be noted that the delay time must be repeatedly adjusted through multiple experiments.

4 Conclusion

This system has been put into use. It is not only simple in structure, low in price, easy to operate, accurate and flexible in control, but also has good energy-saving effect. It makes up for the limitations of the transmitter chip and makes it more intelligent and ideal. Based on this, the application of single-chip microcomputer in remote control system will be more extensive.

Reference address:Using single chip microcomputer to simulate 2262 software coding

Previous article:Design of Remote Measurement and Control Terminal Based on 80C196KB
Next article:Design of electronic password lock based on single chip microcomputer

Latest Industrial Control Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号