Detailed explanation of electronic circuit design of smart socket
0 Preface
The standby energy consumption of computer peripherals (such as printers, scanners, stereos, etc.) not only increases consumers' daily electricity bills, but also wastes power resources. The designed computer intelligent energy-saving socket uses the power on and off of the host to drive other devices to turn on or off, so that the standby energy consumption of the interface device is zero, which can reduce the radiation generated by the computer and its peripherals, thereby achieving energy saving and environmental protection Efficacy; At the same time, it also has the function of segment timing switch. The smart socket can also be used as an ordinary socket through function conversion, without affecting the use of other devices.
1 The design of the smart socket
1.1 Hardware structure of smart socket
The hardware structure diagram of the computer intelligent energy-saving socket is shown in Figure 1. The controller is controlled by AVR mega 48. The peripheral circuit is mainly composed of current sampling circuit, analog/digital conversion reference voltage circuit, status display circuit, keyboard input circuit and real-time clock. The current sampling circuit is used to detect the computer's operating status and overcurrent protection; the digital/analog conversion reference voltage circuit provides a reference for current sampling; the status display circuit indicates the current operating status of the socket; keyboard input realizes the switch between ordinary sockets and smart sockets, Set the standby critical current value and set the time point of the segment switch. The operating status of the host computer is detected by the current transformer of the host interface, and the overcurrent protection is detected by another transformer. When the current is greater than the rated current for a certain period of time, the power supply of the controlled socket will be cut off to protect the peripherals. Due to the small induced current of the transformer, the reference voltage is required to be used in the digital/analog conversion process. This design uses a bandgap constant voltage source TL431 as the reference voltage for A/D conversion. The standby current of different computer hosts may be different, so the standby current can be sampled as a critical value through the external keyboard, and the socket can be set to be used as an ordinary socket; the RTC clock is composed of PCF8563.
1.2 AVR microcontroller
The AVR microprocessor is an 8-bit embedded RISC processor from Atmel. It has the advantages of high performance, high confidentiality, low power consumption, etc. The program memory and data memory can be accessed independently from the Harvard structure, and the code execution efficiency is high. The mega 48v processor used in the system contains 4 KB of on-chip programmable FLASH program memory; 512 B of E2PROM and 512B RAM; at the same time, a watchdog is also integrated on-chip; 8 channels of 10-bit ADC; 3 channels of programmable PWM output ; With online system programming function, rich on-chip resources, high integration, and easy to use. Using AVR mega48V can easily realize the setting of external input parameters, current detection, and indication of working status.
1.3 Current sampling circuit
This design uses a current-type current transformer to sample the AC current, one way is to sample the host interface current to achieve switch control, and the other way to sample the controlled interface current to achieve overcurrent protection (see Figure 2). The output signal of the current transformer is sampled by mega 48 after I-V conversion, and the effective value of the current can be calculated according to the transformation ratio coefficient of the transformer. After the output voltage of the I-V conversion passes through the comparator, if it reaches the overcurrent limit (set to 10 A), an external interrupt is triggered, and the interrupt program is processed to determine whether it reaches the overcurrent value and perform the overcurrent protection action.
1.4 Power circuit
The working voltage of the single-chip microcomputer and the coil side voltage of the relay are 5 V DC voltage. Considering the cost and space factors, it is produced by means of resistance-capacitance step-down. As shown in Figure 3.
In Figure 3: C3 is a CBB step-down capacitor; _R13 provides a discharge circuit for C3 after the power is disconnected; R4 is a current-limiting resistor; D11 clamps the voltage at 5.1V after full-wave rectification. The capacitive reactance XC of C3 in the circuit is: XC=(1/2)πfc, current, in order to meet the current requirements when the relay is pulled in, the value of C3 is 1μF, and the current can reach more than 100 mA. Because it is a non-isolated power supply, the zero potential cannot be connected to the earth during use.
1.5 Relay drive circuit
The on-off of the controlled socket is controlled by a relay. The design uses a relay with a coil side voltage of 5V, and uses S8050 to drive the relay. Mega 48 has a strong I/O drive capability, R17 plays a role in current limiting; pull-down resistor R18 can prevent the relay from malfunctioning; D12 provides a discharge loop when the relay is disconnected. As shown in Figure 4.
1.6 keyboard circuit
Using a single-button input mode, it is used to set the function conversion of ordinary sockets and smart sockets and the time setting when timing switches are required. During the running of the program, check whether a button is pressed through the timer interruption. When the function key is pressed for less than 10s, it enters the timer switch mode, and the time of the timer switch is set by the plus and minus buttons; when the function key is pressed for more than 10s, it switches to ordinary socket use. If you need to switch to smart socket, then Perform the same operation. The set parameters and modes are stored in the E2PROM of the mega 48.
1.7 Status display and alarm circuit
The design uses LCDl602 liquid crystal display system status information, including whether to use intelligent control, host operating status, and controlled port status. LCDl602 adopts 7-line driving method, connect 1 kΩ resistor to ground, used to adjust the contrast of liquid crystal display. Display data and instructions are written in through DB4 ~ DB7 of LCDl602. At the same time, it has an audible and visual alarm function. When there is an overcurrent or the timing cut-off time is up, the corresponding light-emitting diode flashes and the buzzer alarms, and the corresponding action is executed.
1.8 Real-time clock circuit
The real-time clock circuit provides the time for the timer switch. Use CR2025 Ni-MH button battery as the backup battery of PCF8563 (see Figure 5).
2 Software design of smart socket
The main program mainly completes the initialization of I/O and timer, reads out the system parameters stored in E2PROM, and enters the corresponding processing program according to the mode setting. The socket can run in 3 modes: smart timing mode, smart energy-saving mode and normal mode. The mode switch is selected by the mode button. The measurement of the parameter is mainly finished regularly by the interrupt service routine. Figure 6 is the main program flow chart.
Because the standby current of different computers is different, it is necessary to sample the standby current of the host before use. First put the host into the standby mode, and then enter the interrupt through the mode button to sample the current at this time and store it in the E2PROM.
3 Test of smart socket
Connect the designed socket as shown in Figure 7 and test it with a P4 dual-core computer and a 17-inch display. The standby power consumption of the display is 5W and the standby current is about 25mA. After entering the standby state, press the sampling button on the socket to sample the standby current of the computer and store it in the E2PROM. The test results show that when the computer enters the standby state, the socket can effectively cut off the power supply of the monitor.
4 Conclusion
The intelligent energy-saving socket designed in this article has the functions of intelligent energy-saving and time switch, and it can also be used as an ordinary socket. After testing, the system showed a good control effect, not only reducing the standby power of the computer peripherals to zero, but also protecting the peripherals. It has certain social benefits and extensive promotion value in terms of energy saving and emission reduction.
Please read the Chinese version for looking for the figures.