Phase zero-crossing point detection method, power switching method, switching circuit and system
By obtaining the AC current signal parameters when the timer is interrupted and using the PID algorithm to adjust the frequency matching, the problems of complex and costly hardware circuit design in the prior art are solved, and accurate detection of phase zero crossing and safe power switching are achieved.
Patent Information
- Application Number
- CN202210460334.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-04-28
AI Technical Summary
The existing phase zero crossing detection scheme has problems with high hardware circuit design requirements and high cost in off-grid home energy storage systems, and it is easy to cause arcing short circuit when the relay switches high-voltage AC power, affecting the safety of grid power supply and energy storage equipment.
By obtaining the electrical signal parameters of the alternating current when the timer is interrupted, the PID algorithm is used to adjust the interrupt frequency of the timer to match it with the alternating current frequency, thereby determining the phase zero crossing point, avoiding hardware circuit detection, and reducing circuit design difficulty and cost.
It improves the accuracy and safety of phase zero crossing detection, reduces the difficulty and cost of circuit design, and avoids the problem of equipment damage and phase mismatch during power switching.
Smart Images

Figure CN114910693B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of energy storage devices, and in particular to a phase zero-crossing detection method, a power switching method, a switching circuit, and a system. Background Art
[0002] In off-grid home energy storage systems, relays are needed to switch loads between the grid and the energy storage device to optimize power distribution. Because relays switch high-voltage AC power, arcing can easily occur during this switching process, damaging relay contacts and even causing arcing short circuits. Arcing short circuits can temporarily connect the energy storage device to the grid, impacting grid power supply. If the AC voltage phase difference between the energy storage device and the grid is too large, the energy storage device's inverter circuit can also be damaged.
[0003] To address this issue, it's necessary to detect the zero-crossing point of the AC grid voltage. This ensures that the voltage phase of the AC power flowing through the energy storage device is synchronized with that of the grid. Therefore, accurate detection of the zero-crossing point of the AC grid is crucial for grid-connected AC power output. However, existing zero-crossing detection solutions often rely on hardware circuits, which places high demands on hardware circuit design and increases hardware costs. Summary of the Invention
[0004] The main purpose of this application is to provide a phase zero-crossing detection method, a power switching method, a switching circuit and a system, aiming to reduce the circuit design difficulty and circuit cost for detecting the phase zero-crossing of alternating current, and improve the detection accuracy of the phase zero-crossing of alternating current.
[0005] In a first aspect, the present application provides a phase zero-crossing detection method, comprising:
[0006] When a timer interrupt is detected, a sampling value of an electrical signal parameter of the alternating current is obtained;
[0007] adjusting the interrupt frequency of the timer according to the sampled value and the standard zero-crossing reference value of the alternating current so that the interrupt frequency matches the frequency of the alternating current;
[0008] When it is detected that the timer is interrupted according to the interruption frequency, a phase zero crossing point of the alternating current is determined.
[0009] In a second aspect, the present application further provides a power switching method, including the phase zero-crossing detection method as described above, and the power switching method further includes:
[0010] In response to a switching instruction, obtaining a state of the timer;
[0011] When it is detected that the timer is interrupted according to the interrupt frequency, a switching control signal is output to the target device, wherein the switching control signal is used to instruct the target device to output AC power of a target phase.
[0012] In a third aspect, the present application further provides a switching circuit, the switching circuit comprising a timer and a signal sampler;
[0013] The signal sampler is used to collect electrical signal parameters of alternating current;
[0014] The switching circuit also includes a processor, a memory, and a data bus for realizing connection and communication between the processor and the memory, wherein the memory stores a computer program that can be executed by the processor, and when the computer program is executed by the processor, the steps of the phase zero-crossing point detection method or the power switching method as described above are implemented.
[0015] In a fourth aspect, the present application further provides a power distribution system, comprising:
[0016] The energy storage device and the switching circuit as described above, wherein the switching circuit is electrically connected to the first power supply and the energy storage device respectively, and is used to control the first power supply or the energy storage device to supply power to the load.
[0017] The present application provides a phase zero-crossing detection method, a power switching method, a switching circuit, and a system. When a timer interrupt is detected, the present application obtains a sampled value of an electrical signal parameter of an alternating current (AC); adjusts the timer interrupt frequency based on the sampled value and a standard zero-crossing reference value of the AC to match the interrupt frequency with the AC frequency; and determines the phase zero-crossing of the AC when the timer is detected to be interrupted according to the interrupt frequency. By adjusting the timer interrupt frequency to match the AC frequency, the phase zero-crossing of the AC can be determined when the timer is interrupted, eliminating the need for hardware circuitry for zero-crossing detection. This reduces the circuit design difficulty and cost for detecting the phase zero-crossing of the AC, and improves the accuracy of detecting the phase zero-crossing of the AC. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0019] Figure 1 A schematic flow chart of the steps of a phase zero-crossing detection method provided in one embodiment of the present application;
[0020] Figure 2This is a schematic flow chart of the steps of a phase zero-crossing detection method provided by another embodiment of the present application;
[0021] Figure 3 A schematic diagram of sampling an alternating current signal provided for implementing this embodiment;
[0022] Figure 4 A schematic diagram of sampling another alternating current signal provided for implementing this embodiment;
[0023] Figure 5 A schematic flow chart of the steps of the power switching method provided in an embodiment of the present application;
[0024] Figure 6 A schematic diagram of a scenario of the power switching method provided in an embodiment of the present application;
[0025] Figure 7 A schematic diagram of sampling another alternating current signal provided in an embodiment of the present application;
[0026] Figure 8 A schematic block diagram of the structure of a switching circuit provided in an embodiment of the present application;
[0027] Figure 9 A schematic block diagram of the structure of a power distribution system provided in an embodiment of the present application.
[0028] The realization of the objectives, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0030] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined, or partially merged, so the actual execution order may vary depending on the actual situation.
[0031] Embodiments of the present application provide a phase zero-crossing detection method, a power switching method, a switching circuit, and a system. The phase zero-crossing detection method can be applied to a switching circuit comprising a timer and a signal sampler, wherein the timer is configured to count time and the signal sampler is configured to collect electrical signal parameters of alternating current (AC), including parameters such as voltage, current, AC cycle, or AC frequency.
[0032] Exemplarily, the switching circuit can be applied to power distribution equipment such as a distribution box. The switching circuit can detect the phase zero crossing point of the AC power and is also used to control the load to switch power between a first power source and an energy storage device. The first power source may include, for example, an AC power source such as mains electricity, a photovoltaic power source, or a wind power source. The energy storage device may include, for example, a battery module, which may include one or more energy storage units, each of which may be, for example, one or more batteries.
[0033] The following describes some embodiments of the present application in detail with reference to the accompanying drawings. In the absence of conflict, the following embodiments and features therein may be combined with each other.
[0034] Please refer to Figure 1 , Figure 1 A schematic flow chart of the steps of a phase zero-crossing point detection method provided in one embodiment of the present application.
[0035] like Figure 1 As shown, the phase zero-crossing point detection method includes steps S101 to S103.
[0036] Step S101: When a timer interrupt is detected, a sample value of an alternating current electrical signal parameter is obtained.
[0037] In this step, the switching circuit is provided with a timer. The switching circuit controls the timer to count and, upon detecting a timer interrupt, obtains a sampled value of the AC power electrical signal parameter. In this step, the switching circuit is also provided with a signal sampler, and the sampled value of the AC power electrical signal parameter can be collected by the signal sampler, such as an AD sampler.
[0038] In this step, the electrical signal parameters of the AC power can be determined based on the power supply currently connected to the switching circuit. For example, the AC power can be output from an AC power source such as a mains supply, or it can be output from an energy storage device.
[0039] In this step, the timer interruption can be continuous, that is, after the timer interrupts when the count value reaches the interrupt count value, it continues to start the next round of timing counting. Each time the timer interruption is detected, the sampled value of the electrical signal parameter of the alternating current is obtained to obtain multiple sampled values.
[0040] Step S102 , adjusting the interrupt frequency of the timer using a PID algorithm according to the sampling value and the standard zero-crossing reference value of the AC power, so that the interrupt frequency matches the frequency of the AC power.
[0041] In this step, the timer interrupt frequency is adjusted based on the sampled value and the standard zero-crossing reference value of the AC power. This adjustment can be made once or multiple times so that the timer interrupt frequency matches the AC power frequency. When the timer is interrupted based on the interrupt frequency, the AC power phase crosses zero.
[0042] In this step, the sampling value of the electrical signal parameter of the alternating current refers to the sampling value of parameters such as the voltage value, current value, AC cycle or AC frequency of the alternating current output. The sampling value of the electrical signal parameter of the alternating current is, for example, 2300. The standard zero-crossing reference value of the alternating current refers to the reference value of the voltage phase zero point of the alternating current output. The standard zero-crossing reference value is, for example, 2048.
[0043] For example, a PID (Proportion Integral Differential) algorithm is used to determine the error between the sampled value and a standard zero-crossing reference value, and the timer interrupt frequency is dynamically adjusted based on the error value to match the timer interrupt frequency with the AC power frequency. The PID algorithm can be a position-based PID algorithm. In practical applications, the correlation coefficient of the PID algorithm can be set based on the desired accuracy and speed.
[0044] In this step, the switching circuit adjusts the interrupt frequency of the timer so that the difference between the interrupt frequency of the timer and the frequency of the alternating current is less than or equal to the preset frequency difference, and then determines that the interrupt frequency of the timer matches the frequency of the alternating current, so that it can be determined that the sampling value collected when the timer is interrupted is close to or equal to the standard zero-crossing reference value, that is, the timer determines the phase zero-crossing point of the alternating current when it is interrupted according to the interrupt frequency.
[0045] That is to say, in this step, the interrupt frequency of the timer matches the frequency of the AC power, including that the difference between the interrupt frequency of the timer and the frequency of the AC power is less than or equal to the preset frequency difference. The frequency of the AC power can be determined according to the frequency of the AC power connected to the switching circuit. For example, if the power grid system is connected, the frequency of the AC power is 50 Hz, or the frequency of the AC power can also be 60 Hz. The preset frequency difference can be determined according to actual conditions, and this embodiment does not specifically limit this.
[0046] In this step, the initial interrupt frequency of the timer is related to the frequency of the AC power connected to the grid. For example, if the AC power frequency connected to the grid is 50 Hz, the initial interrupt frequency of the timer is also 50 Hz. If the AC power frequency of the grid is 60 Hz, the initial interrupt frequency of the timer is also 60 Hz.
[0047] S103 : When it is detected that the timer is interrupted according to the interruption frequency, determine a phase zero-crossing point of the alternating current.
[0048] After the switching circuit determines that the timer interrupt frequency matches the AC power frequency, it then detects that the AC power phase has crossed zero when the timer is interrupted according to the interrupt frequency. It should be noted that if the interrupt frequency matches the AC power frequency, the AC power phase will have crossed zero when the timer is interrupted according to the matching interrupt frequency. By adjusting the timer interrupt frequency to detect the AC power zero phase, there is no need for hardware circuitry to perform zero-crossing detection.
[0049] The phase zero-crossing detection method provided in the above embodiment obtains a sampled value of an AC electrical signal parameter upon detecting a timer interrupt; and adjusts the timer interrupt frequency using a PID algorithm based on the sampled value and a standard zero-crossing reference value of the AC to match the interrupt frequency with the AC frequency, wherein the AC phase crosses zero when the timer is interrupted according to the interrupt frequency. By adjusting the timer interrupt frequency to match the AC frequency, the AC phase zero-crossing point can be determined upon the timer interrupt, eliminating the need for hardware circuitry for zero-crossing detection. This reduces the circuit design difficulty and cost for detecting the AC phase zero-crossing point, and improves the accuracy of AC phase zero-crossing detection.
[0050] In the following embodiments, the switching circuit is further described using a distribution box as an example. The distribution box is electrically connected to a first power source and an energy storage device, and is used to control the first power source or the energy storage device from supplying power to a load. The distribution box can be used to switch between primary and auxiliary power sources and monitor power usage. Internally, it can switch and sample the connected power sources, and therefore can include devices such as a timer, a signal sampler, and a relay.
[0051] Please refer to Figure 2 , Figure 2 A schematic flow chart of the steps of another phase zero-crossing point detection method provided in one embodiment of the present application.
[0052] like Figure 2 As shown, the phase zero-crossing point detection method includes steps S201 to S204.
[0053] Step S201: When a timer interrupt is detected, a sample value of an alternating current electrical signal parameter is obtained.
[0054] In one embodiment, in response to a zero phase detection instruction, a timer is initialized and the timer is controlled to start counting; wherein the zero phase detection instruction is used to instruct phase zero crossing detection of the alternating current; when a timer interrupt is detected, a sample value of an electrical signal parameter of the alternating current is obtained.
[0055] It should be noted that when the distribution box detects a zero-phase detection instruction, it controls the timer to reset its count value and start counting. The timer is interrupted when the count value reaches the interrupt count value. When the distribution box detects a timer interrupt, it obtains a sampled value of the AC electrical signal parameter through the signal sampler. Specifically, the AC electrical signal parameter includes parameters such as the AC voltage value, current value, AC cycle, or AC frequency. In this application, sampling the AC electrical signal parameter means sampling the AC voltage value.
[0056] In one embodiment, the zero-phase detection instruction is triggered by: powering on the distribution box, a user triggering the zero-phase detection instruction, or connecting the energy storage device to a load. The user triggering the zero-phase detection instruction includes the user issuing the zero-phase detection instruction to the distribution box via a control, touch screen, or button. For example, when a user triggers a button to switch the distribution box to the energy storage device to supply power to the load, the distribution box executes the operation of generating the zero-phase detection instruction based on the switching instruction.
[0057] For example, assume that the timer interrupt count value is 10,000. In response to the zero-phase detection instruction, the distribution box controls the timer to start counting from 0, and triggers a timer interrupt when the timer count value reaches 10,000. When the timer interrupt is detected, the signal sampler samples the AC signal of the AC power output to obtain a sampled value of the AC power electrical signal parameter.
[0058] Step S202: Update the interrupt count value of the timer using the PID algorithm according to the sampling value and the standard zero-crossing reference value.
[0059] When the timer count reaches the interrupt count, an interrupt operation is executed. It should be noted that the timer interrupt count can be dynamically updated using a PID algorithm, sampled values of the AC power signal parameters obtained during the timer interrupt, and a standard zero-crossing reference value for the AC power, so that the timer interrupt frequency matches the AC power frequency.
[0060] In one embodiment, an error value between a sampled value and a standard zero-crossing reference value of an alternating current is calculated; an offset parameter of a timer interrupt count value is determined based on the error value and a preset PID formula; and the interrupt count value is updated based on the offset parameter. It should be noted that the error value is the difference between the sampled value and the standard zero-crossing reference value. Using this error value and the preset PID formula, the offset parameter of the interrupt count value can be accurately determined, thereby dynamically updating the interrupt count value based on the offset parameter.
[0061] Among them, the offset parameter of the interrupt count value of the timer is determined according to the error value and the preset PID formula, including: obtaining a preset proportional coefficient, a preset integral coefficient and a preset differential coefficient; determining a first offset parameter of the interrupt count value according to the preset proportional coefficient and the error value; obtaining an error accumulation value according to multiple error values determined when the timer is interrupted multiple times, and determining a second offset parameter of the interrupt count value according to the preset integral coefficient and the error accumulation value; obtaining an error difference according to the current error value determined and the error value when the timer was last interrupted, and determining a third offset parameter of the interrupt count value according to the preset integral coefficient and the error difference; calculating the sum of the first offset parameter, the second offset parameter and the third offset parameter to obtain the offset parameter of the interrupt count value of the timer. It should be noted that the PID algorithm is a control algorithm that combines the three links of proportional, integral and differential in one, and can dynamically realize closed-loop adjustment of the interrupt count value according to the error value and the preset PID formula.
[0062] For example, the preset PID formula is Among them, u(k) represents the offset parameter, K P Indicates the preset proportional coefficient, K I Indicates the preset integral coefficient, K D Represents the preset differential coefficient, e(k) represents the error between the sampling value and the standard zero-crossing reference value, represents the accumulated error value, and e(k)-e(k-1) represents the error difference.
[0063] It should be noted that the preset proportional coefficient, the preset integral coefficient and the preset differential coefficient are control parameters of the PID algorithm and can be flexibly set according to actual conditions. For example, the preset proportional coefficient K is set to p =1, preset integral coefficient K I =0.01, preset differential coefficient K D = 0. In actual application, the above correlation coefficient can be modified according to actual needs. In some embodiments, after obtaining the offset parameter of the interrupt count value of the timer, the offset parameter can also be fine-tuned such as rounding to facilitate subsequent calculation processing.
[0064] For example, set the interrupt count value of a timer to 10000, the timer starts counting from 0, and triggers the timer interrupt when the count value reaches 10000. Figure 3 As shown, point 10 corresponds to the standard zero-crossing reference value of the AC power, which is 2048, and point 20 corresponds to the sampling value of the AC power signal parameter when the timer is interrupted. Figure 3It can be seen that the sampled value is greater than the standard zero-crossing reference value. For example, the sampled value is 2300. In this case, the error value is equal to 2048-2300=-252. Based on this error value and the preset PID formula, the preset proportional coefficient Kp in the preset PID formula is set to 1, the preset integral coefficient KI=0.01, and the preset differential coefficient KD=0. The output value can be obtained as 1*-252+0.01*-252+0=-254.52. The output value is rounded to an integer, and the offset value of the timer interrupt count value is obtained as -254. The interrupt count value of the timer is set to 10000+(-254)=9746.
[0065] Step S203: Adjust the interrupt frequency of the timer according to the interrupt count value so that the interrupt frequency matches the frequency of the AC power.
[0066] After updating the interrupt count value of the timer, the interrupt frequency of the timer needs to be adjusted according to the updated interrupt count value so that the interrupt frequency matches the frequency of the AC power. At this time, when the timer is interrupted according to the matching interrupt frequency, the phase of the AC power passes through zero.
[0067] It should be noted that the detection of AC zero phase through timer and PID algorithm is applicable to AC of various frequencies and voltage levels. It does not require zero-crossing point detection through hardware circuits, which can reduce the difficulty and cost of related circuit design and improve the detection accuracy of AC phase zero-crossing point.
[0068] In one embodiment, adjusting the interrupt frequency of the timer according to the interrupt count value includes: calculating the ratio between the interrupt count value before adjustment and the interrupt count value after adjustment to obtain an adjustment ratio; and adjusting the interrupt frequency of the timer according to the adjustment ratio.
[0069] Among them, the interrupt frequency corresponding to the interrupt count value before adjustment is obtained, and the product between the interrupt frequency and the adjustment ratio is calculated to obtain the interrupt frequency after adjustment, which can conveniently complete the adjustment of the interrupt frequency of the timer so that the interrupt frequency matches the frequency of the AC power.
[0070] In some embodiments, the adjustment ratio and the interrupt frequency before adjustment can also be input into a preset adjustment formula to adjust the interrupt frequency of the timer. The preset adjustment formula can be set according to actual conditions, for example, including parameters such as a preset adjustment coefficient. This embodiment does not make specific limitations on this.
[0071] For example, a timer interrupt frequency is set to 50 Hz and the interrupt count value is 10000. That is, the timer triggers an interrupt when the count value reaches 10000. If the offset value of the timer interrupt count value is -254, the timer interrupt count value is set to 10000 + (-254) = 9746, and the adjustment ratio is (10000 / 9746). At this time, the timer interrupt frequency is set to 50*(10000 / 9746) = 51.3 Hz.
[0072] In one embodiment, after adjusting the interrupt frequency of the timer, it is determined whether the interrupt frequency matches the frequency of the AC power. Specifically, it is determined whether the difference between the interrupt frequency of the timer and the frequency of the AC power is less than or equal to a preset frequency difference. If the difference between the interrupt frequency of the timer and the frequency of the AC power is greater than the preset frequency difference, it is determined that the adjusted interrupt frequency does not match the frequency of the AC power. If the difference between the interrupt frequency of the timer and the frequency of the AC power is less than or equal to the preset frequency difference, it is determined that the adjusted interrupt frequency matches the frequency of the AC power.
[0073] It should be noted that if the interrupt frequency is determined to match the frequency of the AC power, the phase of the AC power will cross zero when the timer is interrupted according to the matching interrupt frequency. In some embodiments, if the interrupt frequency is determined to not match the frequency of the AC power, the process returns to step S201 to continue adjusting the interrupt frequency of the timer until the interrupt frequency of the timer matches the frequency of the AC power.
[0074] For example, Figure 4 As shown, point 30 corresponds to the first sampled value of the AC signal when the timer is first interrupted. Assuming that the timer interrupt frequency is adjusted based on this first sampled value, the adjusted interrupt frequency is 50.4 Hz. The AC frequency is 50 Hz, and the preset frequency difference is, for example, 0.3 Hz. It can be seen that the difference (0.4 Hz) between the interrupt frequency corresponding to this first sampled value and the AC frequency is greater than the preset frequency difference. Therefore, the timer interrupt frequency needs to be further adjusted, i.e., returning to step S201 to control the timer to count from 0. Point 40 corresponds to the second sampled value of the AC signal when the timer is second interrupted. The timer interrupt frequency is adjusted based on this second sampled value, resulting in an adjusted interrupt frequency of 50.2 Hz. The difference between the interrupt frequency corresponding to this second sampled value and the AC frequency is less than the preset frequency difference. Therefore, the timer interrupt frequency matches the AC frequency. Point 50 corresponds to the sampled value of the AC signal parameter when the timer is third interrupted. When the timer is interrupted based on the interrupt frequency of 50.2 Hz, the AC phase crosses zero.
[0075] In one embodiment, the interrupt frequency that matches the frequency of the alternating current can be obtained through multiple adjustments; the method for determining whether the interrupt frequency of the timer matches the frequency of the alternating current includes: obtaining the interrupt frequencies obtained through multiple adjustments, and calculating the difference between each interrupt frequency and the frequency of the alternating current to obtain multiple frequency differences; determining a target frequency difference that is less than or equal to a preset frequency difference from the multiple frequency differences; and determining whether the interrupt frequency of the timer matches the frequency of the alternating current based on the proportion of the number of target frequency differences in the multiple frequency differences.
[0076] The target frequency difference may be an absolute value. Specifically, if the percentage of target frequency differences exceeds a preset ratio threshold, the timer interrupt frequency is determined to match the AC power frequency. If the percentage of target frequency differences is less than or equal to the preset ratio threshold, the timer interrupt frequency is determined to not match the AC power frequency. It should be noted that the preset ratio threshold can be set based on actual circumstances, for example, 80%.
[0077] S204 : When it is detected that the timer is interrupted according to the interruption frequency, determine the phase zero crossing point of the alternating current.
[0078] It should be noted that if the interrupt frequency matches the AC power frequency, the AC power phase will cross zero when the timer interrupts according to the matching interrupt frequency. By adjusting the timer interrupt frequency to detect the AC power zero phase, there is no need for hardware circuitry to perform zero-crossing detection.
[0079] In one embodiment, after determining that the timer interrupt frequency matches the frequency of the alternating current, based on the adjusted interrupt frequency, a target sampling value obtained by the signal sampler sampling the electrical signal parameters of the alternating current when the timer is interrupted is obtained, and the target sampling value corresponds to the phase zero crossing point of the alternating current.
[0080] The phase zero-crossing detection method provided in the above embodiment obtains a sampled value of an AC electrical signal parameter upon detecting a timer interrupt; updates the timer interrupt count value using a PID algorithm based on the sampled value and a standard zero-crossing reference value; and adjusts the timer interrupt frequency based on the interrupt count value to match the frequency of the AC, wherein the AC phase crosses zero when the timer interrupts according to the interrupt frequency. Detecting the zero phase of AC using a timer and a PID algorithm is applicable to AC of various frequencies and voltage levels. By adjusting the timer interrupt frequency to determine the AC phase zero-crossing, there is no need for hardware circuitry for zero-crossing detection. This reduces the difficulty and cost of circuit design for detecting the AC phase zero-crossing and improves the accuracy of AC phase zero-crossing detection.
[0081] Please refer to Figure 5 , Figure 5 The present invention provides a schematic flow chart of the steps of a power switching method according to an embodiment of the present invention, wherein the power switching method includes the phase zero-crossing point detection method according to the above embodiment.
[0082] like Figure 5 As shown, the phase zero-crossing point detection method further includes steps S301 to S302.
[0083] Step S301: In response to a switching instruction, obtain a timer status.
[0084] The switching instruction instructs the switching circuit to switch power between the first power source and the energy storage device to control the first power source or the energy storage device to supply power to the load. The switching instruction can be triggered by the user or by the switching circuit due to factors such as power failure of the first power source or the energy storage device.
[0085] It should be noted that the switching circuit obtains the state of the timer in response to the switching instruction. The state of the timer includes whether the interrupt frequency of the timer matches the frequency of the AC power and whether the timer is in an interrupt state.
[0086] In one embodiment, after responding to the switching instruction, the state of the timer is that the interrupt frequency of the timer matches the frequency of the AC power, and subsequent operations such as step S302 can be performed; in some embodiments, after responding to the switching instruction, the state of the timer is that the interrupt frequency of the timer does not match the frequency of the AC power, and the above-mentioned steps S201 to S203 can be performed to make the interrupt frequency of the timer match the frequency of the AC power, and then subsequent operations such as step S302 can be performed.
[0087] Step S302: When it is detected that the timer is interrupted according to the interrupt frequency, a switching control signal is output to the target device.
[0088] The switching control instruction is used to instruct the target device to output AC power of a target phase. The target device is a device to be powered, including a first power supply or an energy storage device. The target phase is, for example, zero phase, but can also be other phases.
[0089] It should be noted that by outputting a switching control signal to the target device, the output phase of the AC power provided by the target device is the target phase, which improves the accuracy and safety of power switching and avoids damage to the device due to excessive difference in AC voltage phase.
[0090] In one embodiment, the switching control signal is a signal agreed upon with the target device. The switching control signal can be a rising edge signal from low to high, or a falling edge signal from high to low. It can be specifically set according to the output phase of the target device to ensure that the output phase of the target device is consistent with the output phase of the AC power.
[0091] Exemplarily, the switching circuit is arranged in an intelligent electrical box. When the intelligent electrical box detects that the timer is interrupted according to the interrupt frequency, it outputs a switching control signal of a rising edge signal to the target device. After the target device detects the switching control signal, it uses the level rising change point corresponding to the switching control signal as the zero phase point of the AC voltage output to output the AC voltage.
[0092] Please refer to Figure 6 , Figure 6 A schematic diagram of a scenario for implementing the power switching method provided in this embodiment.
[0093] like Figure 6 As shown, the smart power box 31 supplies power to the load 30 via AC power provided by the power grid 32. The smart power box 31 obtains a switching control signal for controlling the energy storage device 33 to switch power usage. Upon detecting that the timer has been interrupted according to the interruption frequency, the smart power box 31 sends the switching control signal to the energy storage device 33, thereby controlling the energy storage device 33 to output AC power of the target phase to the load 30, ensuring that the output phase of the AC power provided by the energy storage device 33 is the same as that provided by the power grid 32. Upon detecting the AC power output by the energy storage device 33, the smart power box 31 also controls the disconnection of the AC power provided by the power grid 32.
[0094] The above embodiment provides a power switching method, which obtains the status of the timer by responding to a switching instruction; when it is detected that the timer is interrupted according to the interrupt frequency, it outputs a switching control signal to the target device. The switching control instruction is used to instruct the target device to output AC power of the target phase, so that the output phase of the first power supply is consistent with that of the energy storage device, avoiding excessive difference in AC voltage phase when power switching between devices, greatly improving the accuracy and safety of power switching, and avoiding damage to the device during power switching.
[0095] In one embodiment, if Figure 7 As shown, an embodiment of the present application provides a power switching method including:
[0096] First control: When the smart box triggers the zero-phase check operation (the triggering conditions may be the smart box being turned on, the user triggering the AC zero-phase check, the energy storage device being connected to the load, etc.), the timer starts timing. When the timer ends and the timer interrupt is triggered, it is assumed that point 41 is the sampling value of the AC signal when the timer is first interrupted. This value is greater than the sampling value of the phase zero point. At this time, the interrupt frequency of the timer is 51.3hz.
[0097] Second control: Since the timer interrupt frequency is 51.3 Hz, when the timer interrupt is triggered, AC signal sampling will obtain a value closer to zero phase. Point 42 is the sampling value of the AC signal when the timer is interrupted for the second time. However, since the sampling value is still greater than the zero phase value, the interrupt frequency obtained after calculation is still greater than 50 Hz.
[0098] Third control: Point 43 is the sampling value of the AC signal when the timer is interrupted for the third time. Due to the effect of the PID control system, the sampling value is closer to zero phase. At this time, the interrupt frequency of the timer is extremely close to 50hz.
[0099] Similarly, after N control cycles, when the timer interrupts, the signal sampling value is less than or equal to the zero-phase value. At this point, the timer interrupt frequency is less than 50 Hz. For example, the interrupt frequency corresponding to the AC signal sampling values at points 44 and 45 is less than 50 Hz. When the signal sampling value is less than the zero-phase sampling value, the PID control system will set the timer interrupt frequency to a frequency less than 50 Hz. At this point, the signal sampling value will gradually increase until it equals the zero-phase sampling value. For example, the interrupt frequency corresponding to the AC signal sampling value at point 46 is greater than the interrupt frequency corresponding to the AC signal sampling value at point 45.
[0100] When the signal sampling value collected by the timer interrupt is close to or equal to the zero-phase sampling value, the timer interrupt coincides with the zero phase of the AC voltage. At this time, the timer interrupt frequency coincides with the frequency of the AC power, such as 50 Hz. Specifically, in steady state, the timer interrupt frequency coincides with the frequency of the AC power. Steady state is a situation where the signal sampling value is close to or equal to the zero-phase sampling value for a period of time. It should be noted that in this application, the smart electrical box performs zero-phase verification of the AC power after the verification operation is triggered, that is, the timer interrupt frequency calibration can be performed all the time.
[0101] In one embodiment, when the smart electric box needs to switch between the power grid system and the energy storage device, the smart electric box sends a rising edge signal from low to high on the output pin of the energy storage device when the timer is interrupted, so that the output phase of the energy storage device can be consistent with the output phase of the AC power.
[0102] See also Figure 8 , Figure 8 A schematic block diagram of the structure of a switching circuit provided in an embodiment of the present application.
[0103] like Figure 8 As shown, the switching circuit 300 includes a processor 302 and a memory 303 connected via a system bus 301. The switching circuit 300 also includes a timer 304 and a signal sampler 305. The timer 304 is used for timing counting, and the signal sampler 305 is used for collecting electrical signal parameters of the alternating current.
[0104] The memory 303 may include a non-volatile storage medium and an internal memory, and the non-volatile storage medium may store an operating system and a computer program. The computer program includes program instructions that, when executed, cause the processor 302 to execute any one of the phase zero-crossing detection methods or the power switching method.
[0105] The processor 302 is used to provide computing and control capabilities to support the operation of the entire switching circuit 300 .
[0106] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor 302, the processor 302 can execute any phase zero-crossing point detection method or power switching method.
[0107] The switching circuit 300 may further include a network interface for performing network communication, such as sending assigned tasks, etc. It will be understood by those skilled in the art that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the switching circuit 300 to which the solution of the present application is applied. The specific switching circuit 300 may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0108] It should be understood that the processor 302 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0109] In one embodiment, the processor 302 is configured to execute a computer program stored in a memory to implement the following steps:
[0110] When a timer interrupt is detected, a sampling value of an electrical signal parameter of the alternating current is obtained;
[0111] adjusting the interrupt frequency of the timer according to the sampled value and the standard zero-crossing reference value of the alternating current so that the interrupt frequency matches the frequency of the alternating current;
[0112] When it is detected that the timer is interrupted according to the interruption frequency, a phase zero crossing point of the alternating current is determined.
[0113] In one embodiment, when implementing the step of adjusting the interrupt frequency of the timer according to the sampling value and the standard zero-crossing sampling value of the alternating current, the processor 302 is configured to:
[0114] updating an interrupt count value of the timer using a PID algorithm according to the sampled value and the standard zero-crossing reference value, wherein an interrupt operation is performed when the count value of the timer reaches the interrupt count value;
[0115] The interrupt frequency of the timer is adjusted according to the interrupt count value.
[0116] In one embodiment, the processor 302 is configured to run a computer program stored in the memory and further implement the following steps:
[0117] In response to a switching instruction, obtaining a state of the timer;
[0118] When it is detected that the timer is interrupted according to the interrupt frequency, a switching control signal is output to the target device, wherein the switching control signal is used to instruct the target device to output AC power of a target phase.
[0119] It should be noted that, those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the switching circuit 300 described above can refer to the corresponding process in the aforementioned phase zero-crossing point detection method or the power switching method embodiment, and will not be repeated here.
[0120] See also Figure 9 , Figure 9 A schematic block diagram of the structure of a power distribution system provided in an embodiment of the present application.
[0121] like Figure 9As shown, the power distribution system 400 of the embodiment of the present application includes an energy storage device 401 and a switching circuit 402. The switching circuit 402 is electrically connected to the first power supply and the energy storage device 401 respectively, and is used to control the first power supply or the energy storage device 401 to supply power to the load.
[0122] The switching circuit 402 may be the switching circuit 300 in the above embodiment. It should be noted that those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the power distribution system 400 described above can refer to the corresponding process in the aforementioned phase zero-crossing point detection method or power switching method embodiment, and will not be repeated here.
[0123] An embodiment of the present application also provides a computer-readable storage medium, on which one or more computer programs are stored, wherein the one or more computer programs include program instructions, and the program instructions can be executed by one or more processors. The method implemented when the program instructions are executed can refer to the various embodiments of the phase zero-crossing detection method or the power switching method of the present application.
[0124] The computer-readable storage medium may be an internal storage unit of the switching circuit described in the aforementioned embodiment, such as a hard disk or memory of the switching circuit. The computer-readable storage medium may also be an external storage device of the switching circuit, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the switching circuit.
[0125] It should be understood that the terms used in this specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0126] It should also be understood that the term "and / or" used in this specification and the appended claims refers to any combination of one or more of the associated listed items and all possible combinations, including these combinations. It should be noted that, in this article, the terms "include", "comprise" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "including a..." does not exclude the presence of other identical elements in the process, method, article or system that includes the element.
[0127] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments. The above description is only a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A phase zero-crossing detection method, characterized in that: include: When a timer interrupt is detected, a sampling value of an electrical signal parameter of the alternating current is obtained; updating an interrupt count value of the timer using a PID algorithm according to the sampled value and a standard zero-crossing reference value of the alternating current, wherein the timer performs an interrupt operation when the count value reaches the interrupt count value; adjusting an interrupt frequency of the timer according to the interrupt count value so that the interrupt frequency matches the frequency of the alternating current; When it is detected that the timer is interrupted according to the interruption frequency, a phase zero crossing point of the alternating current is determined.
2. The phase zero-crossing detection method according to claim 1, characterized in that: The updating of the interrupt count value of the timer by using a PID algorithm according to the sampling value and the standard zero-crossing reference value of the alternating current comprises: Calculating an error between the sampled value and a standard zero-crossing reference value of the alternating current; Determine an offset parameter of the interrupt count value of the timer according to the error value and a preset PID formula; The interrupt count value is updated according to the offset parameter.
3. The phase zero-crossing detection method according to claim 2, characterized in that: The determining, according to the error value and a preset PID formula, an offset parameter of the interrupt count value of the timer includes: Obtaining a preset proportional coefficient, a preset integral coefficient, and a preset differential coefficient; Determining a first offset parameter of the interrupt count value according to the preset proportional coefficient and the error value; Obtaining an error accumulation value according to a plurality of error values determined when the timer is interrupted multiple times, and determining a second offset parameter of the interrupt count value according to the preset integral coefficient and the error accumulation value; Obtaining an error difference value based on the currently determined error value and the error value when the timer was last interrupted, and determining a third offset parameter of the interrupt count value based on the preset integral coefficient and the error difference value; The sum of the first offset parameter, the second offset parameter and the third offset parameter is calculated to obtain the offset parameter of the interrupt count value of the timer.
4. The phase zero-crossing detection method according to claim 1, wherein: The adjusting the interrupt frequency of the timer according to the interrupt count value includes: Calculating the ratio between the interruption count value before adjustment and the interruption count value after adjustment to obtain an adjustment ratio; The interrupt frequency of the timer is adjusted according to the adjustment ratio.
5. The phase zero-crossing detection method according to any one of claims 1 to 4, characterized in that: Before obtaining the sample value of the electrical signal parameter of the alternating current when the timer interrupt is detected, the method further includes: In response to a zero phase detection instruction, initializing the timer and controlling the timer to start counting; The zero phase detection instruction is used to instruct to perform phase zero crossing detection on the alternating current.
6. The phase zero-crossing detection method according to claim 5, characterized in that: The triggering method of the zero-phase detection instruction includes: powering on the distribution box, a user triggering the zero-phase detection instruction, or connecting an energy storage device to a load.
7. A method for switching electricity, characterized in that: The method for detecting a phase zero crossing point according to any one of claims 1 to 6, wherein the power switching method further comprises: In response to a switching instruction, obtaining a state of the timer; When it is detected that the timer is interrupted according to the interrupt frequency, a switching control signal is output to the target device, wherein the switching control signal is used to instruct the target device to output AC power of a target phase.
8. A switching circuit, characterized in that: The switching circuit includes a timer and a signal sampler; The signal sampler is used to collect electrical signal parameters of alternating current; The switching circuit also includes a processor, a memory, and a data bus for realizing connection and communication between the processor and the memory, wherein the memory stores a computer program that can be executed by the processor, and when the computer program is executed by the processor, it implements the phase zero-crossing point detection method according to any one of claims 1 to 6 or the steps of the power switching method according to claim 7.
9. A power distribution system, characterized in that: The power distribution system comprises: Energy storage equipment; The switching circuit according to claim 8, wherein the switching circuit is electrically connected to the first power supply and the energy storage device, respectively, and is used to control the first power supply or the energy storage device to supply power to the load.
Citation Information
Patent Citations
Voltage zero-crossing detection method and device and cooking electric appliance
CN109799384A
Power frequency voltage zero crossing point detection method and system
CN110286262A