tags: Electronic hardware foundation
AC-220V zero point detection
The general system structure is as shown in the figure below.
Zero-crossing detection has three main functions:
(1) SCR trigger. By detecting the AC220V zero-crossing point, the conduction time of the thyristor can be adjusted to performVoltage controlWait.
(2) Relay protection. When using a relay to control the on and off of AC220v, if the relay is closed near the peak of AC220v, a large spark will be generated, which will affect the life of the relay and cause various electromagnetic interference. If it is closed at the zero-crossing point of AC220v, the impact will be reduced. .
(3) Timing. AC220v frequency is 50Hz, cycle is 20ms. After full-wave rectification, an interrupt is generated at each zero point, which can be timed in units of 10ms.
Design principle:
The principle diagram of zero-crossing detection is shown in the figure. AC220v is reduced to AC 9v through a transformer, and then full-wave rectified. The rectified signal can be directly used for zero-crossing detection. The filter capacitor c1 can be used for other purposes by connecting the follow-up circuit such as 7805. Diode D1 is used to isolate the rectifier and filter parts, maintain the waveform at Zero, and provide a signal source for zero-crossing detection.
Obtain the sampled signal at Zero, then divide the voltage with two 10K resistors, and then connect the triode to the voltage. The triode works in switching mode. When the base voltage Vbe≥0.7V, the triode is turned on and outputs a low level to PB4; on the contrary, the triode works in an off state and outputs a high level to PB4. The corresponding relationship between the sampling signal at Zero and the input signal of PB4 is shown in Figure 2-2. Use the rising edge of PB4 to generate a 10ms external interrupt, and each time an interrupt is generated, it is the zero point of AC220v.
This example uses 6 LEDs as a display. The LED display is refreshed every time a zero-crossing interrupt is generated. The LED refresh frequency is as follows:
LED0 50HZ flashes for 10ms, lights up, 10ms off, lights up and goes out in sync with the power zero point
LED1 25HZ flashes for 20ms, lights up, 20ms off, lights up and goes out synchronously with the power zero point
LED2 12.5HZ flashes for 40ms, lights up, 40ms off, lights up and goes out in sync with the power zero point
LED3 6.25HZ flashes for 80ms, lights up, 80ms off, lights up and goes out in sync with the power zero point
LED4 3.125HZ flashes for 160ms, lights up, 160ms off, lights up and goes out in sync with the power zero point
LED5 1.5625HZ flashes for 320ms, lights up, 320ms off, lights up and goes out in sync with the power zero point
Zero-crossing detection principle diagram
Time error between zero-crossing interrupt generation and actual AC220v zero point
As shown in the figure above, when the voltage drops to 0.7V, the PB4 port gets a rising edge and an interrupt is generated. There is a time difference between the interrupted ground and the true zero point. This time difference is related to the output voltage of the transformer and the resistance divider at the front end of the transistor. In this circuit, the theoretical calculation formula of the time difference between interrupt generation and zero point is:
0.7=4.5√2 *sin(w * t)
where 4.5√2 is obtained by dividing the voltage peak value 9√2 through two 10k resistors
w=2*3.14* f (f is 50Hz)
After calculation, t=350us.
Actually measured by the oscilloscope, the time difference between interrupt generation and zero point is about 500us.
There are many zero-crossing detection schemes for alternating current, and the most common scheme I used before is shown in Figure 1:
Figure 1 AC optocoupler zero-crossing detection circuit
The circuit of Figure 1 can detect the time when the alternating current passes through zero, but it has many drawbacks, which are listed as follows:
Based on the various problems listed above, the synchronization quality using the alternating current zero-crossing point is poor and needs to be improved. The first solution I thought of was to use the comparison function of the comparator to generate a standard square wave. The comparator outputs a high level during the positive half cycle of the alternating current, and the comparator outputs a low level during the negative half cycle of the alternating current. The time error of this scheme only depends on the response speed of the comparator level transition and the comparator's differential level resolution. Take lm319 as an example, the maximum bias voltage is 10mv, the comparative sensitivity is 5mv, and the response time of 5V output level transition is within 300ns, plus asin(10e-3/311)/2//pi/50 = 100ns. The difference between the two is about 400ns in total, which is much lower than the scheme shown in Figure 1. In practical applications, I used LM358 instead of the comparator. Its bias current is 50na, and a 1M resistor is connected in series. The voltage that satisfies the bias current is 50na×1M=50mv. According to st-lm358 data, its open-loop frequency response can reach 100db at 1k, so theoretically the input level of 1mv can still be recognized. Compared with the previous assumption, take 50mv, asin(50mv/311)/2/pi/50 = 500ns, the SR of the amplifier is 0.6V/us, assuming that the conversion to 4V requires 7us. Therefore, the absolute error of using LM358 is 7.5us, and in fact, due to the commonality of each device, the deviation in synchronization should be less than 1.5us.
After the plan is finalized, the circuit design should be carried out. Many problems were encountered during the actual circuit debugging, which is now recorded here for future reference. The main problems include:
Summary of experience:
——Transfer from 21IC Community
http://bbs.21ic.com/icview-1714198-1-1.html
Op amps as zero crossing detectors Sine voltage signals are usually converted into square waves using zero crossing detectors. In this circuit, the op amp operates in open-loop comparator mode. The po...
The two programs test the video and picture data respectively, and the algorithm parameters are the same (there is no corresponding parameter to filter lane lines in the video, but because the zebra c...
Single-phase phase-locking generally uses zero-crossing phase-locking The voltage is judged by the hardware circuit. The previous time is less than 0, and the latter time is greater than 0. It is judg...
The TCP zero window detection is used to obtain the window update message that triggers the opposite end to prevent the infinite loop caused by the loss of the window update message. It also helps the...
1. Introduction to the concept The short-term zero-crossing rate can be regarded as a simple measure of the signal frequency and is a rough estimate of the spectral characteristics. (1) Zero crossing ...
1. Demand analysis Using five basic waveforms to detect the short-term average zero-crossing rate algorithm. Generate a 5s waveform with a sampling frequency of 8000Hz: 1. Sine wave: Ampli...
The MATLAB implementation of short-term average zero-crossing rateAnother blogIt has already been introduced here. Here mainly introduces the short-term average zero-crossing rate of the s...
Introduction to Zero Crossing Zero-crossing analysis is a commonly used method to estimate the frequency of a speech signal. The speech signal is a wideband signal. For a continuous signal, the wavefo...
According to the error message, the algorithm should be changed to nonadaptive, so refer to the setting of the diode rectification routine in the blockset version Give up, 10,000 errors But after refe...