0 Introduction.
There is a kind of intelligent switch on the market, which can use a remote control to control the on and off of the appliances connected to the switch. Its working principle is to use a single chip microcomputer to simulate PT2272 for software decoding according to the traditional general protocol. However, the disadvantage is that the number of terminals controlled by the sending end is too small. One remote control can only control 4 terminals at most. In order to make up for the deficiency of the product in this aspect, this device is designed.
The design idea is to use a single-chip microcomputer to simulate the PT2262 chip encoding on the original remote control according to the PT2262/2272 transmission protocol, and then connect the system and the computer to communicate through the USB port, so that the receiving end can be directly controlled by the computer, which greatly increases the number of controls. It is more practical and more powerful.
1 Hardware Design
1.1 Overall system design
The system is mainly composed of a USB to serial port module, a single-chip microcomputer main control module and a wireless signal transmission module. The system block diagram is shown in Figure 1. The working process of the system is that the computer sends data to the single-chip microcomputer through the USB serial port, and the single-chip microcomputer returns the received data to verify whether the data is sent correctly. If the received data is incorrect and the original data is sent, it will be resent. If the reception is correct, the single-chip microcomputer encodes the received data and transmits it to the wireless transmission module, which transmits the signal. During the signal transmission process, an LED light is used to indicate whether the signal transmission is completed.
Figure 1 System
1.2 Design of each module
1.2.1 USB to serial port module design
The circuit of the module is shown in Figure 2. The module adopts a classic circuit design, and the conversion chip is PL2303HX. At the same time, in order to realize the productization of the device and reduce its size, the use of components is minimized while maintaining reliable performance. Figure 2 is the most simplified circuit design diagram.
Figure 2 USB to serial port module circuit.
1.2.2 Single chip control module design
Hardware design of the single-chip control module: Connect the RXD and TXD lines of the USB serial port module to the TXD and RXD lines of the single-chip microcomputer respectively to realize the information transmission and exchange between the single-chip microcomputer main control module and the computer. At the same time, select two ports at the P1 port, one connected to the LED indicator to indicate the working status, and the other as a data output port connected to the wireless transmitter module for information transmission between the single-chip microcomputer module and the wireless transmitter module.
1.2.3 Wireless Transmitter Module Design
This module is mainly responsible for transmitting the codes transmitted from the MCU main control module in sequence. The module circuit uses the common 315 wireless transceiver circuit diagram, as shown in Figure 3. It is a three-point oscillation circuit composed of a SAW resonator and a high-frequency transistor. The data is input by the MCU, and the high-frequency oscillator is controlled by transistor Q2 to realize the OOK modulation transmission of the data. [page]
2 Software Design
The software is designed according to the previous workflow and is divided into various modular designs. The main program modules include: serial port initialization, serial port communication between PC and MCU, MCU interpretation of data transmitted from PC and data encoding design, and wireless transmission of data.
Figure 3 Wireless transmitter module circuit
2.1 Determination of Coding Rules
The manual remote control uses the PT2262 chip. Although the PT2262/PT2272 coding rules can be found, the coding rules must be re-measured with an oscilloscope for the sake of caution. When a button on the remote control is pressed, the oscilloscope is used to measure the transmission waveform and draw a waveform diagram. Through comparison and calculation, the coding rules of the manual remote control are determined to be: synchronization code + eight-bit address code + four-bit data code. Each bit of the code has three states: high impedance, high level and low level. The waveform diagram of each state is shown in Figure 4. The synchronization code length is 128a, and the first 4a are narrow pulses.
Figure 4 PT2262 bit pulse waveform
2.2 Delay setting
The main delays in program design are as follows: a, 4a, 12a and 124a are accurately set. By measuring the corresponding minimum delay unit a in the manual remote control, which is 120μs, an accurate single-chip delay program is written. At the same time, when programming and setting the delay, comprehensive considerations should be made. It is worth noting that the instruction operation speed of the single-chip microcomputer chip used in this system is 6 times that of the traditional 51 series single-chip microcomputer. The setting of these 4 benchmark delays should minimize the deviation. In order to improve the accuracy, the time consumed in executing each instruction should be taken into account.
At the same time, the delay programming of 4a and 12a cannot be completed by simply repeating the delay of a several times, otherwise there will be a large error and it cannot be decoded correctly. The delay setting must be repeatedly calculated and measured to see if it is accurate. If it is not accurate, it should be modified.
2.3 Analog pulse coding
According to the PT2262/PT2272 protocol, and by measuring the transmission waveform of the manual remote control, it is known that the analog coding of the microcontroller should be divided into three parts, namely the synchronization code, the address code and the data code.
The address code and data code originally have three states, namely high level, low level and high impedance. The address code in the manual remote control has been fixed when welding the circuit, and the measured code is in high impedance state. The 4-bit data code is controlled by 4 buttons respectively, so there are only two states of high level and low level. Only one button can be pressed during remote control, so a manual remote control has only 4 different codes, so a manual remote control can only control 4 different terminals at most. However, when encoding in a single-chip microcomputer, it can be flexible and changeable without control. If 1 and 0 are used to represent the two states of high and low levels, then up to 212 different terminals can be controlled. If 00, 01, and 10 are used to represent these three states, then up to 312 different terminals can be controlled. In an ordinary working environment, only using 1 and 0 to encode can meet general design requirements.
When using a single-chip microcomputer to simulate pulse coding, the data stream sent by the USB to serial port module is converted by the corresponding algorithm to determine the state of each bit of the 8-bit address code and the 4-bit data code, and then different reference delays are called to simulate different state codes, thereby forming a simulated 12-bit waveform code. At the same time, a simulated synchronization code is added at the end. The synchronization code can be independently compiled into a program and directly called and inserted. In this way, the simulated PT2262 chip coding is completed through the software programming of the single-chip microcomputer.
[page]
2.4 Experimental ResultsThe system has been completed, and the finished product has been completed through PCB plate making and welding, as shown in Figure 5. Since the shell problem was not taken into consideration during PCB plate making, the PCB layout is not perfect enough, resulting in the position of the LED indicator light not being very appropriate.
Figure 5 Positive and negative effects of the system.
Since the starting point of the system design is to use a computer instead of a remote control, after the hardware of the system is completed, a control software that can be installed on any computer is written in LabVIEW language. The control interface of the software is shown in Figure 6. The number of ports that can be effectively controlled in the software is 212, that is, 4096, which far exceeds the number of control ports of ordinary remote controls and can basically meet the needs of various occasions.
Figure 6 System software control interface
3 Conclusion
This system has been completed and debugged successfully. A computer can control a simple set of electric lights through this device. The system is packaged in a traditional USB flash drive shell and has obtained a national utility model patent certificate. Patent number: ZL2010 2 0546946.5). The system has a simple structure, light volume, flexible control, and is controlled by a computer. The control software is a control program window written in LabVIEW. At the same time, the system can achieve remote intelligent remote control of the receiving terminal through wireless media or the Internet through functional expansion. It belongs to the application scope of the Internet of Things and has broad application prospects.
Previous article:How many methods are there to read data from each I/O port? How to read latch instructions?
Next article:Why do we need to set up an interrupt system? What are the entry addresses of each interrupt service routine?
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- [NXP Rapid IoT Review] NO1. First experience with NXP Rapid LoT development kit
- [TI recommended course] #TPS65086100: User programming of multi-rail power management IC#
- DAC analog multiplier, DDS (frequency synthesizer), signal generator
- For beginners of TI 6000 series DSP
- MSP430F6638 MCU interrupt, clock and low power consumption
- How to draw this circuit in dxp
- 【CH579M-R1】2. SYSTICK + GPIO + INT
- Microchip Live at 10:00 today: MCU programming is no longer difficult, use MPLAB Code Configurator (MCC) to achieve rapid development
- Application of TMS320DM642 in ATP Technology of Mobile Platform
- [ufun Learning] Unboxing Instructions: What are the preparations before formal learning?