The segment switch is an energy-saving electronic product. When there are only two power lines, it can be used to control lamps with multiple bulbs, fluorescent lamps, and energy-saving lamps in groups, avoiding the pain of rewiring the lighting circuit. Common segment switches are controlled by a one-position switch, and different lighting states are generated by different switching times. This control method has two defects: first, the bulb is constantly switched on and off during the control process. Since the service life of the bulb, fluorescent lamp, and energy-saving lamp is closely related to the number of switches, this method can easily cause damage; second, it is more troublesome to use. If there are three groups of lamps in the lamp, it must be switched on and off four times to turn on all the lights. The following introduces a three-way segment switch designed with a single-chip microcomputer. A switch and three buttons are used on the control panel. After turning on the switch, different groups of lamps can be controlled by pressing different buttons. The three groups of lamps are independently controlled, which is intuitive and convenient to use.
1. Circuit Working Principle
The sectionalizer consists of a control panel and a receiving controller. The control panel is mounted on the switch box, and the receiving controller is mounted on the lamp. The control panel and the receiving controller are connected by two power lines. The control signal is transmitted through the power line in the form of power carrier. In order to prevent interference from the 50Hz AC power supply and facilitate separation, a 100kHz high-frequency pulse signal is used as the control signal. In order to simplify the circuit, the pulse counting method is used to distinguish different control signals.
1. Control panel circuit
The control panel mainly generates different control signals to control different lamp groups.
The circuit is shown in the figure below. The delay circuit is composed of the NAND gates A1 and A2 in IC1, resistors R1~R4, capacitors C1~C3, etc. The working principle is explained below by taking pressing S1 as an example: when S1 is not pressed, the input terminal of A1 is low level, so after two inversions, A2 also outputs low level; when S1 is pressed, since the voltage on C1 cannot change suddenly, the input terminal of A1 is high level, and A2 also outputs high level. After that, the voltage at both ends of C1 gradually rises after being charged by R4, and the potential at the input terminal of A1 gradually decreases. When the potential drops to VDD/2, that is, below 4.5V, the output of A2 changes from high level to low level. In this way, when the buttons S1NS3 are pressed respectively, the output terminal of A2 generates three different single positive pulse signals with pulse widths of 15mS, 23mS, and 34mS, which are used as control signals of the multivibrator respectively. NAND gates A1, A2, resistors R5, R6, capacitor C5, etc. form a multivibrator with an oscillation frequency of about 100kHz. When A2 outputs a high level, the multivibrator works and A4 outputs a 100kHz pulse signal. Since the number of its output pulse signals is controlled by the time of the high level output by A2, A4 can output different numbers of pulses by pressing different buttons in S1 to S3, and the corresponding numbers of pulses are about 1500, 2300, and 3400 respectively. Transistor VTl, high-frequency transformer T1, etc. form an output circuit, and the pulse signal output by A4 is amplified by VT1 and transmitted to the power line through C8. L1 is a high-frequency choke inductor, which can prevent the 100kHz pulse signal from being short-circuited by other electrical equipment and prevent it from generating interference signals to the outside.
C7, VD2, VD3, C6 and other components form a capacitor step-down power supply circuit, in which the 9V power supply stabilized by the voltage stabilizing diode VD1 is used by IC1.
2. Receiving controller circuit
The receiving controller circuit is shown in Figure 2. The circuit consists of a receiving circuit, a single-chip microcomputer circuit, and a power supply circuit.
R1 and C1 form the reset circuit of the microcontroller. After the power is turned on, the reset terminal 1 pin of the microcontroller AT89C2051 obtains a high-level reset pulse, which makes the microcontroller enter the initial state set by the program. Its pin P1.0 outputs a high level, P1~1 and P1.2 output a low level, the transistor VTl is turned on, VT2 and VT3 are turned off, so that the relay K1 is attracted, and K2 and K3 are in a released state. In this way, when the switch S4 on the control panel is turned on, the first group of lights is lit, and the other two groups of lights are off. When in use, the commonly used group of lights is generally connected to the control contact of K1.
C4, T1, \\/T1, etc. form the input signal processing circuit. C4 plays the role of isolating 50Hz AC signals. In order to improve the anti-interference ability, VT1 does not add DC bias voltage. The pulse signal with an amplitude of 5V output by its collector is input to the single-chip microcomputer through the P3.4 pin for processing. The single-chip microcomputer decides to change the working state of pins P1.0~P1.2 according to the number of input pulse signals. Specifically, about 1500 pulse signals correspond to P1.0, about 2300 pulse signals correspond to P1.1, and about 3400 pulse signals correspond to P1.2.
The following takes the second circuit as an example to illustrate the working process of the circuit. After the power is turned on, press the button S2, then the P1.1 terminal of the single-chip microcomputer is converted from low level to high level, the relay K2 is energized, and the corresponding normally open contact k2 is closed to turn on the corresponding light group. Press S2 again, and the P1.1 terminal of the single-chip microcomputer is converted from high level to low level, turning off the corresponding light group. The working process of the other two circuits is similar. When the working state of one circuit is controlled, the working states of the other two circuits are not affected, that is, each circuit can be controlled independently.
C5, VD4~VD8, IC2, etc. form a capacitor step-down power supply circuit to provide +12V and +5V power supplies. The function of L1 in the circuit is the same as that of L1 in the control panel circuit.
2. Program Introduction
The program is written in C language, and the timer TO is set as a counter, and the P3.4 pin is used as the input end of the counting pulse. Timer T0 counts the input pulse signal, and by judging the number of pulses, it can be known which switch is pressed on the control panel, thereby changing the working state of the corresponding relay. [page]
The program list is as follows:
#include
unsignedchari,DelayTime;unsignedintn:
sbitP1_O=p1^0;
sbitP1_1=P1^1;
sbitP1_2=P1^2;
sbitP3_4=P3^4;
voiddelay(DdayTime) //delay subroutine
{
for(;DelayTime>0;DelayTime——)
{
for(i=0;i<250;i++);
}
}
voiDMAin(void) //main program
{
P1_0=1;
P1_1=O;
P1_2=0;
TMOD=0x05;
//Timer TO works in mode 1 counting
TH0=0;
TL0=0:
TRO=1: //Turn on timer TO
for(;;)
{
while(P3_4=1);//Judge whether there is
Input pulse
TR0=1: //Start timer TO
delay(50);
//Delay 50mS, let timer TO count
TRO=O: //Turn off timer TO
n=TL0ㄧ(TH0<<8); //get the count value
TH0=0;
TLO=O:
if(n>1300&&n<1700)//If the pulse
The average number is about 1500
P10=!P10: //P1.0 input
Output level inversion
elseif(n>2000&&n<2600)//If
The number of pulses is about 2300
P1_1=!P1_1; //P1.1 input
Output level inversion
elseif(n>3000&&n<3800)//If
The number of pulses is about 3400
P1_2=!P1_2; //P1.2 input
Output level inversion
}
}
In the program, "while(P3_4==1):" detects whether the P3.4 pin is at a high level. When the control panel does not send out a pulse signal, the P3.4 pin is always at a high level, and the program is in a waiting state; once a pulse signal is sent out, the P3.4 pin will be at a low level. After the program detects it, it will execute downward, and the timer T0 counts the pulse signal input from the P3.4 pin. Since the longest duration of the control signal sent by the control panel is 34mS, 50mS is selected here for the timer TO to count to ensure that the pulse signal is not lost. After the counting is completed, the program screens the count value. Since the control panel uses an RC oscillator, its frequency stability is poor. In order to improve the reliability of the circuit operation, a certain error is allowed in the number of pulse signals during screening.
3. Installation and debugging
IC1 in the control panel uses CMOS NAND gate integrated circuit CD4011, and capacitors C1, C2, C3, and C5 use polyester capacitors with good stability to ensure the stability of the circuit. S1~S4 use touch button switches. The core of inductor L1 uses E16 ferrite core, which is wound with 100T enameled wire with a diameter of 0.41. The high-frequency transformer T1 uses E1
3's ferrite core, use φ0.19 enameled wire to wind 200T on the primary and 50T on the secondary.
In the receiving controller, IC1 uses ATMEL's AT89C2051 single-chip integrated circuit, IC2 uses a low-power three-terminal voltage regulator integrated circuit 78L05. X1 uses a 12MHz quartz crystal. VD1~VD7 use rectifier diodes 1N4004, VT1 uses transistors 2SC945, and VT2~VT4 use transistors 2SCl815. Relays K1~K3 use HRS1-S, 12VDC relays, and their contact loads are 3A120/220VAC.
The parameters of inductor L1 are the same as those of L1 in the control panel. High-frequency transformer T1 uses E13 ferrite core and uses φ0.19 enameled wire for primary and secondary windings with 1OOT.
Before installation, use a programmer to write the compiled target file switch.hex into the AT89C2051 chip.
The debugging work after installation is mainly to adjust the delay time of the control panel and the oscillation frequency of the multivibrator. During debugging, turn on the power switch S4 of the control panel, and then press the button switches S1, S2, and S3 in turn to see if the corresponding relays in the receiving controller have any action. If there is no response, if there is no problem with the circuit, it may be that the output frequency error of the control panel is large. The problem can be solved by properly adjusting the parameters of R6 or C5 in the circuit. If conditions permit, the output frequency of A4 can be measured with a frequency meter, and the input end of A1 and +9V can be connected with a wire for measurement. After that, if there is no response when a certain button switch is pressed, it means that the delay error of this channel is large, and the capacity of the corresponding delay capacitor can be changed. Finally, press the three buttons S1~S3 of the transmitter in turn. If the working status of the corresponding three-way relay can change, the debugging work is completed.
Previous article:Display board circuit diagram with 6-digit LED and 4 buttons
Next article:Design and implementation of three-dimensional rotating LED based on STC11F02E
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [NXP Rapid IoT Review] Finally received it, routine unboxing
- STM32F429 uses freemodbus to communicate with the computer and shows a write communication error
- Talking about RF5 architecture
- EEWORLD University ---- High-speed data converter signal processing: real and complex modulation
- Ultra-low power Bluetooth controlled, cost-effective, dimmable smart lighting solution
- How to use the serial port of Sinlinx A33 development board
- EEWORLD University Hall----Live Replay: New requirements for connectors in 5G multi-scenario terminal applications and Molex's 5G connection solutions
- MSP430F1232 Minimum System Test MCU AD10 Programming
- Top 10 Noise Issues in High-Resolution Delta-Sigma ADCs
- 【NXP Rapid IoT Review】+ 4. Simple temperature and humidity monitoring