A charging pile grounding fault diagnosis and locking control method and system

CN122539943APending Publication Date: 2026-08-11XIAMEN JOINT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-09
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0005]本申请提供了一种充电桩接地故障诊断与锁定控制方法及系统,该方法解决了现有技术中单一静态阈值监控导致的误判问题以及电压恢复即复位僵化逻辑带来的安全隐患

Benefits of technology

1、通过持续采集火线对零线电压和火线对地线电压,实时掌握充电桩供电线路的电气状态;通过提取预设时间窗口内的火线对零线电压瞬时值序列并计算总谐波失真得分、电压事件得分以及基波频率偏移得分,全面评估电网质量状况,对这些得分进行加权求和得到电网环境总分后,可以准确识别充电桩所处的电网环境模式,并确定安全阈值、恢复阈值、异常确认时长以及恢复确认时长,有效避免了固定阈值在复杂电网环境下的频繁误报或漏报问题;在未插枪状态时通过计算火线对地线电压与火线对零线电压的电压比值来监测接地状态,当电压比值小于安全阈值且持续异常确认时长时触发接地故障锁定状态。当充电桩已处于接地故障锁定状态时,即使插枪状态信号变更为已插枪状态,仍维持接地故障锁定状态并禁止充电,有效防止了车辆端零线与地线非法短接导致的桥接回路形成时,火线对地线电压被强行拉高而产生的假性恢复现象,避免系统误判故障已消除而解除锁定;只有在未插枪状态下且电压比值大于或等于恢复阈值并持续恢复确认时长这一预设接地故障恢复条件真正满足后,才解除接地故障锁定状态,从而确保了充电桩接地系统的真实恢复,全面保障了用户的人身安全。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122539943A_ABST
    Figure CN122539943A_ABST
Patent Text Reader

Abstract

The application relates to a charging pile ground fault diagnosis and locking control method and system, and relates to the technical field of charging pile fault diagnosis. A gun insertion state signal is acquired, and the live wire to zero line voltage and the live wire to ground line voltage of a power supply line are collected; the instantaneous value sequence of the live wire to zero line voltage in a preset time window is extracted, the power grid environment total score is obtained based on the instantaneous value sequence, the safety threshold corresponding to the power grid environment mode is determined according to the power grid environment total score; when the gun is not inserted, the voltage ratio is calculated; if the voltage ratio is less than the safety threshold, the duration reaches the abnormal confirmation duration, and the ground fault locking state is placed, and the charging operation is prohibited; when the ground fault locking state is in the inserted state, the ground fault locking state is maintained and the charging is prohibited; if the gun insertion state signal indicates that the gun is not inserted, the preset ground fault recovery condition is met, the ground fault locking state is released, and the charging operation is allowed. The method solves the misjudgment problem caused by static threshold monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of charging pile fault diagnosis technology, specifically to a method and system for diagnosing and locking grounding faults in charging piles. Background Technology

[0002] With the rapid popularization of new energy vehicles, AC charging piles, as an important infrastructure for providing power to electric vehicles, have attracted much attention regarding their operational safety. In the power supply network of charging piles, the protective grounding system is a critical line of defense for ensuring user safety and the normal operation of equipment. Once a grounding fault occurs at a charging pile (such as a broken grounding wire or abnormally high impedance), the system will lose its basic leakage protection function, which can easily lead to serious electric shock accidents in the event of leakage. Therefore, real-time monitoring of the grounding status of charging piles is crucial.

[0003] Currently, the monitoring of grounding faults in charging piles mainly relies on a single static threshold monitoring of the voltage between the live wire and ground (L-GND) in the power supply line. That is, the system collects the L-GND voltage in real time through a voltage detection circuit and compares it with a preset fixed reference threshold. When the detected L-GND voltage is lower than the set threshold, the system determines that a grounding fault has occurred and triggers protection; when the voltage rises back above the set normal threshold, the system determines that the grounding status is normal, then automatically resets and allows subsequent charging operations to proceed.

[0004] However, in complex real-world applications, the aforementioned existing technologies can lead to problems. If the charging station itself has a poor grounding connection, and the connected electric vehicle has an illegal short circuit between its neutral and ground wires, the charging gun's operation will create an illegal bridging loop between the live wire, neutral wire, ground wire, and the vehicle body. This bridging effect causes the L-GND voltage at the charging station's detection end to be forcibly pulled high, resulting in a "false recovery" of the voltage. Because the existing technology uses a rigid logic of "voltage recovery equals reset," the system may mistakenly believe the grounding fault has been eliminated, automatically unlocking the fault and allowing charging. This not only fails to identify the true source of the fault but also masks the significant safety hazard of the charging station's grounding failure, posing a serious threat to the user's personal safety. Summary of the Invention

[0005] This application provides a method and system for diagnosing and locking grounding faults in charging piles. This method solves the problem of misjudgment caused by single static threshold monitoring in the prior art and the safety hazards caused by the rigid logic of voltage recovery and reset.

[0006] Firstly, this application provides a method for diagnosing and locking grounding faults in charging piles. The method includes: acquiring the charging pile's plug-in status signal and continuously collecting the live-to-neutral voltage and live-to-ground voltage of the power supply line; extracting the instantaneous value sequence of the live-to-neutral voltage within a preset time window, and calculating the total harmonic distortion score, voltage event score, and fundamental frequency offset score based on the instantaneous value sequence; weighted summing of the total harmonic distortion score, voltage event score, and fundamental frequency offset score to obtain the total grid environment score; determining the grid environment mode of the charging pile based on the total grid environment score, and determining the corresponding safety threshold, recovery threshold, anomaly confirmation time, and recovery confirmation time based on the grid environment mode; when the charging pile is plugged in... When the status signal indicates that the charging gun is not plugged in, the voltage ratio between the live wire and the ground wire and the live wire and the neutral wire is calculated. If the voltage ratio is less than the safety threshold and the duration reaches the abnormal confirmation time, the charging pile is placed in a ground fault lockout state, and charging operation is prohibited. When the charging pile is in a ground fault lockout state, if the charging gun status signal changes to the plugged-in state, the ground fault lockout state is maintained and charging is prohibited. When the charging pile is in a ground fault lockout state, if the charging gun status signal indicates that the charging gun is not plugged in and the preset ground fault recovery conditions are met, the ground fault lockout state is released, and charging operation is allowed. The preset ground fault recovery conditions include a voltage ratio greater than or equal to the recovery threshold and a continuous recovery confirmation time.

[0007] By adopting the above technical solution, the electrical status of the charging pile's power supply line can be monitored in real time by continuously collecting the voltage between the live wire and neutral wire and the voltage between the live wire and ground wire. By extracting the instantaneous value sequence of the live wire to neutral wire voltage within a preset time window and calculating the total harmonic distortion score, voltage event score, and fundamental frequency offset score, the power grid quality can be comprehensively evaluated. After weighted summing of these scores to obtain the total power grid environment score, the power grid environment mode in which the charging pile is located can be accurately identified, and the safety threshold, recovery threshold, anomaly confirmation time, and recovery confirmation time can be determined, effectively avoiding the problem of frequent false alarms or missed alarms of fixed thresholds in complex power grid environments. When the charging gun is not plugged in, the grounding status is monitored by calculating the voltage ratio between the live wire to ground wire voltage and the live wire to neutral wire voltage. When the voltage ratio is less than the safety threshold and the anomaly confirmation time is continuous, the grounding fault lockout state is triggered. When a charging station is already in a ground fault locked state, even if the charging gun status signal changes to "charging gun engaged," the ground fault locked state remains in effect and charging is prohibited. This effectively prevents the false recovery phenomenon caused by the forced increase of the voltage between the live wire and the ground wire when a bridging circuit is formed due to an illegal short circuit between the vehicle's neutral wire and the ground wire. This avoids the system misjudging that the fault has been eliminated and thus releasing the lockout. Only when the preset ground fault recovery condition—that the voltage ratio is greater than or equal to the recovery threshold and the recovery confirmation time is continuously met—is the ground fault locked state released. This ensures the true recovery of the charging station's grounding system and fully protects the personal safety of users.

[0008] Optionally, the instantaneous value sequence of the live-to-neutral voltage within a preset time window is extracted. Based on the instantaneous value sequence, the total harmonic distortion score, voltage event score, and fundamental frequency offset score are calculated. Specifically, this includes: performing a fast Fourier transform on the instantaneous value sequence to obtain the spectrum, extracting the fundamental amplitude and harmonic amplitudes from the spectrum, calculating the real-time total harmonic distortion based on the fundamental amplitude and harmonic amplitudes; calculating the difference between the real-time total harmonic distortion and the reference total harmonic distortion, comparing the difference with multiple preset deviation thresholds, and obtaining the total harmonic distortion score based on the comparison results; calculating the effective voltage value corresponding to the instantaneous value sequence, and when the effective voltage value exceeds... When the voltage exceeds the preset upper and lower limits of the rated voltage, it is recorded as a voltage event; when the absolute value of the instantaneous value sequence exceeds the preset transient peak threshold, it is recorded as a transient overvoltage event; the total number of voltage events and transient overvoltage events within the preset time window is counted, and a voltage event score is calculated based on the total number of occurrences; the zero-crossing timestamps of consecutive zero-crossing points in the same direction are identified from the instantaneous value sequence, and the time difference between two adjacent zero-crossing timestamps is calculated as the real-time period, and the reciprocal of the real-time period is used as the real-time frequency; the maximum offset of the real-time frequency relative to the preset reference frequency within the preset time window is extracted, and a fundamental frequency offset score is calculated based on the maximum offset.

[0009] By employing the above technical solutions, a fast Fourier transform is performed on the instantaneous value sequence of the live-to-neutral voltage to extract spectral features. The difference between the real-time total harmonic distortion (THD) and the reference THD is calculated and compared with multiple preset deviation thresholds to obtain a THD score, which can accurately identify changes in the degree of harmonic pollution in the power grid. By statistically analyzing the total number of voltage events in a preset time window where the effective voltage value exceeds the preset upper and lower limits of the rated voltage, and the total number of transient overvoltage events where the absolute value of the instantaneous value exceeds the preset transient peak threshold, and by calculating the voltage event score using a weighted summation method, the impact of power grid voltage fluctuations and impulse disturbances on grounding detection can be effectively captured. By identifying the zero-crossing timestamps of consecutive zero-crossing points in the same direction and calculating the time difference between adjacent zero-crossing timestamps as the real-time period, the maximum offset of the real-time frequency relative to the preset reference frequency is obtained. Based on the maximum offset and the frequency penalty coefficient, the fundamental frequency offset score is calculated, which can promptly detect the interference of power grid frequency anomalies on the accuracy of voltage measurement.

[0010] Optionally, the power grid environment mode includes a severe power grid environment mode and a normal power grid environment mode. The power grid environment mode of the charging pile is determined based on the total power grid environment score, and the corresponding safety threshold, recovery threshold, anomaly confirmation time, and recovery confirmation time are determined based on the power grid environment mode. Specifically, this includes: comparing the total power grid environment score with the severe environment score threshold and the normal environment score threshold, wherein the severe environment score threshold is greater than the normal environment score threshold; when the total power grid environment score is greater than the severe environment score threshold, the charging pile is determined to be in the severe power grid environment mode; when the charging pile is in the severe power grid environment mode, and the total power grid environment score calculated for a consecutive preset number of times is less than or equal to the normal environment score threshold, the charging pile is determined to switch to the normal power grid environment mode; matching the corresponding basic safety threshold, basic recovery threshold, anomaly confirmation time, and recovery confirmation time according to the power grid environment mode of the charging pile; obtaining the voltage ratio sequence within a preset historical time period, and calculating the basic recovery threshold and basic safety threshold based on the voltage ratio sequence to obtain the safety threshold and recovery threshold.

[0011] By adopting the above technical solution, the total power grid environment score is compared with both the severe environment score threshold and the normal environment score threshold. When the total power grid environment score is greater than the severe environment score threshold, the charging pile is determined to be in a severe power grid environment mode. When the charging pile is in a severe power grid environment mode, the total power grid environment score calculated for a preset number of consecutive times must be less than or equal to the normal environment score threshold before it can switch to a normal power grid environment mode. When the total power grid environment score is between the two score thresholds, the current mode remains unchanged. Based on the identified power grid environment mode, the corresponding basic safety threshold, basic recovery threshold, anomaly confirmation time, and recovery confirmation time are matched. The basic recovery threshold and basic safety threshold are adaptively calculated based on the voltage ratio sequence within a preset historical time period to obtain the final safety threshold and recovery threshold.

[0012] Optionally, the basic recovery threshold and basic safety threshold are calculated based on the voltage ratio sequence to obtain the safety threshold and recovery threshold. Specifically, this includes: calculating the standard deviation of the voltage ratio of the voltage ratio sequence; calculating the ratio of the total grid environment score to the benchmark environment score to obtain the environmental degradation coefficient; multiplying the environmental degradation coefficient by the basic first factor to obtain the first adjustment factor; subtracting the product of the voltage ratio standard deviation and the first adjustment factor from the basic safety threshold to obtain the safety threshold; multiplying the environmental degradation coefficient by the basic second factor and adding the hysteresis compensation constant to obtain the second adjustment factor; and adding the product of the voltage ratio standard deviation and the second adjustment factor to the basic recovery threshold to obtain the recovery threshold.

[0013] By adopting the above technical solution, the standard deviation of voltage ratios in a voltage ratio sequence within a preset historical time period is calculated to quantify the severity of voltage fluctuations. The ratio of the total grid environment score to the benchmark environment score is used to calculate the environmental degradation coefficient, which characterizes the degree of deviation in grid quality. The first adjustment factor is obtained by multiplying the environmental degradation coefficient by the first basic factor, and the safety threshold is obtained by subtracting the product of the standard deviation of voltage ratios and the first adjustment factor from the basic safety threshold. The second adjustment factor is obtained by multiplying the environmental degradation coefficient by the second basic factor and superimposing the hysteresis compensation constant. The recovery threshold is obtained by adding the product of the standard deviation of voltage ratios and the second adjustment factor to the basic recovery threshold. This makes the recovery threshold increase more under harsh environments and high fluctuation conditions, ensuring that fault recovery judgment is more conservative and reliable.

[0014] Optionally, when the charging pile is in a ground fault locked state, if the charging gun status signal changes to "charging gun inserted," then after maintaining the ground fault locked state and prohibiting charging, the method further includes: acquiring the first average live wire to ground voltage during a first target time period before the charging gun status signal changes to "charging gun inserted," and the second average live wire to ground voltage during a second target time period after the change to "charging gun inserted"; calculating the rate of change of live wire to ground voltage before and after charging gun insertion based on the first average live wire to ground voltage and the second average live wire to ground voltage; injecting a first active detection signal into the protective grounding circuit of the charging pile, and collecting the response current of the first active detection signal in the protective grounding circuit; based on the first active detection signal... The system detects the signal and response current to calculate the real-time loop impedance characteristics. It compares the rate of change of the live wire to ground voltage with a preset rate of change threshold and performs feature matching between the real-time loop impedance characteristics and a preset fault feature database. If the rate of change of the live wire to ground voltage is greater than the preset rate of change threshold and the real-time loop impedance characteristics match the impedance drop in the preset fault feature database, the ground fault is determined to originate from the vehicle end, and vehicle end illegal connection diagnostic information is generated. If the rate of change of the live wire to ground voltage is less than or equal to the preset rate of change threshold, or the real-time loop impedance characteristics do not match the impedance drop, the ground fault is determined to originate from the charging pile itself, and charging pile itself ground fault diagnostic information is generated.

[0015] By adopting the above technical solution, when the charging pile is in a ground fault locked state and the charging gun status signal changes to the plugged-in state, while maintaining the ground fault locked state and prohibiting charging, the first average live wire to ground voltage during the first target time period before the plugged-in status signal change and the second average live wire to ground voltage during the second target time period after the change are immediately acquired. The potential change characteristics introduced by the vehicle connection are captured by calculating the rate of change of the live wire to ground voltage before and after plugging in. When the vehicle chassis is in contact with the ground or there is an illegal neutral ground connection, the live wire to ground voltage will change significantly, and the rate of change will be greater than the preset rate of change threshold. However, the voltage change of the charging pile body ground fault before and after plugging in is small. A first active detection signal is injected into the protective grounding circuit of the charging pile and the response current of the signal in the protective grounding circuit is collected. Based on the first active detection signal and the response current, the voltage change is calculated. The system obtains real-time loop impedance characteristics and performs feature matching with a preset fault feature database. When there is an illegal grounding short circuit at the vehicle end, a low-impedance parallel path is introduced into the grounding loop, causing the real-time loop impedance characteristic to match as an impedance drop. However, poor grounding of the charging pile itself manifests as high impedance characteristics. By comprehensively judging that the rate of change of the live wire to ground voltage is greater than a preset rate of change threshold and the real-time loop impedance characteristic matches as an impedance drop, the system determines that the grounding fault originates from the vehicle end and generates illegal connection diagnostic information for the vehicle end. Conversely, when the rate of change of the live wire to ground voltage is less than or equal to the preset rate of change threshold or the real-time loop impedance characteristic does not match as an impedance drop, the system determines that the grounding fault originates from the charging pile itself and generates grounding fault diagnostic information for the charging pile itself. This effectively avoids the risk of misjudgment based on a single feature and can accurately distinguish between two fundamentally different fault sources: grounding defects in the charging pile itself and illegal connections at the vehicle end.

[0016] Optionally, when the charging pile is in a ground fault locked state, if the charging gun status signal changes to "plugged in", the method further includes maintaining the ground fault locked state and prohibiting charging, and then: when the charging pile is in a ground fault locked state and the charging gun status signal is "plugged in", outputting ground fault alarm information through the charging pile's human-machine interface; simultaneously displaying a gun removal guidance prompt on the human-machine interface, which guides the user to remove the charging gun; when a change in the charging gun status signal is detected, confirming that the user has removed the charging gun according to the gun removal guidance prompt, and determining that the charging gun status signal has changed from "plugged in" to "not plugged in".

[0017] By adopting the above technical solution, when the charging pile is in a ground fault locked state and the charging gun status signal is "plugged in," a ground fault alarm message is output through the human-machine interface to clearly inform the user that the system has detected a ground safety hazard and has taken protective measures. This prevents users from making improper operations or mistakenly believing that the equipment is faulty due to a lack of understanding of the cause of the fault. Simultaneously, a gun-unplugging guidance message is displayed on the human-machine interface to guide the user in unplugging the charging gun. This ensures that the user clearly understands the correct operating steps required, meeting the technical requirements of fault recovery verification while guaranteeing the user's operational safety under fault conditions and preventing the safety risks that may arise from keeping the charging gun plugged in for an extended period. By monitoring the change in the charging gun status signal, it confirms that the user has unplugged the charging gun according to the unplugging guidance message and determines that the charging gun status signal has changed from "plugged in" to "not plugged in." This accurately captures the moment when the user responds to the guidance and completes the unplugging operation, thereby triggering the state machine to transition from the ground fault locked state to the fault recovery verification state. This allows for reliable recovery verification testing of the charging pile's own grounding system, excluding potential influence from the vehicle side.

[0018] Optionally, if the charging station's charging status signal indicates that the charging station is not plugged in, and the preset ground fault recovery conditions are met, the ground fault lockout state is released. Specifically, this includes: when the charging station is not plugged in, calculating the voltage ratio, injecting a second active detection signal into the charging station's protective grounding circuit, and continuously calculating the current circuit impedance characteristics based on the collected current response current; determining whether the voltage ratio is greater than or equal to the recovery threshold and continuing to confirm the recovery for a certain duration, or determining whether the current circuit impedance characteristics have recovered to the normal impedance range and continuing to confirm the impedance for a certain duration; if the voltage ratio is greater than or equal to the recovery threshold and continues to confirm the recovery for a certain duration, or if the current circuit impedance characteristics have recovered to the normal impedance range and continue to confirm the impedance for a certain duration, then it is determined that the ground fault recovery conditions are met, and the ground fault lockout state is released.

[0019] By adopting the above technical solution, the voltage ratio is continuously calculated when the charging pile is not plugged in, and a second active detection signal is injected into the protective grounding circuit of the charging pile at the same time. Based on the current response current collected, the current circuit impedance characteristics are continuously calculated. The repair status of the grounding system is comprehensively evaluated through the dual means of passive voltage monitoring and active impedance detection, avoiding the blind spots and misjudgment risks that may exist in a single monitoring dimension. It is determined whether the voltage ratio is greater than or equal to the recovery threshold and the recovery confirmation time is continuously maintained. At the same time, it is determined whether the current circuit impedance characteristics have recovered to the normal impedance range and the impedance confirmation time is continuously maintained. By setting the duration requirement, the influence of short-term voltage fluctuations or transient interference on the recovery judgment is filtered out, ensuring that the repair of the grounding system is real and stable rather than a temporary phenomenon.

[0020] The second aspect of this application provides a charging pile grounding fault diagnosis and locking control system. The system includes an acquisition unit, a processing unit, a locking unit, and a recovery unit. The acquisition unit acquires the charging pile's plug-in status signal and continuously collects the live-to-neutral voltage and live-to-ground voltage of the power supply line. The processing unit extracts the instantaneous value sequence of the live-to-neutral voltage within a preset time window, and calculates the total harmonic distortion score, voltage event score, and fundamental frequency offset score based on the instantaneous value sequence. The total harmonic distortion score, voltage event score, and fundamental frequency offset score are weighted and summed to obtain a total grid environment score. The grid environment mode of the charging pile is determined based on the total grid environment score, and the corresponding safety threshold, recovery threshold, and anomaly confirmation time are determined based on the grid environment mode. The system includes a ground fault confirmation time; when the charging gun status signal indicates an unplugged state, it calculates the voltage ratio between the live wire and ground wire voltage and the live wire and neutral wire voltage; a locking unit, if the voltage ratio is less than the safety threshold and the duration reaches the abnormal confirmation time, places the charging pile in a ground fault lock state and prohibits charging operation; when the charging pile is in a ground fault lock state, if the charging gun status signal changes to plugged state, the ground fault lock state is maintained and charging is prohibited; a recovery unit, when the charging pile is in a ground fault lock state, if the charging gun status signal indicates an unplugged state and the preset ground fault recovery conditions are met, releases the ground fault lock state and allows charging operation; the preset ground fault recovery conditions include a voltage ratio greater than or equal to the recovery threshold and a continuous recovery confirmation time.

[0021] In a third aspect, this application provides an electronic device including a processor, a memory, a user interface, and a network interface. The memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory, causing the electronic device to perform any of the methods described above in this application.

[0022] In a fourth aspect, this application provides a computer-readable storage medium storing instructions that, when executed, perform any of the methods described above in this application.

[0023] In summary, one or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. By continuously collecting the voltage between the live wire and neutral wire and the voltage between the live wire and ground wire, the electrical status of the charging pile's power supply line can be monitored in real time. By extracting the instantaneous value sequence of the live wire to neutral wire voltage within a preset time window and calculating the total harmonic distortion score, voltage event score, and fundamental frequency offset score, the power grid quality can be comprehensively evaluated. After weighted summing of these scores to obtain the total power grid environment score, the power grid environment mode in which the charging pile is located can be accurately identified, and the safety threshold, recovery threshold, anomaly confirmation duration, and recovery confirmation duration can be determined, effectively avoiding the problem of frequent false alarms or missed alarms of fixed thresholds in complex power grid environments. When the charging gun is not plugged in, the grounding status is monitored by calculating the voltage ratio between the live wire to ground wire voltage and the live wire to neutral wire voltage. When the voltage ratio is less than the safety threshold and the anomaly confirmation duration is continuous, the grounding fault lockout state is triggered. When a charging station is already in a ground fault locked state, even if the charging gun status signal changes to "charging gun engaged," the ground fault locked state remains in effect and charging is prohibited. This effectively prevents the false recovery phenomenon caused by the forced increase of the voltage between the live wire and the ground wire when a bridging circuit is formed due to an illegal short circuit between the vehicle's neutral wire and the ground wire. This avoids the system misjudging that the fault has been eliminated and thus releasing the lockout. Only when the preset ground fault recovery condition—that the voltage ratio is greater than or equal to the recovery threshold and the recovery confirmation time is continuously met—is the ground fault locked state released. This ensures the true recovery of the charging station's grounding system and fully protects the personal safety of users. Attached Figure Description

[0024] Figure 1 This is a flowchart illustrating a grounding fault diagnosis and locking control method for charging piles provided in an embodiment of this application; Figure 2 This is a schematic diagram of the framework of a charging pile grounding fault diagnosis and locking control method provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application.

[0025] Explanation of reference numerals in the attached figures: 300, electronic device; 301, processor; 302, memory; 303, user interface; 304, network interface; 305, communication bus. Detailed Implementation

[0026] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.

[0027] In the description of the embodiments of this application, the words "for example" or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design that is described as "for example" or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design options. Rather, the use of the words "for example" or "for instance" is intended to present the relevant concepts in a specific manner.

[0028] In the description of the embodiments of this application, the term "multiple" means two or more. For example, multiple systems means two or more systems, and multiple screen terminals means two or more screen terminals. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.

[0029] Therefore, how to address the misjudgments caused by single static threshold monitoring in existing technologies, and the safety hazards brought about by the rigid logic of voltage recovery and reset, are urgent problems to be solved. This application provides a charging pile grounding fault diagnosis and locking control method, applied in a server. The server in this application can be a platform providing grounding fault diagnosis services for charging piles. Figure 1 This is a flowchart illustrating a grounding fault diagnosis and locking control method for charging piles provided in an embodiment of this application. (Refer to...) Figure 1 The method includes the following steps S101-S107.

[0030] S101: Acquire the charging station's plug-in status signal and continuously collect the live wire to neutral wire voltage and live wire to ground wire voltage of the power supply line.

[0031] In the above S101, in order to diagnose grounding faults, it is necessary to simultaneously acquire the charging pile's plug-in status signal and continuously collect the live wire to neutral line voltage and live wire to ground line voltage of the power supply line. This is because the plug-in status signal determines the physical connection status between the charging pile and the electric vehicle, while the live wire to neutral line voltage and live wire to ground line voltage reflect the real-time electrical characteristics of the power supply line. Only by combining these two types of information can the true state of the grounding system be accurately identified and misjudgments caused by illegal connections at the vehicle end be avoided.

[0032] The acquisition of the charging gun connection status signal typically relies on the standard communication protocol between the charging pile and the electric vehicle. The main control unit determines the connection status of the charging gun by monitoring the voltage changes of the CC or CP signal lines of the charging interface. In the unplugged state, the voltage of the CP signal line usually remains around +12V, indicating that the charging pile is in a ready standby state. When the user plugs the charging gun into the electric vehicle's charging interface and completes the physical connection, a PWM pulse signal is generated on the CP signal line, causing a significant change in voltage characteristics. The main control unit detects this voltage change to identify the plugging event and updates the connection status signal to "plugged in." During or after charging, when the user unplugs the charging gun, the voltage of the CP signal line rises back to +12V. The main control unit then determines that the charging gun has been unplugged and updates the connection status signal to "unplugged in." By continuously monitoring the CC or CP signal lines, the connection status between the charging gun and the vehicle can be monitored in real time.

[0033] The voltage monitoring module needs to continuously collect the live-to-neutral (L) and live-to-ground (L-GND) voltages of the power supply line. The live-to-neutral (L) voltage refers to the voltage difference between the L and N lines. In a standard single-phase AC power supply system, this voltage is typically 220V ± 10%, reflecting the reference supply voltage of the charging pile. The live-to-ground (L) voltage refers to the voltage difference between the L and GND lines. Under normal grounding conditions, since the N and GND lines are connected at the power supply end and the GND line should maintain a good earth connection, the live-to-ground (L-GND) voltage should be close to the live-to-neutral (L-GND) voltage. However, when a fault occurs in the charging pile's protective grounding system, such as a disconnected GND line or an abnormally high grounding impedance, the live-to-ground (L-GND) voltage will significantly decrease, and the ratio of the live-to-ground (L-GND) voltage to the live-to-ground (L-GND) voltage will deviate from the normal range. This change in ratio is the core basis for judging grounding faults. To achieve high-precision voltage acquisition, the voltage monitoring module typically uses a high-performance ADC converter in conjunction with a precise resistor divider network to synchronously sample the LN and L-GND voltages. The sampling frequency should be high enough to capture instantaneous voltage changes; for example, it can be set to sample more than 1000 times per second to ensure accurate reflection of the detailed characteristics of the voltage waveform. The acquired instantaneous voltage values ​​are digitally filtered and stored in the buffer of the main control unit for subsequent power grid environment analysis and fault diagnosis.

[0034] By synchronously acquiring the charging gun status signal and continuously collecting the voltage between the live wire and neutral wire, and the voltage between the live wire and ground wire, the system can correlate the plugging and unplugging of the charging gun with the dynamic changes in voltage parameters over time. It can not only monitor static voltage thresholds but also analyze the voltage trends before and after plugging in the charging gun, thereby identifying bridging loop effects caused by illegal N-GND connections at the vehicle end. For example, when the charging pile detects a persistently low live wire-to-ground voltage when the charging gun is not plugged in and determines it to be a grounding fault, it enters a fault-locked state. If the user plugs in the charging gun and the connected vehicle has an N-GND short circuit, the plugging action will cause the live wire-to-ground voltage to suddenly rise. However, because the changes in the plugging gun status signal are monitored synchronously, it can be identified that this voltage recovery occurs when the charging gun is plugged in, rather than a genuine repair of the charging pile's own grounding system. Therefore, the fault-locked state will be maintained and charging will be refused, thus avoiding the safety hazards caused by false voltage recovery in existing technologies.

[0035] like Figure 2 As shown, Figure 2 The diagram showcases the modules of the intelligent diagnostic and locking control system for charging pile grounding faults. The system includes a voltage monitoring module, a main control unit, a charging gun status detection module, an active signal injection module, a signal response analysis module, and a fault feature database module. The architecture adopts a center-radial topology, with the main control unit located at the system center. This unit is responsible for receiving data input from each module, executing state machine logic, making judgments and control decisions, and coordinating the operation of the entire system. The voltage monitoring module, located in the upper left corner of the system architecture, serves as the foundational sensing front-end, responsible for real-time acquisition of the two most basic electrical parameters, LN voltage and L-GND voltage, and calculating the voltage ratio K. The charging gun status detection module, located in the upper right corner, provides connection status information and charging gun insertion / removal events by monitoring the CC / CP signal. The active signal injection module and signal response analysis module, located below, form an active detection subsystem. The former injects test signals into the grounding loop, while the latter collects and analyzes response signals and extracts impedance characteristics. Together, they enhance diagnostic capabilities. The fault feature database module, located in the lower right corner, stores a feature pattern library of various fault modes, providing the main control unit with knowledge support for pattern matching and diagnostic judgment. The voltage monitoring module and the plug status detection module, as the sensing layer, provide basic data and event triggers to the main control unit; the main control unit sends control commands to the active signal injection module to form an active detection link; the signal response analysis module feeds back the calculated impedance characteristics to the main control unit; the bidirectional interaction between the main control unit and the fault feature database enables feature matching and diagnostic judgment.

[0036] S102: Extract the instantaneous value sequence of the live wire to neutral wire voltage within the preset time window, and calculate the total harmonic distortion score, voltage event score, and fundamental frequency offset score based on the instantaneous value sequence.

[0037] In S102 above, after continuously acquiring the plug-in status signal and power supply line voltage, the power grid environmental quality is analyzed to achieve dynamic adaptive threshold adjustment, thereby overcoming the problem of frequent false alarms of static thresholds in complex power grid environments in existing technologies. The instantaneous value sequence of the live-to-neutral voltage within a preset time window is extracted. Based on the instantaneous value sequence, the total harmonic distortion score, voltage event score, and fundamental frequency offset score are calculated. Specifically, this includes: performing a fast Fourier transform on the instantaneous value sequence to obtain the spectrum, extracting the fundamental amplitude and harmonic amplitudes from the spectrum, calculating the real-time total harmonic distortion based on the fundamental amplitude and harmonic amplitudes; calculating the difference between the real-time total harmonic distortion and the reference total harmonic distortion, comparing the difference with multiple preset deviation thresholds, and obtaining the total harmonic distortion score based on the comparison results; calculating the effective voltage value corresponding to the instantaneous value sequence, and when the effective voltage value exceeds the preset threshold... When the rated voltage is at its upper and lower limits, it is recorded as a voltage event; when the absolute value of the instantaneous value sequence exceeds the preset transient peak threshold, it is recorded as a transient overvoltage event; the total number of voltage events and transient overvoltage events within the preset time window is counted, and a voltage event score is calculated based on the total number of occurrences; the zero-crossing timestamps of consecutive zero-crossing points in the same direction are identified from the instantaneous value sequence, and the time difference between two adjacent zero-crossing timestamps is calculated as the real-time period, and the reciprocal of the real-time period is used as the real-time frequency; the maximum offset of the real-time frequency relative to the preset reference frequency within the preset time window is extracted, and a fundamental frequency offset score is calculated based on the maximum offset.

[0038] Specifically, the instantaneous value sequence of the live-to-neutral voltage within a preset time window is extracted. The length of the preset time window needs to be sufficient to cover multiple complete power frequency cycles to ensure statistical significance, while not being too long to avoid reducing real-time response capability. In actual implementation, the preset time window is usually set to 5 to 30 seconds. For example, 10 seconds is selected as a typical value, which can cover 500 complete cycles in a 50Hz power frequency environment. Within this time window, the live-to-neutral voltage is continuously collected at a sampling rate of 1000 times per second, obtaining a total of 10,000 instantaneous voltage values. These instantaneous values ​​are arranged in chronological order to form an instantaneous value sequence, denoted as V(t1), V(t2), ..., V(t10000). This sequence completely records the waveform details of the live-to-neutral voltage within this time window.

[0039] A Fast Fourier Transform (FFT) is performed on the instantaneous value sequence to obtain spectral information. The FFT decomposes a time-domain signal into a superposition of different frequency components. In practice, the main control unit calls the built-in FFT library to perform FFT transformation on 10,000 sampling points. Since the actual AC voltage signal is a real number sequence, the spectrum obtained after the FFT transformation has conjugate symmetry. Therefore, only the first 5,000 frequency points need to be analyzed to obtain complete frequency information. The transformed spectrum is represented in complex form, with each frequency point corresponding to the amplitude and phase of a specific frequency. The amplitude spectrum of each frequency component is obtained by calculating the modulus of the complex number. In a standard 50Hz power supply system, the fundamental frequency is 50Hz, corresponding to the 50th frequency point in the spectrum (assuming a frequency resolution of 1Hz). The amplitude of this frequency point is the fundamental amplitude, denoted as A1. Simultaneously, it is necessary to extract the amplitude of each harmonic. Harmonics are frequency components that are integer multiples of the fundamental frequency. Common harmonics include the 2nd harmonic (100Hz), 3rd harmonic (150Hz), 5th harmonic (250Hz), and so on, up to higher harmonics. The amplitudes at the 100th, 150th, and 250th frequency points in the spectrum are read sequentially and denoted as A2, A3, A5, etc., respectively. To accurately calculate the total harmonic distortion, it is usually necessary to extract the amplitudes of at least the first 40 harmonics, covering a frequency range from DC to 2000Hz. These harmonic amplitudes collectively reflect the degree to which the grid voltage waveform deviates from the ideal sine wave.

[0040] Based on the extracted fundamental amplitude and harmonic amplitudes, the real-time total harmonic distortion (THD) is calculated. THD is an important indicator for measuring the power quality of the power grid, defined as the ratio of the square root of the sum of the squares of the effective values ​​of all harmonic components to the effective value of the fundamental frequency. The specific calculation formula is as follows: Where A2 to A40 represent the amplitudes of the 2nd to 40th harmonics, respectively, and A1 is the fundamental amplitude. For example, assuming that the fundamental amplitude A1 is 311V (corresponding to 220V RMS), the 2nd harmonic amplitude A2 is 15V, the 3rd harmonic amplitude A3 is 20V, the 5th harmonic amplitude A5 is 10V, and the amplitudes of the other higher harmonics are all less than 5V, then the sum of the squares of the RMS values ​​of the harmonic components is 15² + 20² + 10² + the sum of the squares of the remaining harmonics. Assuming the total sum is 900, then THD = 9.6%. This real-time total harmonic distortion reflects the harmonic pollution level of the power grid voltage at the current moment. The larger the value, the worse the power grid quality and the more severe the voltage waveform distortion.

[0041] Since the absolute value of real-time total harmonic distortion (THD) cannot accurately assess the degree of anomaly in the power grid environment, as the background harmonic levels of the power grid vary greatly in different regions and at different times, a baseline THD concept is introduced to achieve adaptive assessment. This baseline value represents the real-time THD of the live wire to neutral wire voltage continuously calculated within a preset initialization period after the charging pile is first powered on or restarted. The average or stable value within the preset initialization period is extracted as a background reference for the power grid environment in which the charging pile is located. In practice, the preset initialization period is usually set to 5 to 30 minutes, for example, 15 minutes. During this period, the real-time THD is calculated every 10 seconds, resulting in 90 THD sample values. These 90 sample values ​​are statistically analyzed, and after removing significantly outliers, the arithmetic mean is calculated to obtain the baseline THDbase.

[0042] Next, the difference between the real-time total harmonic distortion (THD) and the baseline THD is calculated. This difference reflects the degree of deviation of the current power grid environment from the background level and is the core basis for judging whether the power grid condition is abnormal. The formula for calculating the difference is ΔTHD = THD - THDbase. When ΔTHD is positive, it indicates that the harmonic pollution level of the current power grid is higher than the average level, and the power grid quality is declining. When ΔTHD is negative, it indicates that the power grid quality is better than the average level. The calculated difference ΔTHD is compared with several preset deviation thresholds. These preset deviation thresholds are pre-set based on power grid quality standards and actual engineering experience, and usually include three levels of thresholds to distinguish between slight deviation, moderate deviation, and severe deviation. For example, a first deviation threshold of 2%, a second deviation threshold of 5%, and a third deviation threshold of 10% can be set. When ΔTHD is less than 2%, the power grid environment is considered normal, and a total harmonic distortion (THD) score of 0 is assigned, indicating that no additional safety margin is needed. When ΔTHD is between 2% and 5%, it is considered a slight deviation, and a THD score of 10 is assigned. When ΔTHD is between 5% and 10%, it is considered a moderate deviation, and a THD score of 25 is assigned. When ΔTHD exceeds 10%, it is considered a severe deviation, and a THD score of 50 is assigned. If a certain data acquisition and calculation yields a real-time THD of 15.8% and a baseline THD base of 8.2%, then ΔTHD = 15.8% - 8.2% = 7.6%. This difference falls within the range of 5% to 10%, resulting in a THD score of 25. This score quantifies the degree of abnormality in the power grid harmonic environment.

[0043] After calculating the total harmonic distortion (THD) score, it is necessary to evaluate the stability of the grid voltage from a time-domain perspective. This is achieved by calculating the voltage event score. The voltage event score reflects the fluctuations and transient anomalies of the grid voltage within a preset time window. It complements the THD score, which reflects waveform distortion in the frequency domain, and together they constitute a comprehensive assessment of the grid environment. First, the effective voltage value corresponding to the instantaneous value sequence is calculated. The effective voltage value is a standard physical quantity for evaluating the amplitude of AC voltage. The calculation method is to average the squares of the instantaneous voltage values ​​within a complete cycle and then take the square root. In actual implementation, since the preset time window covers multiple cycles, the system uses a sliding window method to calculate the effective voltage value cycle by cycle. For example, for a 50Hz power frequency signal, each cycle is 20ms. With a window length of 20ms, 20 sampling points are extracted from the beginning of the instantaneous value sequence, and the effective value of these 20 points is calculated as the effective voltage value Vrms1 of the first cycle. Then the window slides forward one cycle, and the effective voltage value Vrms2 of the second cycle is calculated by extracting the 21st to 40th sampling points. And so on. A total of 500 effective voltage values ​​are calculated within a 10-second time window. After calculating the effective voltage value for each cycle, the effective voltage value is immediately compared with the preset upper and lower limits of the rated voltage. The preset upper and lower limits of the rated voltage are set according to the State Grid standard. For a single-phase power supply system with a nominal voltage of 220V, the preset lower limit of the rated voltage is usually set to 198V, and the preset upper limit of the rated voltage is set to 242V. When the effective voltage value of a certain cycle is lower than 198V or higher than 242V, it is considered that a voltage event has occurred in that cycle, and the voltage event counter is incremented by 1. For example, within a 10-second time window, if out of 500 cycles of effective voltage values ​​calculated by the system, 8 cycles have effective values ​​lower than 198V and 5 cycles have effective values ​​higher than 242V, then a total of 13 voltage events have occurred within that time window. These voltage events reflect the continuous deviation of the power supply amplitude from the grid.

[0044] In addition to deviations from the effective voltage value, transient overvoltage events also need to be detected. Transient overvoltage refers to a sharp spike in the instantaneous voltage value that occurs within a very short time. These events are usually caused by lightning strikes, switching operations, or load changes. They are short in duration but high in amplitude, which can cause impact damage to the electronic components of the charging pile and interfere with the accurate detection of grounding faults. Transient overvoltage events are identified by checking whether the absolute value of each sampling point in the instantaneous value sequence exceeds a preset transient peak value threshold. The preset transient peak value threshold is usually set to 1.5 to 2 times the rated peak value. For an AC voltage with an effective value of 220V, the theoretical peak value is 311V, and the preset transient peak value threshold can be set to 450V or higher. When the absolute value of the instantaneous voltage at a sampling point is detected to exceed 450V, a transient overvoltage event is determined to have occurred at that moment, and the transient overvoltage event counter is incremented by 1. To avoid the same transient overvoltage pulse being counted repeatedly, an event merging window is set. When multiple consecutive sampling points exceed the threshold and the time interval is less than 2ms, it is counted as only one event. For example, within a 10-second time window, three obvious voltage spikes were detected at the 2.3-second, 5.7-second, and 8.9-second intervals, respectively. The instantaneous values ​​of these spikes reached 480V, 510V, and 470V, respectively, all exceeding the preset transient peak value threshold of 450V. Therefore, the transient overvoltage event counter recorded 3 instances.

[0045] The total number of voltage events and transient overvoltage events within the preset time window was counted. In the aforementioned example, voltage events occurred 13 times, and transient overvoltage events occurred 3 times, for a total of 16 occurrences. To reasonably quantify the impact of different types of events, the number of occurrences for each event type was weighted and summed with their corresponding weights to calculate the voltage event score. The weights of voltage events and transient overvoltage events were set based on the degree of interference with ground fault detection and the level of safety risk. Generally, the weight of transient overvoltage events was higher than that of voltage events because transient overvoltages not only affect detection accuracy but may also damage equipment. For example, the weight of a single voltage event could be set to 1 point, and the weight of a single transient overvoltage event to 3 points. Then, the voltage event score would be 13 × 1 + 3 × 3 = 22 points. This score reflects the severity of the grid voltage fluctuation within the preset time window. A higher score indicates a more unstable grid, requiring a more conservative ground fault detection threshold to avoid false alarms.

[0046] After calculating the voltage event score, it is also necessary to evaluate the stability of the grid fundamental frequency, which is achieved by calculating the fundamental frequency offset score. Grid frequency is an important parameter for measuring the balance between power generation and consumption in the grid. Frequency offset reflects grid load fluctuations or power source disturbances. Frequency instability leads to irregular voltage waveform periods, affecting the accuracy of voltage analysis based on periodic characteristics, and consequently interfering with the accurate judgment of ground faults. Real-time frequency is measured by identifying the zero-crossing timestamps of consecutive zero-crossing points in the instantaneous value sequence. A zero-crossing point is the moment when the instantaneous voltage value changes from positive to negative or vice versa. In an ideal sine wave, the time interval between adjacent zero-crossing points in the same direction is equal to the signal period. Linear interpolation is used to accurately locate the zero-crossing timestamp. This involves traversing the instantaneous value sequence; when two adjacent sampling points V(ti) and V(ti+1) are detected to have opposite signs, it indicates a zero-crossing has occurred between these two sampling points. The precise time of the zero-crossing is calculated using linear interpolation. The interpolation formula is Tzero = ti + |V(ti)| / (|V(ti)| + |V(ti+1)|) × Δt, where Δt is the sampling interval, i.e., 1 ms. For example, if V(ti) = 5V, V(ti+1) = -3V, and ti = 2.345 seconds, then the zero-crossing timestamp Tzero = 2.345 + 5 / (5 + 3) × 0.001 = 2.345625 seconds. All zero-crossings are identified sequentially and their timestamps recorded. Then, consecutive zero-crossings in the same direction are selected. Zero-crossings in the same direction refer to zero-crossings with the same zero-crossing direction.

[0047] For example, in a positive or negative zero-crossing sequence, adjacent zero-crossing points in the same direction span a complete cycle. The time difference between the timestamps of two adjacent zero-crossing points in the same direction is calculated as the real-time period of that cycle. For example, if the first positive zero-crossing timetamp is 2.345625 seconds and the second positive zero-crossing timetamp is 2.365598 seconds, then the real-time period T = 2.365598 - 2.345625 = 0.019973 seconds, or 19.973 ms. The reciprocal of the real-time period is taken as the real-time frequency, i.e., f = 1 / T = 1 / 0.019973 ≈ 50.068 Hz. This real-time frequency reflects the instantaneous frequency value within that cycle.

[0048] The real-time frequency for each cycle is continuously calculated within a preset time window. Approximately 500 real-time frequency samples are obtained within a 10-second time window. The maximum deviation of these real-time frequencies relative to a preset reference frequency is extracted as a quantitative indicator of frequency fluctuation. The preset reference frequency is the nominal frequency of the power grid, which is 50Hz in China and most countries, and 60Hz in North America. The maximum deviation is calculated by iterating through all real-time frequency samples and finding the value that deviates the furthest from the preset reference frequency. The maximum deviation is defined as Δfmax = max(|f1-50|, |f2-50|, ..., |f500-50|), where f1 to f500 are the real-time frequencies for each cycle. For example, if within a certain time window, most of the 500 real-time frequencies detected are distributed between 49.95Hz and 50.05Hz, but there is one outlier at 50.35Hz and another outlier at 49.58Hz, then the maximum offset Δfmax = max(|50.35-50|,|49.58-50|) = 0.42Hz. This maximum offset reflects the maximum fluctuation range of the power grid frequency.

[0049] The fundamental frequency offset score is calculated based on the maximum offset. The calculation method involves multiplying the maximum offset by a frequency penalty coefficient to obtain a frequency deduction score. This deduction score is then subtracted from a preset base score to arrive at the final fundamental frequency offset score. The preset base score is typically set to 100 points to represent an ideal frequency stability state. The frequency penalty coefficient is set according to power grid standards and engineering experience; for example, it can be set to deduct 10 points for every 0.1Hz offset. In the example above, if the maximum offset is 0.42Hz, the frequency deduction score = 0.42 / 0.1 × 10 = 42 points, and the fundamental frequency offset score = 100 - 42 = 58 points. If the power grid frequency is very stable, with a maximum offset of only 0.05Hz, the frequency deduction score = 0.05 / 0.1 × 10 = 5 points, and the fundamental frequency offset score = 100 - 5 = 95 points. To avoid negative scores, a lower limit of 0 points is set; that is, when the frequency deduction score exceeds the preset base score, the fundamental frequency offset score is forcibly set to 0. This score reflects the stability of the power grid frequency; a higher score indicates greater frequency stability, while a lower score indicates greater frequency fluctuations, requiring a more conservative strategy in ground fault detection. Through the complete power grid environment analysis process described above, three dimensions of power grid quality assessment indicators were obtained: total harmonic distortion score, voltage event score, and fundamental frequency offset score.

[0050] S103: The total harmonic distortion score, voltage event score, and fundamental frequency offset score are weighted and summed to obtain the total grid environment score. The grid environment mode of the charging pile is determined based on the total grid environment score, and the corresponding safety threshold, recovery threshold, anomaly confirmation time, and recovery confirmation time are determined based on the grid environment mode.

[0051] In step S103 above, after obtaining the total harmonic distortion score, voltage event score, and fundamental frequency offset score, a weighted sum is calculated to obtain the total power grid environment score. The reason for using a weighted sum instead of a simple arithmetic average is that the impact of different dimensions of power grid quality problems on ground fault detection varies. Setting reasonable weighting coefficients can more accurately reflect the overall power grid quality level. Preset weighting coefficients are read from the configuration memory. These coefficients are determined based on statistical analysis of numerous practical cases and power grid standard requirements. Typically, the total harmonic distortion weighting coefficient is set to 0.4, the voltage event weighting coefficient to 0.35, and the fundamental frequency offset weighting coefficient to 0.25. This weighting allocation reflects the primary impact of harmonic distortion on waveform analysis accuracy while also taking into account the secondary interference effects of voltage fluctuations and frequency offsets. Then, a weighted summation calculation is performed, with the formula: Total Power Grid Environment Score = Total Harmonic Distortion Score × 0.4 + Voltage Event Score × 0.35 + Fundamental Frequency Offset Score × 0.25. In this formula, the fundamental frequency offset score has the opposite meaning to the other two scores. This is because a higher fundamental frequency offset score indicates a more stable frequency, i.e., better power grid quality, while higher total harmonic distortion score and voltage event score indicate worse power grid quality. To unify the meaning of the scores, the fundamental frequency offset score is converted into a frequency anomaly score in actual calculations. The conversion formula is: Frequency Anomaly Score = 100 - Fundamental Frequency Offset Score. In this way, all sub-scores follow the unified rule that a higher score indicates a worse power grid quality.

[0052] For example, a charging pile might have a total harmonic distortion score of 25, a voltage event score of 22, and a fundamental frequency offset score of 58 within a certain time window. First, the fundamental frequency offset score is converted to a frequency anomaly score (100 - 58 = 42). Then, a weighted summation is performed, resulting in a total grid environment score of 25 × 0.4 + 22 × 0.35 + 42 × 0.25 = 28.2. This total grid environment score comprehensively reflects the overall quality level of the grid environment in which the charging pile is located. A higher score indicates a more severe grid environment, with more serious problems such as harmonic pollution, voltage fluctuations, and frequency instability, and greater interference with grounding fault detection.

[0053] Furthermore, after calculating the total grid environment score, the continuous total grid environment score is converted into a discrete grid environment mode classification, dividing the grid environment modes into severe grid environment modes and normal grid environment modes. The grid environment mode of the charging pile is determined based on the total grid environment score, and the corresponding safety threshold, recovery threshold, anomaly confirmation time, and recovery confirmation time are determined based on the grid environment mode. Specifically, this includes: comparing the total grid environment score with the severe environment score threshold and the normal environment score threshold, where the severe environment score threshold is greater than the normal environment score threshold; when the total grid environment score is greater than the severe environment score threshold, the charging pile is determined to be in a severe grid environment mode; when the charging pile is in a severe grid environment mode, and the total grid environment score calculated for a consecutive preset number of times is less than or equal to the normal environment score threshold, the charging pile is determined to switch to a normal grid environment mode; matching the corresponding basic safety threshold, basic recovery threshold, anomaly confirmation time, and recovery confirmation time according to the grid environment mode of the charging pile; obtaining the voltage ratio sequence within a preset historical time period, and calculating the basic recovery threshold and basic safety threshold based on the voltage ratio sequence to obtain the safety threshold and recovery threshold.

[0054] Specifically, the values ​​of the severe environment score threshold and the normal environment score threshold are determined based on statistical analysis of a large amount of field test data. This requires comprehensive consideration of power grid quality standards, the anti-interference capability of the charging pile equipment, and the sensitivity characteristics of the ground fault detection algorithm. Typically, the severe environment score threshold is set to 40 points, and the normal environment score threshold is set to 25 points. The 15-point difference between the two constitutes a transition range, which is a key design feature for achieving stable mode switching. These two preset thresholds are read from the configuration memory, and the currently calculated total power grid environment score is compared step-by-step with the two thresholds. First, it is determined whether the total power grid environment score is greater than the severe environment score threshold. This is the primary condition for determining whether the charging pile is in a severely deteriorated power grid environment. When the total power grid environment score is greater than the severe environment score threshold, it indicates that the power grid environment where the charging pile is located suffers from severe harmonic pollution, frequent voltage fluctuations, and significant frequency shifts. Continuing to use conventional ground fault detection parameters under such severe conditions will lead to frequent false alarms, indicating that the charging pile is in a severe power grid environment mode. For example, suppose a charging pile gets a total score of 45 points for the power grid environment in a certain calculation. This score exceeds the severe environment score threshold of 40 points. The charging pile is immediately determined to enter or maintain a severe power grid environment mode, and the mode identifier is written into the system status register. At the same time, the severe environment response strategy is activated, including conservative measures such as raising the safety threshold and extending the confirmation time.

[0055] However, the power grid environment is not static. Over time and with load changes, a previously poor power grid environment may gradually improve and return to normal. It's necessary to be able to identify this improvement trend promptly and adjust the operating mode accordingly. However, simply setting a switch back to normal mode when the total power grid environment score falls below a certain threshold could lead to frequent switching between the two modes when the power grid environment quality fluctuates significantly. This frequent switching not only affects stability but also causes drastic changes in detection parameters, leading to other problems. To resolve this contradiction, the charging pile is only allowed to switch to normal power grid environment mode when it is in the poor power grid environment mode and the total power grid environment score calculated for a consecutive preset number of times is less than or equal to the normal environment score threshold. The consecutive preset number of times is a crucial time constant used to filter out short-term fluctuations in the power grid environment, ensuring that the mode is switched only when the environment is continuously improving. In practice, the consecutive preset number of times can be set to 3 to 5 times. For example, setting it to 3 times means that the total power grid environment score calculated for 3 consecutive times must be less than or equal to the normal environment score threshold of 25 points before switching from the poor power grid environment mode to the normal power grid environment mode.

[0056] When the charging station is currently in a poor power grid environment mode, after each new total power grid environment score is obtained, it is first checked whether the new total power grid environment score is less than or equal to the normal environment score threshold. If so, the mode switching counter is incremented by 1; otherwise, the mode switching counter is reset to zero. When the value of the mode switching counter reaches a preset number of consecutive times, such as 3 times, it is further checked whether the total power grid environment scores of the most recent 3 times in the historical score buffer are indeed less than or equal to 25 points. If the check passes, it is officially determined that the charging station has switched to the normal power grid environment mode, the mode identifier is updated to normal mode, and the mode switching counter is reset to zero for the next use. For example, suppose a charging pile is currently in a poor power grid environment mode. In the Nth calculation, the total power grid environment score is 42 points, which is still greater than the poor environment score threshold of 40 points, maintaining the poor mode. In the N+1th calculation, the total power grid environment score drops to 32 points, which is lower than the poor environment score threshold but higher than the normal environment score threshold of 25 points. At this time, the mode switching counter remains at 0. In the N+2nd calculation, the total power grid environment score further drops to 22 points, which is lower than the normal environment score threshold. The system increments the mode switching counter by 1 to 1. In the N+3rd calculation, the total power grid environment score is 20 points, which is again lower than the normal environment score threshold. The counter is incremented by 1 to 2. In the N+4th calculation, the total power grid environment score is 23 points, which is still lower than the normal environment score threshold. The counter is incremented by 1 to 3, reaching the preset number of consecutive calculations. At this time, it is checked that the scores of the last 3 calculations are all less than or equal to 25 points. The check passes, and the power grid environment mode of the charging pile is officially switched from the poor power grid environment mode to the normal power grid environment mode.

[0057] When the total grid environment score is greater than or equal to the normal environment score threshold and less than or equal to the severe environment score threshold, a strategy is adopted to maintain the current grid environment mode of the charging pile unchanged. This rule is designed to avoid frequent mode switching when the grid environment quality is at a moderate level, utilizing the transition range between the two thresholds to create hysteresis characteristics and improve the stability of mode determination. Specifically, when the total grid environment score falls within the transition range of 25 to 40 points, if the charging pile is currently in a severe grid environment mode, it continues to maintain the severe mode; if it is currently in a normal grid environment mode, it continues to maintain the normal mode. The mode switching determination process is only triggered when the total grid environment score clearly exceeds the boundary of this range. For example, suppose a charging pile is currently in a severe grid environment mode and obtains a total grid environment score of 35 points in a certain calculation. Although this score is lower than the severe environment score threshold of 40 points, it is still higher than the normal environment score threshold of 25 points and falls within the transition range. According to the maintenance strategy, the severe grid environment mode will remain unchanged, and the mode switching counter will not be activated. Similarly, if a charging pile is currently in normal power grid environment mode, and its total power grid environment score in a certain calculation is 30 points, falling within the transition range, the normal power grid environment mode will also be maintained. This hysteresis mechanism effectively avoids the system repeatedly switching between the two modes when the power grid environment quality fluctuates slightly around a moderate level, ensuring the continuity and stability of the detection strategy.

[0058] After determining the power grid environment mode of the charging pile, the system matches corresponding basic safety thresholds, basic recovery thresholds, anomaly confirmation times, and recovery confirmation times based on the power grid environment mode. The basic safety thresholds and basic recovery thresholds are initial reference values ​​determined based on the power grid environment mode. They require dynamic correction based on actual voltage ratio characteristics to arrive at the final usable safety and recovery thresholds. This two-level adjustment mechanism considers both the macroscopic power grid environment mode and microscopic voltage characteristic changes, achieving more refined adaptive control. A mode parameter mapping table is pre-stored in non-volatile memory. This table uses the power grid environment mode as an index, with each mode corresponding to a set of basic parameter values. The mapping table design follows the principle of using conservative parameters for harsh environments and conventional parameters for normal environments.

[0059] The basic parameter set for the severe power grid environment mode is typically set as follows: basic safety threshold 0.88, basic recovery threshold 0.70, anomaly confirmation time 3s, and recovery confirmation time 15s. This set of parameters reflects a cautious response strategy to severe power grid environments. The higher basic safety threshold effectively filters out transient increases in ground voltage caused by severe harmonic distortion and voltage fluctuations, avoiding false alarms. The sufficient hysteresis margin between the basic recovery threshold and the basic safety threshold prevents repeated switching near the threshold. The longer anomaly confirmation time and recovery confirmation time can fully verify the continuity of voltage anomalies or recovery, eliminating the influence of transient interference. The basic parameter set for the normal power grid environment mode is typically set as follows: basic safety threshold 0.92V, basic recovery threshold 0.80V, anomaly confirmation time 1s, and recovery confirmation time 10s. This set of parameters reflects a detection strategy that pursues rapid response and high sensitivity in a good power grid environment. The basic safety threshold can promptly detect real ground faults to avoid missed detections. The basic recovery threshold ensures rapid power restoration after fault elimination, reducing service interruption time. The shorter confirmation time provides rapid fault response capability.

[0060] Based on the currently determined power grid environment mode, the corresponding basic parameter set is queried and read from the mode parameter mapping table. The query operation is implemented through index access, which has high execution efficiency. For example, if the charging pile is currently determined to be in a severe power grid environment mode, the basic safety threshold (0.88), basic recovery threshold (0.70), anomaly confirmation time (3s), and recovery confirmation time (15s) are read from the mapping table using the severe mode as the index, and these parameter values ​​are temporarily stored in the working register. If the charging pile is currently determined to be in a normal power grid environment mode, the basic safety threshold (0.92), basic recovery threshold (0.80), anomaly confirmation time (1s), and recovery confirmation time (10s) are read. It should be noted that the anomaly confirmation time and recovery confirmation time are directly determined based on the power grid environment mode in this embodiment and do not require subsequent dynamic correction, while the basic safety threshold and basic recovery threshold still need to be dynamically calculated based on the voltage ratio sequence to obtain the final safety threshold and recovery threshold.

[0061] Furthermore, to achieve dynamic threshold correction based on actual voltage characteristics, a voltage ratio sequence within a preset historical time period is obtained. This voltage ratio sequence is a crucial characteristic parameter reflecting the relative relationship between the charging pile's power supply line and ground voltage. The statistical characteristics of this sequence can reveal the impact of factors such as the neutral point grounding status and line distributed capacitance on the ground voltage. The preset historical time period is typically set to the most recent 10 to 30 minutes, for example, 20 minutes. Effective values ​​of the live-to-ground and neutral-to-ground voltages collected within this time period are extracted from the historical data buffer. During normal operation, the live-to-ground and neutral-to-ground voltages are continuously collected, and their effective values ​​are calculated per power frequency cycle. At a 50Hz power frequency, 50 effective value data points are generated per second. The 20-minute historical time period contains a total of 30,000 data point pairs, each containing one effective value of the live-to-ground voltage and one effective value of the neutral-to-ground voltage. The data point pairs are iterated through, and for each pair, the voltage ratio is calculated as follows: Voltage Ratio = Effective Value of Live Wire to Ground / Effective Value of Neutral Wire to Ground. This ratio reflects the relative magnitude of the voltage amplitudes of the live and neutral wires to ground. For example, assuming that at a certain moment the effective value of the live wire to ground is 12V and the effective value of the neutral wire to ground is 8V, then the voltage ratio at that moment is 12 / 8 = 1.5, indicating that the voltage of the live wire to ground is 1.5 times that of the neutral wire to ground. The voltage ratios of all 30,000 data point pairs are calculated sequentially, forming a voltage ratio sequence containing 30,000 elements. This sequence records the temporal changes of the voltage ratios within a preset historical time period.

[0062] Because the effective value of the neutral-to-ground voltage may be close to or even zero in actual calculations, direct division can lead to voltage ratios approaching infinity or producing numerical anomalies. To avoid this, before calculating the voltage ratio, the effective value of the neutral-to-ground voltage is checked to see if it is less than a preset minimum effective value threshold, typically set to 0.5V. If the effective value is less than 0.5V, the data point is skipped and the voltage ratio is not calculated. If it is greater than or equal to 0.5V, the voltage ratio is calculated normally and the result is added to the voltage ratio sequence. Furthermore, to filter out abnormal data points, the calculated voltage ratios are checked for reasonableness. Typically, the voltage ratio should be within the range of 0.1 to 10. If a voltage ratio exceeds this range, the data point is considered abnormal and removed from the voltage ratio sequence. After the above data preprocessing, a valid voltage ratio sequence is obtained, which may have slightly fewer elements than the original number of data point pairs.

[0063] The basic recovery threshold and basic safety threshold are calculated based on the voltage ratio sequence to obtain the safety threshold and recovery threshold. Specifically, this includes: calculating the standard deviation of the voltage ratio sequence; calculating the ratio of the total grid environment score to the benchmark environment score to obtain the environmental degradation coefficient; multiplying the environmental degradation coefficient by the basic first factor to obtain the first adjustment factor; subtracting the product of the voltage ratio standard deviation and the first adjustment factor from the basic safety threshold to obtain the safety threshold; multiplying the environmental degradation coefficient by the basic second factor and adding the hysteresis compensation constant to obtain the second adjustment factor; and adding the product of the voltage ratio standard deviation and the second adjustment factor to the basic recovery threshold to obtain the recovery threshold.

[0064] Specifically, the standard deviation of the voltage ratio sequence is calculated. This standard deviation is a crucial statistic reflecting the dispersion of the voltage ratio sequence; its magnitude reveals the stability or volatility of the relative relationship between the live-wire to ground voltage and the neutral-wire to ground voltage over time. A smaller standard deviation indicates that the voltage ratio remains relatively stable within a preset historical time period, with little change in the ratio between the live and neutral-wire to ground voltages. This typically signifies a stable power grid operation and smooth load changes. In this case, a relatively fixed detection threshold can be used without concern about misjudgments due to voltage ratio fluctuations. Conversely, a larger standard deviation indicates drastic voltage ratio fluctuations and frequent changes in the relative relationship between the live and neutral-wire to ground voltages. This may be caused by factors such as frequent power grid load switching, changes in distributed capacitance, or unstable neutral grounding. In such cases, a more significant adjustment to the detection threshold is needed to accommodate the dynamic range of voltage ratio changes, avoiding missed detections or false alarms due to improper threshold settings. The standard deviation of the voltage ratio sequence is calculated using standard statistical methods. The calculation process consists of two steps. First, the mean of the voltage ratio sequence is used as a central reference point, and the summation of all elements in the sequence yields the average voltage ratio. Second, the square root of the average of the sum of squared deviations of each voltage ratio from the mean is taken to obtain the standard deviation. The squared deviations of each voltage ratio from the mean are calculated, and then all squared deviations are summed to obtain the total sum of squared deviations. This total sum of squared deviations is divided by the number of elements to obtain the variance, and then the square root of the variance is taken to obtain the standard deviation. For example, if the calculated total sum of squared deviations is 11300, the variance is 0.2, and the standard deviation σ = 0.447. This standard deviation indicates that the average deviation of each element in the voltage ratio sequence from the mean is approximately 0.447, reflecting the fluctuation range of the voltage ratios.

[0065] After calculating the standard deviation of the voltage ratio, the environmental degradation coefficient is further calculated to quantify the degree of deterioration of the current power grid environment relative to the baseline state. The environmental degradation coefficient is a dimensionless coefficient calculated by comparing the total power grid environmental score with the baseline environmental score. This coefficient directly reflects the deviation of the current power grid quality from the reference baseline. The baseline environmental score is a pre-set reference value representing an ideal or acceptable level of power grid environmental quality. Typically, the baseline environmental score is set to the midpoint or slightly lower of the normal environmental score threshold. For example, if the normal environmental score threshold is 25, the baseline environmental score can be set to 20. This value indicates that when the total power grid environmental score is 20, the power grid quality is considered to be at a normal level and no additional threshold adjustment is needed. When the total power grid environmental score exceeds 20, it indicates a decline in power grid quality, requiring corresponding adjustments to the threshold based on the degree of deviation. The environmental degradation coefficient is obtained by dividing the currently calculated total power grid environmental score by the baseline environmental score. For example, assuming the current power grid environment score is 21.2 points and the baseline score is 20 points, the environmental degradation coefficient is 28.2 / 20 = 1.06. An environmental degradation coefficient greater than 1 indicates that the current power grid environment quality is lower than the baseline level, with a degradation degree of 1.06 times the baseline level. If the total power grid environment score is 42 points, the environmental degradation coefficient is 42 / 20 = 2.1, indicating that the power grid environment degradation degree reaches 2.1 times the baseline level. In this case, a more significant adjustment to the detection threshold is needed to adapt to the harsh environment. Conversely, if the total power grid environment score is 15 points, lower than the baseline score, the environmental degradation coefficient is 15 / 20 = 0.75, less than 1, indicating that the current power grid environment quality is better than the baseline level. Theoretically, the detection threshold can be lowered to increase sensitivity. However, considering safety, the lower limit of the environmental degradation coefficient is usually limited, for example, to 0.8. That is, even if the power grid environment is very good, the threshold is not excessively lowered to retain the necessary safety margin.

[0066] The calculated environmental degradation coefficient is converted into an adjustment factor that actually affects the threshold adjustment. For adjusting the safety threshold, the environmental degradation coefficient is multiplied by a basic first factor to obtain the first adjustment factor. The basic first factor is a pre-calibrated coefficient parameter used to control the intensity of the environmental degradation coefficient's influence on the safety threshold adjustment. The value of this parameter needs to be determined comprehensively based on the actual usage scenario of the charging pile, power grid characteristics, and safety requirements. Typically, the basic first factor is set between 0.3 and 0.6, for example, 0.40. The design logic of this parameter is that when the power grid environment deteriorates, i.e., the environmental degradation coefficient increases, the first adjustment factor increases accordingly, thus increasing the adjustment range of the safety threshold. However, this adjustment is not strictly linearly proportional to the environmental degradation coefficient, but rather moderately scaled by the basic first factor to avoid excessive adjustment range causing the threshold to deviate from a reasonable range. For example, assuming the environmental degradation coefficient is 1.06 and the basic first factor is 0.40, then the first adjustment factor = 1.06 × 0.40 = 0.424. This first adjustment factor will be used as a weighting coefficient for the standard deviation of the voltage ratio in subsequent calculations to determine the degree of influence of voltage ratio fluctuations on the safety threshold.

[0067] The final safety threshold is obtained by subtracting the product of the voltage ratio standard deviation and the first adjustment factor from the basic safety threshold. Since the voltage ratio standard deviation reflects the volatility of the voltage ratio rather than its absolute level, drastic voltage ratio fluctuations indicate an unstable relative relationship between the live and neutral voltages to ground. At certain times, the live voltage to ground may be significantly higher than the neutral voltage to ground, and vice versa. This volatility makes it difficult for detection logic based on a fixed threshold to accurately determine the fault state. Therefore, it is necessary to appropriately lower the safety threshold to cover the lower limit of voltage ratio fluctuations and avoid missing real grounding faults when the voltage ratio is at a low point. For example, if the basic safety threshold corresponding to the charging pile's current normal power grid environment mode is 0.92, the calculated voltage ratio standard deviation is 0.447, and the first adjustment factor is 0.424, then the safety threshold = 0.92 - 0.447 × 0.424 = 0.73, and the safety threshold is 0.73. If the basic safety threshold for a charging pile operating in a harsh power grid environment is 0.88, the calculated standard deviation of the voltage ratio is 0.447, and the first adjustment factor is 0.424, then the safety threshold = 0.88 - 0.447 × 0.424 = 0.69, and therefore the safety threshold is 0.69. It is important to note that the calculated safety threshold will be validated for reasonableness to ensure that it does not deviate excessively from the basic safety threshold, thus preventing the detection strategy from failing.

[0068] The calculation logic for the recovery threshold is similar to that for the safety threshold, but there are significant differences in the adjustment direction and additional compensation. First, a second adjustment factor is calculated for the recovery threshold. This factor is obtained by multiplying the environmental degradation coefficient by the basic second factor and then adding a hysteresis compensation constant. Similar to the basic first factor, the basic second factor is a pre-calibrated coefficient parameter used to control the influence of the environmental degradation coefficient on the recovery threshold adjustment. However, the value of the basic second factor is usually smaller than the basic first factor to ensure a difference in the adjustment range between the safety threshold and the recovery threshold, avoiding insufficient hysteresis margin due to their excessive proximity. Typically, the basic second factor is set between 0.2 and 0.4, for example, 0.25. The hysteresis compensation constant is a unique additional term in the recovery threshold calculation. Its purpose is to further increase the interval between the recovery threshold and the safety threshold on top of the basic adjustment of the environmental degradation coefficient, ensuring sufficient hysteresis margin between them to avoid frequent switching between fault and normal states caused by voltage fluctuations near the threshold. The value of the hysteresis compensation constant is determined according to the requirement of hysteresis margin, and is usually set between 0.1 and 0.3, for example, 0.15. The unit of this value is the same as that of the adjustment factor, which is a dimensionless coefficient.

[0069] For example, if the environmental degradation coefficient is 1.06, the basic second factor is 0.3, and the hysteresis compensation constant is 0.15, then the second adjustment factor = 1.06 × 0.25 + 0.15 = 0.415. This second adjustment factor will be used to calculate the recovery threshold. It is slightly smaller than the first adjustment factor of 0.424, but due to the presence of the hysteresis compensation constant, its absolute value remains at a high level.

[0070] The final recovery threshold is obtained by adding the standard deviation of the voltage ratio and the product of the second adjustment factor to the basic recovery threshold. Unlike the subtraction method used in the safety threshold calculation, the recovery threshold calculation uses addition. When the voltage ratio fluctuates significantly or the grid environment deteriorates, the recovery threshold needs to be increased, thus raising the threshold for determining that the fault has been eliminated. This ensures that the fault is only considered truly resolved when the voltage to ground has indeed dropped to a lower level. This conservative recovery strategy effectively avoids the risk of secondary faults caused by prematurely restoring power supply before the fault is completely eliminated or only temporarily improved. The addition method results in a larger increase in the recovery threshold when the standard deviation of the voltage ratio or the second adjustment factor is larger, reflecting a cautious response to unstable grid environments. At the same time, since the second adjustment factor includes a hysteresis compensation constant, the increase in the recovery threshold will be moderately higher than when only considering the environmental deterioration coefficient, thereby ensuring a stable hysteresis interval between the recovery threshold and the safety threshold.

[0071] For example, if the basic recovery threshold for a charging pile in a normal power grid environment is 0.80, the standard deviation of the voltage ratio is 0.447, and the second adjustment factor is 0.415, then the recovery threshold = 0.80 + 0.447 × 0.415 = 0.98. If the basic recovery threshold for a charging pile in a harsh power grid environment is 0.70, the standard deviation of the voltage ratio is 0.447, and the second adjustment factor is 0.415, then the recovery threshold = 0.70 + 0.447 × 0.415 = 0.88. In this example, because the standard deviation of the voltage ratio is small and the second adjustment factor is moderate, the calculated recovery threshold is very close to the basic recovery threshold, only slightly higher. After calculating the recovery threshold, the results also need to be verified for reasonableness to ensure that the finally determined safety threshold and recovery threshold can adapt to the actual characteristics of the power grid environment and meet the basic requirements of ground fault detection for threshold relationships.

[0072] S104: When the gun insertion status signal indicates that the gun is not inserted, calculate the voltage ratio between the live wire and the ground wire and the live wire and the neutral wire.

[0073] In S104 above, if the current charging gun status signal indicates an unplugged state, in a standard TN power supply system, when the charging pile is not connected to the vehicle, the live wire L, neutral wire N, and ground wire GND inside the charging pile form a relatively closed electrical environment. The neutral wire N and ground wire GND are grounded together at the neutral point of the power supply transformer. Ideally, the voltage between the neutral wire and ground should be close to zero volts, while the voltage between the live wire and ground should be approximately equal to the voltage between the live wire and neutral wire, with a ratio close to 1. The main control unit continuously monitors the logic level or value of the charging gun status signal. When the signal is in an unplugged state, such as a logic low level or a specific status code value, it determines that the timing conditions for performing the voltage ratio calculation are met. To ensure the reliability of the charging gun status determination and avoid calculations during the transient process of plugging and unplugging the charging gun, the charging gun status signal is typically required to remain stably in the unplugged state for more than a short de-jittering time, such as 200 milliseconds. Only when this condition is met does the voltage ratio calculation operation actually begin. This condition-triggered mechanism based on the insertion state ensures that the voltage ratio calculation occurs in a well-defined state, avoiding the introduction of additional errors or inconsistencies caused by calculations performed at uncertain moments during state transitions.

[0074] After confirming that the plug-in status signal indicates that the plug is not plugged in, the current live wire to ground voltage and live wire to neutral voltage are read from the voltage monitoring module. These two voltage values ​​are stable measurements obtained by the voltage acquisition unit in the above steps through a high-precision analog-to-digital converter and after digital filtering. They are usually stored in the data register in the form of RMS values ​​for the main control unit to read. The live wire to ground voltage refers to the AC voltage measured at the live wire L terminal relative to the ground wire GND terminal. The magnitude of this voltage directly reflects the potential status of the ground wire GND. When the ground wire is well grounded, the live wire to ground voltage should be close to the live wire to neutral voltage. When the ground wire is poorly grounded, this voltage will decrease accordingly due to the increased ground wire potential. The live-to-neutral voltage refers to the AC voltage measured at the live wire (L) terminal relative to the neutral wire (N) terminal. This voltage reflects the actual output voltage of the power supply. In a standard 220V AC power supply system, the live-to-neutral voltage is usually maintained at around 220V and fluctuates within a certain range depending on the power grid load and regulation. This voltage is used as a reference standard to normalize the measured value of the live-to-ground voltage.

[0075] The voltage ratio K is equal to the live wire to ground voltage U. LG Divide by the voltage U between the live wire and the neutral wire LN That is, K=U LG / U LN Division operations are performed in the arithmetic logic unit of the main control unit in the form of floating-point or fixed-point numbers. To ensure calculation accuracy, the system typically uses 32-bit floating-point numbers and retains the result to two decimal places. Before performing the division operation, the denominator, i.e., the voltage U between the live wire and the neutral wire, is calculated. LN Perform a validity check to ensure the value is not zero or too small to avoid division by zero errors or overflow in the calculation result. If a voltage U between the live wire and the neutral wire is detected... LN If the voltage is below a preset minimum threshold, such as 100V, the current power supply is deemed abnormal and unsuitable for voltage ratio calculation. The calculation will be skipped and retried in the next sampling period. Optionally, a power supply abnormality log entry will be recorded for fault analysis. This protective check mechanism ensures that voltage ratio calculations are always based on valid voltage measurement data, avoiding meaningless calculation results caused by power outages or measurement anomalies.

[0076] Under normal circumstances, when the voltage U between the live wire and the neutral wire... LN When within a reasonable range, the division operation is successfully completed to obtain the voltage ratio K. This voltage ratio is a dimensionless value, and its physical meaning is the ratio of the voltage between the live wire and the ground wire to the voltage between the live wire and the neutral wire. Under ideal conditions where the charging pile grounding system is intact, the ground wire GND maintains a good low-impedance connection with the earth, and the ground wire potential is stable at the earth potential, which is close to zero volts. At this time, the voltage U between the live wire and the ground wire is... LG It should be equal to the voltage U between the live wire and the neutral wire.LN Because the neutral wire is grounded at the neutral point of the power supply transformer, its potential is close to zero volts and the same as the ground wire potential. Therefore, the ideal voltage ratio K should be equal to 1. However, in actual engineering, due to the existence of grounding resistance, voltage drop in the neutral wire loop, and the influence of various distributed capacitances to the ground, even the normal voltage ratio K of the grounding system is usually slightly less than 1, generally fluctuating between 0.95 and 0.98. When a fault occurs in the grounding system of a charging pile, the impedance between the ground wire GND and the earth increases significantly. The unbalanced current flowing through the neutral wire loop will generate a voltage drop across the grounding impedance, causing the ground wire potential to rise relative to the earth potential. Since the voltage between the live wire and the ground wire is the difference between the live wire potential and the ground wire potential, and the voltage between the live wire and the neutral wire is the difference between the live wire potential and the neutral wire potential, when the ground wire potential rises while the neutral wire potential remains basically unchanged, the voltage between the live wire and the ground wire decreases relatively while the voltage between the live wire and the neutral wire remains unchanged. This results in a significant drop in the voltage ratio K to less than 0.95 or even lower. The magnitude of the drop is proportional to the increase in grounding impedance. This drop in voltage ratio is a typical electrical characteristic of grounding faults.

[0077] S105: If the voltage ratio is less than the safety threshold and the duration reaches the abnormal confirmation time, the charging pile will be placed in the ground fault lockout state and charging operation will be prohibited.

[0078] In step S105 above, the current power grid environment mode is first determined. The power grid environment mode reflects the quality status of the power supply grid. Different power grid environments have different characteristics such as voltage stability, harmonic content, and transient interference frequency. These characteristics directly affect the accuracy and stability of charging pile voltage monitoring. By calculating the instantaneous value sequence of the live wire to neutral wire voltage within the preset time window, it is determined whether the current power grid environment mode is normal or severe.

[0079] When the charging pile is determined to be in a normal power grid environment mode, it indicates that the current power grid quality is good and the signal-to-noise ratio of the voltage monitoring signal is high. Therefore, the safety threshold and anomaly confirmation duration are determined based on the normal power grid environment mode. The calculated voltage ratio is then compared with the safety threshold under the normal power grid environment mode. When the calculated voltage ratio is less than the safety threshold under the normal power grid environment mode, a timer is started to continuously monitor the duration of the abnormal state. This is to distinguish between transient disturbances and persistent faults. Transient disturbances (such as switching operations, lightning strikes, etc.) may cause the voltage ratio to drop in a very short time, but these disturbances usually disappear within milliseconds to hundreds of milliseconds, and the voltage ratio quickly returns to normal. True grounding faults, on the other hand, are caused by poor physical connections, broken grounding wires, corrosion of the grounding electrode, etc., manifesting as a continuous increase in the grounding loop impedance, and the corresponding abnormal voltage ratio will remain stable. Only when the voltage ratio is less than the safety threshold under the normal power grid environment mode, and the duration reaches the anomaly confirmation duration under the normal power grid environment mode, is the charging pile placed in a grounding fault lockout state, and all charging operations are prohibited.

[0080] In the example above, under normal power grid environment conditions, the safety threshold is set at 0.73, and the anomaly confirmation time is 3 seconds. If the real-time voltage ratio remains below 0.73 for 3 seconds, a ground fault is immediately identified and the system enters a locked state. Under normal power grid conditions, using a higher safety threshold and a shorter confirmation time demonstrates high sensitivity and rapid response, enabling early warning when the grounding system shows initial deterioration, effectively preventing further safety risks caused by the fault.

[0081] When a charging station is determined to be in a severe power grid environment, the quality issues of the power grid itself can significantly interfere with voltage monitoring. For example, severe harmonic distortion can cause waveform distortion of the live-to-neutral voltage, leading to deviations in the calculated effective value. Frequent voltage fluctuations and transient overvoltage events can cause nonlinear changes in the live-to-ground voltage within a short period. Even if the grounding system is intact, the monitored voltage ratio may drop significantly due to power grid interference. If the safety threshold under normal power grid conditions is still applied, these voltage ratio deviations caused by power grid quality issues will be misjudged as grounding faults, leading to frequent alarms or even service interruptions at the charging station, severely impacting availability. Therefore, safety thresholds and anomaly confirmation times are determined based on the severe power grid environment model. The calculated voltage ratio is then compared with the safety threshold under the adverse power grid environment mode. When the calculated voltage ratio is less than the safety threshold under the adverse power grid environment mode, a timer is started to continuously monitor the duration of the abnormal state. Only when the voltage ratio is less than the safety threshold under the adverse power grid environment mode and the duration reaches the abnormal confirmation time under the adverse power grid environment mode, the charging pile is placed in the ground fault lockout state and all charging operations are prohibited.

[0082] In the example above, under the harsh power grid environment mode, the safety threshold is set at 0.69 and the anomaly confirmation time is 5 seconds. If the real-time voltage ratio remains below 0.69 for 5 seconds, a ground fault is immediately identified and the system enters a locked state. In harsh power grid environments, by lowering the safety threshold and extending the confirmation time, the tolerance to inherent power grid interference is significantly improved, avoiding misjudging power grid quality problems as ground faults of the charging pile itself.

[0083] S106: When the charging pile is in a ground fault locked state, if the gun insertion status signal changes to "gun inserted", the ground fault locked state is maintained and charging is prohibited.

[0084] In S106 above, when the charging pile is placed in a ground fault locked state, the connection status of the charging gun is continuously monitored. This status monitoring is achieved through the charging pile's plug-in status detection module. This module determines the physical connection status of the charging gun by reading the control guide pin signal of the charging interface. In a standard electric vehicle AC charging system, the control guide pin signal is a key communication signal used to detect the connection status between the charging gun and the vehicle's charging interface, as well as the vehicle's charging readiness status. When the charging gun is not connected, the control guide pin signal is usually maintained at a high level (e.g., 12V), indicating that the charging interface is idle. When the charging gun is inserted into the vehicle's charging interface and the physical connection is completed, the control guide pin signal will be pulled down to an intermediate level (e.g., 9V or 6V) due to the resistive load at the vehicle end, indicating that the charging gun is connected but the vehicle is not yet ready to charge. When the vehicle completes the charging readiness and closes the input switch of the on-board charger, the control guide pin signal will be pulled down further to an even lower level (e.g., 3V), indicating that the vehicle is ready to receive charging. By continuously monitoring the level changes of the control guide pin signal, the connection status of the charging gun and the charging readiness status of the vehicle can be accurately determined.

[0085] When the charging station is in a ground fault lockout state, the charging gun status signal is continuously monitored. Once the signal changes from an unplugged state to a plugged state (i.e., the control pin signal is pulled down from a high level (e.g., 12V) to a mid-level or low level (e.g., 9V, 6V, or 3V), indicating that the user has plugged the charging gun into the vehicle's charging interface, the system will not reassess the voltage status and potentially unlock the fault as in existing technologies. Instead, the ground fault lockout state will be maintained, and all charging operations will continue to be prohibited. Ground faults detected in the unplugged state are considered inherent faults of the charging station itself. These faults are persistent and structural, usually caused by physical reasons such as poor grounding wire connection, grounding electrode corrosion, or grounding wire breakage. They cannot be repaired automatically by the user's plugging in. Therefore, even if the voltage monitoring parameters change or appear to return to normal after plugging in, this should not be considered evidence of fault elimination. Instead, it should be viewed with high suspicion that this may be a false recovery caused by abnormal connections at the vehicle end.

[0086] Furthermore, while maintaining the ground fault lockout state, clear fault information and operation instructions are conveyed to the user through the human-machine interface. This proactive and explicit safety guidance encourages users to take the correct countermeasures. In existing technologies, when a ground fault is detected, the user is typically notified only by flashing indicator lights on the charging pile or displaying a simple fault code on the screen. This method has significant limitations; ordinary users often cannot understand the specific meaning of the fault code and do not know what actions to take to address the fault. They may repeatedly try plugging and unplugging the charging gun, restarting the charging pile, or directly contacting customer service. These blind operations not only do not help solve the problem but may also introduce new safety risks if the charging pile's ground fault protection function fails. This application provides users with clear and actionable guidance information, enabling them to quickly understand the current safety status and know what actions to take. Specifically, this includes: when the charging pile is in a ground fault locked state and the charging gun status signal is "plugged in," outputting a ground fault alarm message through the charging pile's human-machine interface; simultaneously displaying a gun-unplugging guidance message on the human-machine interface to guide the user to unplug the charging gun; and when a change in the charging gun status signal is detected, confirming that the user has unplugged the charging gun according to the unplugging guidance message, and determining that the charging gun status signal has changed from "plugged in" to "not plugged in."

[0087] Specifically, upon detecting that the charging pile is in a ground fault locked state and the charging gun status signal is "plugged in," a ground fault alarm message is immediately output through the charging pile's human-machine interface. The charging pile's human-machine interface typically includes multiple output devices to adapt to different usage scenarios and user needs. The most common output device is an LCD screen mounted on the charging pile panel. This screen can be a monochrome character LCD, a color graphic LCD, or a more advanced touch-screen color LCD. The screen size is typically between 3.5 inches and 7 inches, capable of displaying sufficient text and graphic information. In addition to the screen, the charging pile is also equipped with multi-color LED indicators, typically using red, yellow, and green LEDs or RGB full-color LEDs, indicating the charging pile's operating status through different colors and flashing patterns. Furthermore, some high-end charging piles are equipped with a voice broadcast module, capable of playing voice prompts through a speaker to provide additional alarm notifications when the user is not paying attention to the display screen. For charging piles with network connectivity, alarm notifications can also be pushed to the user's smartphone via a companion mobile application, enabling remote information transmission.

[0088] The output of ground fault alarm information is achieved through the main control unit coordinating and controlling these human-machine interface devices. When the main control unit determines that ground fault alarm information needs to be output, it first sends a display command to the display controller. This command includes format information such as the text content to be displayed, font size, color, and position. After receiving the command, the display controller reads the corresponding character or graphic data from the display buffer of the main control unit and updates the display content of the screen through the LCD driving circuit. The design of the ground fault alarm information follows the principles of clarity, conspicuousness, and ease of understanding. In terms of text content, the alarm information uses concise and straightforward language to describe the fault status, such as "Warning: Grounding system fault detected!" or "Fault: Charging pile protection grounding abnormality," avoiding the use of technical jargon or complex technical descriptions to ensure that ordinary users can quickly understand it. In terms of display format, the alarm information uses a large font size and eye-catching colors (such as red or orange) to attract the user's attention. The alarm information is usually displayed in the upper half or center of the screen to ensure that the user can see it at first glance when approaching the charging pile.

[0089] Synchronized with the display output, the system also controls the LED indicator lights to switch to fault alarm mode. Charging stations are typically equipped with one or more multi-color LED indicator lights, which are positioned in prominent locations on the charging station, such as the top of the charging station, the center of the panel, or near the charging gun mount. When a ground fault alarm message is output, the main control unit sends a control signal to the LED driver circuit, setting the LED indicator lights to a rapid red flashing mode, for example, flashing at a frequency of 2 times per second. This rapid red flashing visual signal is widely used in the industry to indicate dangerous or serious fault conditions, allowing users to immediately notice the abnormality even when observing the charging station from a distance or from a side angle.

[0090] While outputting grounding fault alarm information, the system simultaneously displays a charging gun removal guidance message on the human-machine interface. This not only informs users of the fault but also clearly outlines the specific actions to take. The design of the removal guidance message follows the principle of behavioral guidance, using explicit action instructions rather than vague suggestions, such as "Please unplug the charging gun immediately" or "Please press and hold the charging gun unlock button and unplug the charging gun," prompting users to quickly perform the correct operation. To ensure effective communication of the removal guidance message, a multimodal output strategy is employed. In addition to displaying text and graphic guidance information on the screen, a voice broadcast module simultaneously broadcasts the guidance instructions. The voice content is consistent with the text content displayed on the screen, such as "Please unplug the charging gun immediately." This synchronization of voice broadcast and screen display enhances information delivery through both visual and auditory channels, significantly improving user reception and response speed. For push notifications sent to users' mobile phones, in addition to including the fault alarm information, the notification content also clearly states "Please unplug the charging gun immediately and check the charging pile grounding system," ensuring that users receiving the notification remotely also know the appropriate actions.

[0091] After outputting the gun removal guidance message, the charging station continuously monitors the gun insertion status signal to detect whether the user has responded to the guidance command and performed the gun removal operation. The monitoring of the gun insertion status signal is achieved through a gun insertion status detection module. This module continuously reads the signal level of the control guide pin of the charging interface. When the gun is inserted, the control guide pin signal remains at a mid-level or low level (e.g., 9V, 6V, or 3V). When the user presses the unlock button on the charging gun and removes the charging gun from the vehicle's charging interface, the physical connection between the charging gun and the vehicle's charging interface is broken. The control guide pin loses its load connection from the vehicle end, and the pin level quickly rises to a high level (e.g., 12V) under the action of the internal pull-up resistor. This level change is captured in real time by a high-speed analog-to-digital converter in the gun insertion status detection module. The analog-to-digital converter continuously collects the voltage value of the control guide pin at a high sampling rate and sends the sampled data to the main control unit for analysis.

[0092] The main control unit detects the transition of the gun insertion status signal by analyzing the time-series data of the control guide pin voltage. To avoid false detections caused by poor contact or electromagnetic interference, a de-jitter algorithm is used to process the raw sampled data. A time window (e.g., 100 milliseconds) and a voltage threshold (e.g., 10V) are set. Only when the voltage value of multiple consecutive samples (e.g., 100 consecutive samples, i.e., for 100 milliseconds) is stable above the high-level threshold is it determined that the control guide pin signal has stably transitioned from a low to a high level. This de-jitter mechanism can effectively filter out brief voltage glitches or transient fluctuations, ensuring that the detected gun insertion status transition is true and reliable. When the control guide pin voltage stably transitions from a low level (e.g., 6V) in the inserted state to a high level (e.g., 12V) in the uninserted state, the gun insertion status signal transition is confirmed. After confirming the gun insertion status signal transition, it is further verified that this transition indeed corresponds to the user performing a gun removal operation. Record the precise timestamp of the transition and compare it with the timestamp of the first display of the weapon-drawing guidance prompt. If the transition occurs within a reasonable time range after the guidance prompt is displayed (e.g., between 1 second and 5 minutes), it can be reasonably inferred that the transition is the result of the user responding to the guidance prompt and performing a weapon-drawing operation. If the transition occurs before the guidance prompt is displayed or within a very short time after the guidance prompt is displayed (e.g., less than 1 second), it may be due to signal fluctuations caused by other reasons, and monitoring should continue for further verification. If the transition occurs too long after the guidance prompt is displayed (e.g., more than 5 minutes), although it is still determined that the user performed a weapon-drawing operation, this longer response time should be recorded as data for user behavior analysis, which will be used to optimize the design of the guidance prompt to improve user response speed.

[0093] After confirming that the user has unplugged the charging gun according to the unplugging guide, the charging gun insertion status signal changes from "plugged in" to "unplugged in." This determination triggers the main control unit to update the charging pile's internal state machine, changing from the previous "fault locked and plugged in" state to "fault locked but not plugged in." Simultaneously, this event is recorded in the fault log. After the state transition, the content displayed on the human-machine interface is immediately updated. The unplugging guide on the display is replaced with a new message, such as "Charging gun unplugged, system is checking grounding status." The LED indicator's flashing pattern may remain a rapid red flash (because the grounding fault still exists), or switch to a slow red flashing (e.g., once per second) to indicate that the fault status has not been resolved but the user has completed the required operation. This timely feedback lets the user know that the system has recognized their unplugging operation, preventing unnecessary repeated plugging and unplugging of the charging gun due to a lack of system response.

[0094] In one possible implementation, when the charging pile is in a ground fault locked state and the charging gun status signal changes to "charging gun inserted," further diagnosis is needed to determine the true source of the ground fault, i.e., to distinguish whether the grounding anomaly is caused by poor grounding of the charging pile itself or by an illegal connection with the vehicle. Specifically, this includes: acquiring the first average live wire-to-ground voltage during a first target time period before the charging gun status signal changes to "charging gun inserted," and the second average live wire-to-ground voltage during a second target time period after the change to "charging gun inserted"; calculating the rate of change of the live wire-to-ground voltage before and after charging gun insertion based on the first and second average live wire-to-ground voltages; injecting a first active detection signal into the protective grounding circuit of the charging pile and acquiring the response current of the first active detection signal in the protective grounding circuit; calculating the real-time circuit impedance characteristics based on the first active detection signal and the response current; and then... The ground voltage change rate is compared with a preset change rate threshold, and the real-time loop impedance characteristics are matched with a preset fault feature database. If the change rate of the live wire to ground voltage is greater than the preset change rate threshold, and the real-time loop impedance characteristics match the impedance drop in the preset fault feature database, then the ground fault is determined to originate from the vehicle end, and vehicle end illegal connection diagnostic information is generated. If the change rate of the live wire to ground voltage is less than or equal to the preset change rate threshold, or the real-time loop impedance characteristics do not match the impedance drop, then the ground fault is determined to originate from the charging pile itself, and charging pile itself ground fault diagnostic information is generated.

[0095] Specifically, after confirming that the charging station's charging status signal has changed to "charging station engaged," the first average live wire to ground voltage within the first target time period before the signal changes to "charging station engaged" is acquired. The setting of the first target time period needs to strike a balance between data sufficiency and timeliness. A time period that is too short may result in insufficient voltage samples to accurately reflect the steady-state voltage level before charging station engagement, making it susceptible to instantaneous voltage fluctuations or measurement noise. Conversely, a time period that is too long may include transitional data during changes in the charging station's status, reducing the representativeness of the data. In practice, the first target time period is typically set to 2 to 10 seconds before the charging station's charging status signal changes, preferably 5 seconds. This time length ensures that a sufficient number of effective voltage samples are collected for average value calculation while also guaranteeing that these samples reflect the true ground voltage state of the charging station in its unengaged steady-state condition. The main control unit's real-time clock module accurately records the timestamps of transitions in the plug-in status signal, marking these timestamps as Tplug. Then, it extracts all live-wire to-ground voltage samples within the time range [Tplug-5 seconds, Tplug] from the historical voltage data buffer. The voltage monitoring module typically collects live-wire to-ground voltage samples continuously at a high sampling frequency, such as 100 or 1000 times per second. Taking a 5-second time period and a sampling frequency of 100 times per second as an example, 500 voltage samples will be extracted from the buffer. These samples are denoted as U.LG before[i], where i=1, 2,...,500.

[0096] To ensure the accuracy of the first average live-to-ground voltage calculation, the extracted voltage samples are preprocessed to remove outliers before calculating the average. During voltage sampling, electromagnetic interference, transient spikes caused by switching actions, or occasional faults in the measurement circuit may cause individual sample values ​​to deviate abnormally. If these outliers are directly used in the average calculation without processing, they will significantly affect the reliability of the calculation results. The quartile method or standard deviation method in statistics is used to identify and remove outliers. Taking the quartile method as an example, the 500 sample values ​​are first sorted from smallest to largest, and the first quartile Q1 (the 125th value) and the third quartile Q3 (the 375th value) are calculated. Then, the interquartile range IQR = Q3 - Q1 is calculated. Sample values ​​that are less than Q1 - 1.5 × IQR or greater than Q3 + 1.5 × IQR are marked as outliers and removed from the sample set. The remaining samples after removing outliers are recorded as the valid sample set, and the number of samples is recorded as Nvalid. The first average live wire-to-ground voltage U is obtained by calculating the arithmetic mean of all voltage values ​​in the valid sample set. LG avg1, If ​​the charging station is properly grounded and the system is normal, U LG avg1 should be close to the voltage between the live wire and the neutral wire, typically above 200V (for a 220V AC system). If there is a high impedance fault in the charging pile's grounding system, U LG avg1 will be significantly lower than normal, for example, lower than 187V (i.e., 220V × 0.85 threshold coefficient).

[0097] After acquiring the first average live wire to ground voltage, the second average live wire to ground voltage is acquired during the second target time period after the charging gun status signal changes to "plugged in". The setting of the second target time period also needs to consider data sufficiency and timeliness, but also the time required for the electrical connection to stabilize after plugging in. After the charging gun is physically connected to the vehicle's charging interface, the contact resistance requires a brief stabilization process, and the electrical characteristics of the control guidance signal also require a certain amount of time to reach a steady state. If voltage data acquisition begins too early, transient voltages during connection establishment may be acquired instead of the stabilized voltage, leading to inaccurate measurement results. Therefore, the second target time period is usually set to a certain delay after the change in the plugged in status signal before starting acquisition, and then continuing acquisition for a certain duration. In actual implementation, after detecting the plugged in status signal changing from "plugged in" to "plugged in", a delay of 0.5 to 2 seconds is made to wait for the electrical connection to stabilize, and then the live wire to ground voltage is acquired, continuously for 2 to 10 seconds. The preferred configuration is a 1-second delay before acquisition, continuing for 5 seconds. The transition time of the gun insertion status signal is recorded as Tplug. The start time of the second target time period is Tplug+1 seconds, and the end time is Tplug+6 seconds, with a time range of [Tplug+1 seconds, Tplug+6 seconds]. The system extracts all live wire-to-ground voltage samples within this time period from the real-time data stream of the voltage monitoring module. Again, at a sampling frequency of 100 times per second, a 5-second time period will generate 500 sample values, denoted as U. LG after[i], where i=1, 2,...,500.

[0098] The voltage sample values ​​within the second target time period undergo the same outlier removal preprocessing as described above. Outlier sample values ​​are identified and removed using the quartile method or standard deviation method. The effective sample set after removal is denoted as U. LG after[j], the number of valid samples is denoted as Nafter, and then the arithmetic mean is calculated to obtain the second average live wire to ground voltage U. LG avg2, if the charging pile has poor grounding but there is no illegal connection at the vehicle end, then U LG avg2 should be with U LG avg1 values ​​are all abnormally low and the differences are small. If the charging pile has poor grounding and there is an illegal neutral / ground connection at the vehicle end, then the illegal connection at the vehicle end after plugging in the charging gun forms an alternative grounding path, causing U LG avg2 compared to U LG The significant increase in avg1, which may approach the normal value, is precisely the difference in voltage levels before and after plugging in the gun, providing a key basis for fault source identification.

[0099] After obtaining the first and second average live-wire-to-ground voltages, the rate of change of the live-wire-to-ground voltage before and after plugging in the connector is calculated based on these two average voltage values. The rate of change of the live-wire-to-ground voltage is a normalized relative change indicator, which can eliminate the influence of different grid voltage levels on the absolute voltage difference, making the judgment standard more universal and robust. The system uses the following formula for calculating the relative change rate: Rate of change of live-wire-to-ground voltage = (U... LG avg2-U LG avg1) / U LG The formula avg1×100% calculates the percentage change in voltage after plugging in the charging gun relative to the voltage before plugging in. A positive value indicates a voltage increase, and a negative value indicates a voltage decrease. The larger the absolute value of the rate of change, the more significant the voltage change. When the charging pile itself is well grounded, the voltage between the live wire and ground should remain at a normal high value (e.g., between 210V and 230V) regardless of whether the charging gun is plugged in. The voltage change before and after plugging in is minimal, with a change rate usually within ±2%. This small fluctuation mainly comes from the normal fluctuations in the grid voltage. When the charging pile itself has poor grounding but the vehicle end is properly grounded or there is no illegal connection, the live wire to ground voltage measured at the charging pile end before plugging in will be lower due to poor grounding (e.g., 150V). Even after plugging in the charging gun, because the vehicle end is connected to the earth through normal protective grounding and there is no illegal neutral-to-ground connection, the live wire to ground voltage still mainly depends on the grounding impedance of the charging pile itself. The voltage level will not change significantly and will remain at a low value (e.g., 155V). The voltage difference before and after plugging in is very small. The error rate is usually within ±5%. However, when the charging pile itself has poor grounding but there is an illegal connection between the neutral and ground wires at the vehicle end, the voltage between the live wire and the ground wire measured by the charging pile before plugging in the gun will also be low due to poor grounding (e.g., 150V). However, the illegal connection at the vehicle end after plugging in the gun causes the ground wire to form a low impedance path with the neutral wire through the vehicle end. This path bypasses the high impedance grounding fault point of the charging pile itself, making the voltage measurement between the live wire and the ground wire actually become an approximate voltage measurement between the live wire and the neutral wire. The voltage value will rise significantly and approach the normal voltage between the live wire and the neutral wire (e.g., from 150V to 210V). The voltage difference before and after plugging in the gun reaches 60V, and the rate of change is as high as (210-150) / 150×100%=40%. This large voltage jump is a typical characteristic of the illegal connection at the vehicle end.

[0100] After calculating the rate of change of the live wire to ground voltage, the rationality of the voltage change rate is verified to avoid misjudgment in extreme cases. For example, if the first average live wire to ground voltage U before plugging in the gun... LG If avg1 is close to zero or very small (e.g., less than 10V), it may indicate that the grounding system is completely disconnected or that the measuring circuit is faulty. In this case, use U... LGUsing avg2 as the denominator to calculate the rate of change can lead to abnormally amplified results, even approaching infinity. Detecting this situation and taking protective measures is crucial. If U LG If avg1 is less than the preset minimum effective voltage threshold (e.g., 20V), this situation is marked as a severe fault of "complete grounding disconnection". Instead of performing rate of change calculations, it is directly determined as a severe grounding fault of the charging pile itself, and corresponding diagnostic information is generated. Only when U... LG The rate of change calculation is only valid and reliable when avg1 is within a reasonable range (e.g., greater than 50V and less than 250V). The calculated rate of change of the live wire to ground voltage is stored in an internal variable and denoted as ΔKvoltage.

[0101] In parallel with calculating the voltage change rate between the live wire and ground wire, an active detection process is initiated to obtain the impedance characteristics of the grounding loop. By actively injecting a test signal with known characteristics into the grounding loop and analyzing the loop's response to the signal, the frequency domain or time domain impedance characteristics of the grounding loop are obtained, facilitating the differentiation of resistive, capacitive, and inductive components of the impedance. A first active detection signal is injected into the protective grounding loop of the charging pile. This first active detection signal is an electrical signal with a specific frequency, amplitude, and waveform, generated by the active signal injection module and precisely controlled by the main control unit. The design of this signal needs to meet several constraints: the signal amplitude must be small enough not to pose a risk to normal electrical equipment and human safety, typically limited to the milliampere level or lower; the signal frequency selection needs to avoid the power frequency of 50Hz or 60Hz and its harmonics to prevent aliasing with the power grid signal; and the frequency cannot be too high to avoid significant attenuation by parasitic capacitance or inductance. Commonly used... The detection signal frequency includes a low-frequency sine wave of 10Hz to 100Hz, a medium-frequency square wave or pulse of 100Hz to 1kHz, or a DC pulse sequence with specific encoding. The signal waveform is usually selected as a sine wave, square wave, or pulse wave. Among them, the sine wave is suitable for frequency domain impedance analysis, and the square wave or pulse wave is suitable for time domain response analysis. In a preferred embodiment, the first active detection signal adopts a sine wave current signal with a frequency of 50Hz and a peak current amplitude of 5mA to 20mA. This signal is injected from the live wire to the ground wire loop through the controllable current source circuit via the active signal injection module.

[0102] The active signal injection module typically employs a precision controllable current source design. This circuit consists of a digital-to-analog converter (DAC), operational amplifier, power transistor, and a current sampling resistor forming a closed-loop feedback circuit. The main control unit outputs an analog voltage signal representing a sinusoidal waveform through the DAC. This voltage signal is amplified by the operational amplifier and power transistor to drive the load (i.e., the loop impedance from the live wire to ground). The current sampling resistor is connected in series in the injection loop to monitor the current flowing through it in real time. The voltage signal across the sampling resistor is fed back to the negative input of the operational amplifier, forming a closed-loop control. This ensures that regardless of changes in load impedance, the current flowing through the load always maintains a set sinusoidal waveform and amplitude. This constant current source design... The advantage of this design is that even if the grounding loop impedance varies over a wide range (from a few ohms to several thousand ohms), the injected current remains stable and controllable, facilitating subsequent impedance calculations. When the system starts active detection, the main control unit first configures the digital-to-analog converter to output a 47Hz sine wave with the amplitude set to the control voltage corresponding to a 10mA peak current. Then, it enables the current source output, and the first active detection signal begins to be injected from the live wire through the internal controlled current source circuit into the ground wire. This injected current will flow in the complete loop of live wire-ground wire-earth (or illegal path at the vehicle end)-neutral wire-live wire. The impedance characteristics of each part in the loop will determine the distribution of the current signal and the resulting voltage response.

[0103] While injecting the first active detection signal, the response current of the first active detection signal in the protective grounding loop is collected through the signal response analysis module. Although a constant current signal is injected, in order to improve measurement accuracy and perform self-testing in actual implementation, the actual current flowing in the loop is still measured independently by a high-precision current sensor. The current sensor can be a Hall current sensor, a current transformer, or a high-precision sampling resistor combined with an instrumentation amplifier. The sensor is installed at a key position in the grounding loop and can measure the current flowing through that point non-invasively or with low impedance. The current signal output by the sensor is sampled by an analog-to-digital converter at a high sampling rate (e.g., 10 kHz per second). The sampled data stream is sent to the main control unit for digital signal processing. At least 2 to 10 complete signal cycles are continuously collected. For a 47 Hz sine wave signal, one cycle is about 21.3 milliseconds, and it takes about 213 milliseconds to collect 10 cycles. The current sample data collected during this period is denoted as Iresponse[n], where n is the sampling point number. These current response data reflect the transmission characteristics of the injected signal in the actual grounding loop.

[0104] In addition to acquiring the response current, the voltage response of key nodes in the loop is also acquired synchronously. Specifically, the change in the voltage of the ground wire relative to the neutral wire (i.e., the GND-N voltage) during the injection of the probe signal is measured. This voltage measurement is achieved through a differential voltage measurement circuit. The input terminals of the measurement circuit are connected to the ground wire and the neutral wire respectively, and the output terminal is connected to a high-precision analog-to-digital converter. Synchronous with the current response acquisition, the system acquires the GND-N voltage at the same sampling rate (e.g., 10kHz), and the sampled data is denoted as Vresponse[n]. At least 10 complete signal cycles are also acquired. By synchronously acquiring the injected signal (known), the response current, and the response voltage, the impedance characteristics of the grounding loop can be calculated based on Ohm's law and circuit theory. The basic impedance calculation formula is Z=V / I. However, since the signal is an AC sine wave, the impedance Z is a complex number, containing impedance amplitude and phase information. The system uses discrete Fourier transform or fast Fourier transform technology to perform frequency domain analysis on the acquired voltage and current time domain signals, extracting the amplitude and phase of the 47Hz frequency component. The 47Hz component of the voltage signal is represented as V. 47Hz =|V 47Hz |·e (jφV) The 47Hz component of the current signal is represented as I. 47Hz =|I 47Hz |·e (jφI) Then the impedance is Z 47Hz =V 47Hz / I 47Hz =(|V4 7Hz | / |I 47Hz |)·e (j(φV-φI)) , where |V 47Hz | / |I 47Hz | represents the impedance amplitude, and φV-φI represents the impedance phase angle.

[0105] The real-time loop impedance characteristics are calculated based on the first active detection signal and response current. These characteristics include not only the impedance amplitude and phase mentioned above, but also multi-dimensional feature vectors derived from these fundamental parameters to more comprehensively describe the electrical characteristics of the grounding loop. The magnitude of the impedance amplitude |Z| directly reflects the total impedance level of the grounding loop. The impedance of a normally grounded loop is typically between 1 ohm and 10 ohms, while the impedance of a poorly grounded loop may rise to tens or even hundreds of ohms. The impedance phase angle θ = φV - φI reflects the capacitive or inductive characteristics of the loop. The phase angle of a purely resistive loop is close to 0 degrees, the phase angle of a capacitive loop is negative (voltage lags current), and the phase angle of an inductive loop is positive (voltage leads current). A normal protective grounding loop mainly consists of conductors, grounding electrodes, and soil. The circuit is composed of resistive components, with a phase angle typically between -15 and +15 degrees. If there is an illegal neutral-to-ground connection at the vehicle end, the distributed capacitance effect of the power cable and vehicle body may cause the circuit to exhibit certain capacitive characteristics, and the phase angle may be biased towards negative values ​​(such as -20 to -40 degrees). The system further calculates the real part (resistive component) R=|Z|·cos(θ) and the imaginary part (capacitive or inductive component) X=|Z|·sin(θ) of the impedance based on the impedance amplitude and phase angle. These parameters together constitute a multidimensional feature vector of the real-time circuit impedance characteristics, denoted as Zfeature={|Z|,θ,R,X}. This feature vector will be used to match with a preset fault feature database.

[0106] After calculating the voltage change rate of the live wire to the ground wire and the real-time loop impedance characteristics, the fault source determination logic is entered. The measured characteristic parameters are compared with preset thresholds and characteristic patterns to distinguish whether the grounding fault originates from the charging pile itself or from an illegal connection at the vehicle end. First, the voltage change rate between the live wire and the ground wire is compared with the preset change rate threshold. The preset change rate threshold is a critical value pre-set based on a large amount of experimental data and theoretical analysis. It is used to distinguish whether the voltage change is a normal fluctuation or an abnormal jump. As mentioned earlier, when the charging pile is grounded normally or poorly grounded but there is no illegal connection at the vehicle end, the voltage change rate before and after plugging in the charging gun is usually within ±5%. However, when there is an illegal connection at the vehicle end that causes the grounding path to change, the voltage change rate may reach 30% to 60% or even higher. Taking into account factors such as measurement error and power grid fluctuation, the preset change rate threshold is usually set to 15% to 25%. If the preset change rate threshold is set to 20%, the calculated voltage change rate ΔKvoltage between the live wire and the ground wire is compared with 20%. It is determined whether ΔKvoltage is greater than 20%. If ΔKvoltage>20%, it means that the voltage before and after plugging in the charging gun has increased significantly, and it is initially determined that there is a suspicion of illegal connection at the vehicle end. If ΔKvoltage≤20%, it means that the voltage before and after plugging in the charging gun is basically stable or changes very little, and it is initially determined that the fault mainly comes from the charging pile itself.

[0107] Relying solely on the voltage change rate as a single indicator carries a risk of misjudgment. For example, in certain special cases, the grid voltage may jump precisely before and after the charging station is plugged in, or the vehicle may have an illegal connection but a high connection impedance may result in an insignificant voltage change. Therefore, it is necessary to perform feature matching between the real-time loop impedance characteristics and a pre-set fault feature database. This database is a structured database stored in the non-volatile memory of the charging station's main control unit. It contains impedance feature templates corresponding to various typical fault modes. Each feature template is a multi-dimensional parameter set describing the impedance amplitude range, phase angle range, resistive component range, and capacitive / inductive component range of the grounding loop under a specific fault mode. The database contains at least the following typical... Fault mode characteristic templates: Normal grounding mode, impedance amplitude 1 to 10 ohms, phase angle -10 degrees to +10 degrees, mainly resistive; poor grounding mode of charging pile body, impedance amplitude 30 to 200 ohms, phase angle -15 degrees to +15 degrees, still mainly resistive but the resistance value is significantly higher; illegal neutral and ground wire connection mode at the vehicle end, impedance amplitude 5 to 30 ohms (slightly higher than normal but lower than the fault of the charging pile body), phase angle -25 degrees to -45 degrees, showing obvious capacitive characteristics; completely disconnected grounding mode, impedance amplitude greater than 500 ohms, phase characteristics are uncertain. These characteristic templates can be established by collecting a large amount of impedance data under different fault conditions in the laboratory or on site, performing statistical analysis and clustering. After the database is established, it can be continuously optimized and updated through machine learning algorithms.

[0108] The calculated real-time loop impedance characteristic Zfeature={|Z|, θ, R, X} is matched with each feature template in the preset fault feature database. This means determining whether the measured characteristic parameters fall within the parameter range of a particular template. If they do, the match is successful. A more precise method is similarity calculation, which calculates the Euclidean or Mahalanobis distance between the measured feature vector and the feature vectors of each template. The template with the smallest distance is the best-matched fault mode. Initial classification is performed based on the impedance amplitude |Z|. If |Z| < 15 ohms, "pile grounding failure" is excluded. In the "Good" mode, if |Z| > 25 ohms, the "Illegal Vehicle-End Connection" and "Normal Grounding" modes are excluded. Then, based on the initial classification, the phase angle θ is further checked. If θ < -20 degrees and |Z| is within the range of 5 to 30 ohms, the match is determined to be in the "Illegal Vehicle-End Connection" mode. The typical characteristic of this mode is a decrease in impedance (relative to the high-resistance fault state of the pile before the insertion gun) and capacitive behavior. If |Z| > 30 ohms and -15 degrees < θ < +15 degrees, the match is determined to be in the "Poor Pile Grounding" mode. The typical characteristic of this mode is high resistance and resistive behavior. After completing the voltage change rate comparison and impedance characteristic matching, the final fault source determination decision logic is entered. The decision-making logic employs a dual-criteria fusion strategy, simultaneously considering both voltage change rate criteria and impedance characteristic matching criteria. A definitive judgment is made only when both criteria point to the same conclusion. If the voltage change rate ΔKvoltage between the live wire and ground wire is greater than a preset change rate threshold (20%), and the real-time loop impedance characteristic matches an impedance drop in the preset fault characteristic database, then the ground fault is determined to originate from the vehicle end, and vehicle-end illegal connection diagnostic information is generated. After determining the fault source, corresponding diagnostic information is generated. The diagnostic information is a structured data object containing fault type identifiers, key diagnostic parameters, timestamps, confidence levels, and other information. If the vehicle is determined to be illegally connected, the generated vehicle-side illegal connection diagnostic information includes the following fields: fault type identifier, diagnostic description text "An illegal connection between the neutral and ground wires was detected at the vehicle end, causing grounding detection abnormality", key diagnostic parameters including the specific value of voltage change rate ΔKvoltage (e.g., "Voltage change rate before and after plugging in the gun is +42%), impedance characteristic parameters (e.g., "Grounding loop impedance is 15.3 ohms, phase angle is -32 degrees, capacitive"), judgment timestamp recording the precise moment the diagnosis was completed, and confidence level set according to the consistency of the two criteria (if both criteria strongly point to the same conclusion, the confidence level is "high").

[0109] If the rate of change of the live wire to ground voltage ΔKvoltage is less than or equal to the preset rate of change threshold (20%), or the real-time loop impedance characteristics do not match the impedance drop, then the grounding fault is determined to originate from the charging pile itself, and charging pile body grounding fault diagnosis information is generated. The generated charging pile body grounding fault diagnosis information includes the following fields: fault type identifier, diagnosis description text "abnormal charging pile body protective grounding system, excessively high grounding impedance or grounding disconnection", and key diagnostic parameters including the first average live wire to ground voltage U before plugging in the charging gun. LG The value of avg1 (e.g., "the voltage between the live wire and ground is 152V when the gun is not plugged in, which is far lower than the normal value of 220V"), and the grounding loop impedance parameters (e.g., " Grounding circuit The impedance is 78.5 ohms, significantly higher than the normal range. The voltage change rate (e.g., "the voltage change rate before and after insertion of the gun is only +3%, with no significant change"), the determination timestamp, and the confidence level are also recorded in the diagnostic information.

[0110] S107: When the charging pile is in a ground fault locked state, if the gun insertion status signal indicates that the gun is not inserted and the preset ground fault recovery conditions are met, the ground fault locked state will be released and charging operation will be allowed.

[0111] In S107 above, when the charging pile is in a ground fault locked state and the charging gun status signal indicates that the charging gun is not plugged in, in order to prevent the fault from being falsely cleared and recurring, and to avoid the charging pile from resuming operation while there are still hidden dangers in the grounding system, thus avoiding safety risks, if the charging gun status signal indicates that the charging gun is not plugged in and the preset ground fault recovery conditions are met, the ground fault locked state is released. Specifically, this includes: when the charging pile is in the unplugged state, calculating the voltage ratio, injecting a second active detection signal into the protective grounding circuit of the charging pile, and continuously calculating the current circuit impedance characteristics based on the collected current response current; determining whether the voltage ratio is greater than or equal to the recovery threshold and continuing to recover for a confirmation time, or determining whether the current circuit impedance characteristics have recovered to the normal impedance range and continuing to confirm the impedance for a confirmation time; if the voltage ratio is greater than or equal to the recovery threshold and continues to recover for a confirmation time, or if the current circuit impedance characteristics have recovered to the normal impedance range and continue to confirm the impedance for a confirmation time, then it is determined that the ground fault recovery conditions are met, and the ground fault locked state is released.

[0112] Specifically, after detecting that the charging gun status signal indicates an unplugged state, a continuous voltage ratio monitoring process is initiated. This process is coordinated by the main control unit and the voltage monitoring module and the charging gun status detection module. The charging gun status detection module determines whether the charging gun is connected to the electric vehicle by monitoring the voltage status of the CC and CP signal lines of the charging gun. In the standard charging protocol, the voltage on the CP signal line is 12V DC when the charging gun is not plugged in, indicating that the charging gun is in standby mode. When the charging gun is plugged into the vehicle's charging interface and a physical connection is completed, the CP signal line voltage will drop to 9V or 6V, indicating that it has entered the connection state or charging preparation state. At the same time, the CC signal line identifies the rated current of the cable through resistance encoding. The main control unit reads the CP signal line voltage every 50 milliseconds. When the result of 5 consecutive readings is 12V±0.5V, the charging gun status signal is determined to indicate an unplugged state. This design of multiple continuous determinations is to avoid misjudgments caused by instantaneous signal jitter and to ensure that the charging gun is indeed in the unplugged state rather than a transitional state during the plugging and unplugging process. After confirming that the voltage monitoring module is not plugged in, it immediately enters a high-precision continuous sampling mode, synchronously acquiring the live-to-neutral voltage U_LN and live-to-ground voltage U_LG at a sampling frequency of 100 times per second. Sampling uses a 16-bit high-precision ADC converter, achieving a voltage measurement accuracy of ±0.5V. After each sampling, the main control unit's digital signal processing module performs digital filtering on the sampled value, employing a moving average filtering algorithm to eliminate high-frequency noise. The filtering window length is set to 10 sampling points, meaning the average of the most recent 10 samples is used as the current effective voltage value. This filtering process eliminates instantaneous spike interference while maintaining a rapid response to real voltage changes. Every 0.1 seconds, the main control unit calculates the voltage ratio K=U based on the filtered voltage value. LG / U LN The calculation uses floating-point arithmetic to maintain precision, and the result is retained to three decimal places. For example, when U LN 220.3V, U LG When the voltage is 215.8V, the calculated value is K = 215.8 / 220.3 ≈ 0.980.

[0113] In a standard TN power supply system, the neutral and ground wires are grounded together at the neutral point of the power transformer. Theoretically, they should be at the same potential. Therefore, the voltage U measured from the live wire to the neutral wire should be equal. LN It should be equal to the voltage U measured from the live wire to the ground wire. LGThe voltage ratio K should be equal to 1.0. However, in actual systems, due to the resistance of the wires and contacts between the power supply and the charging pile, as well as the connection resistance between the grounding terminal and the grounding busbar inside the charging pile, these impedances cause a small potential difference between the neutral wire and the ground wire. This causes the voltage ratio K to fluctuate between 0.95 and 1.05, which is a normal physical phenomenon. However, when the grounding system of the charging pile malfunctions, such as a loose grounding wire connection leading to increased contact resistance, a broken grounding wire causing an open grounding loop, or corrosion of the grounding electrode leading to increased grounding resistance, the potential of the ground wire will deviate from the neutral wire potential. Under the influence of the live wire voltage, the potential of the ground wire relative to the actual ground will increase, causing the voltage U measured from the live wire to the ground wire to rise. LG Significantly lower than the voltage U measured from the live wire to the neutral wire LN The voltage ratio K will drop below 0.85 or even lower, and may drop to 0.5 to 0.7 in severe faults. If the grounding system is repaired, for example, if maintenance personnel retighten loose grounding wire connection bolts, replace corroded grounding terminals, or add resistance-reducing agent around the grounding electrode, the impedance of the grounding loop will return to the normal range, and a good equipotential relationship will be re-established between the ground wire and the neutral wire. The voltage ratio K will rise and stabilize at a level close to 1.0. Therefore, continuously monitoring the trend of the voltage ratio K and determining whether it has reached and stabilized above the recovery threshold is the primary criterion and the most intuitive physical indicator for verifying whether the grounding fault has been truly eliminated.

[0114] A second active detection signal is injected into the protective grounding loop of the charging pile, and the current loop impedance characteristics are continuously calculated based on the collected current response current. The second active detection signal is continuously injected in the unplugged state during the fault recovery verification phase to verify whether the impedance of the grounding system has returned to normal and remains stable. The injection of the second active detection signal is performed by an active signal injection module, which includes a controllable weak current source circuit and a signal generator. The signal generator produces a control signal with a frequency of 47Hz and a sine wave waveform. This frequency selection is carefully designed; 47Hz is close to the power frequency of 50Hz to simulate the actual power frequency leakage scenario, and has sufficient frequency difference from 50Hz to distinguish it from the power frequency signal in spectrum analysis, avoiding interference from power frequency harmonics. The sine wave provides stable spectrum characteristics for easy analysis. The controlled current source circuit generates a sinusoidal current signal with a peak amplitude of 10mA. This current amplitude setting balances test sensitivity and safety; the 10mA current is small enough to pose no risk to users or equipment, and even in the worst-case scenario where a user touches a live component, the current is far below the human perception threshold. Simultaneously, this current is large enough to generate a measurable voltage response in the grounding loop, enabling the signal response analysis module to accurately calculate impedance characteristics. The current signal is coupled into the grounding loop through an isolation transformer, with the injection point located between the live wire L and the ground wire GND, forming a test loop: the signal current is injected from the live wire L, flows through the parasitic capacitance and insulation resistance inside the charging pile to the ground wire GND, then flows to the ground through the grounding loop, and finally returns to the power supply through the neutral wire N of the power system, forming a closed loop.

[0115] Simultaneously with signal injection, the signal response analysis module begins operation. This module includes a high-precision current sensor, a voltage sensor, a high-speed ADC sampling circuit, and a digital signal processing unit. The current sensor, employing a Hall effect sensor or a Rogowski coil, is installed in the ground loop to acquire the current response current flowing through the ground wire in real time. The voltage sensor uses a differential amplifier circuit to measure the voltage response between the ground wire (GND) and the neutral wire (N). The output signals from both sensors are synchronously fed into the high-speed ADC for digital sampling. The sampling frequency is set to 4700Hz, 100 times the detection signal frequency of 47Hz. According to the Nyquist sampling theorem, this sampling rate can completely reconstruct the signal waveform. The digital signal processing unit receives the current and voltage digital sequences output by the ADC. It first preprocesses the signal, including removing the DC component and applying a Hamming window function to reduce spectral leakage. Then, it performs a Fast Fourier Transform (FFT) to convert the time-domain signal to the frequency domain, accurately extracting the complex values ​​of the current and voltage components at the 47Hz frequency point. Each complex value contains two parameters: amplitude and phase. The complex current value is denoted as I. 47 =Imag·e (j φI) The complex voltage is denoted as U. 47=Umag·e (jφU) Where Imag and Umag are the amplitudes of the current and voltage at 47Hz, respectively, and φI and φU are their phase angles. According to Ohm's law and the complex definition of impedance, the impedance characteristic of the current circuit at 47Hz can be calculated as Z. 47 =U 47 / I 47 After expansion, the impedance amplitude |Z is obtained. 47 The complex impedance can be further decomposed into a resistive component R = |Z|, where |Z| = Umag / Imag and the impedance phase angle θ = φU - φI. 47 |·cos(θ) and reactive component X=|Z 47 |·sin(θ), the sign of the reactance component indicates the capacitive or inductive characteristic of the circuit, X>0 indicates inductive, X<0 indicates capacitive. These calculated impedance magnitudes, phase angles, resistive components, and reactance components together constitute the current circuit impedance characteristics. This characteristic is a digital fingerprint of the health status of the grounding system, which can reflect the physical parameters of the grounding circuit, such as resistance, capacitance, and inductance.

[0116] After obtaining continuous monitoring data streams of the voltage ratio and continuous detection data streams of the current loop impedance characteristics, the core recovery condition determination logic is entered. This determination logic employs a dual-criteria verification mechanism, constructing voltage and impedance criteria separately. These two criteria can independently verify the recovery status of the grounding system. The voltage criterion, based on the continuous monitoring results of the voltage ratio K, determines whether the voltage ratio is greater than or equal to the recovery threshold and continues for the recovery confirmation duration. The recovery threshold is a dynamically set parameter that varies according to the grid environment quality where the charging pile is located. Two grid environment modes are pre-configured, each corresponding to different recovery thresholds and recovery confirmation duration requirements. In the normal grid environment mode, the recovery threshold is set to 0.98, and the recovery confirmation duration is set to 10 seconds. For example, in industrial parks with dedicated transformer power supply or areas with good municipal power quality, under normal grid environment conditions, the recovery threshold is set to 0.98, and the recovery confirmation time is set to 10 seconds. This time corresponds to 100 voltage ratio calculations (calculated once every 0.1 seconds). Within the 10-second time window, all 100 calculated voltage ratios must satisfy K ≥ 0.98. Any calculation result below 0.98 will cause the timer to reset, and the accumulation duration must restart. This strict continuity requirement ensures that voltage recovery is not an accidental instantaneous phenomenon, but a stable and continuous state, avoiding misjudgments of recovery due to brief voltage rebounds caused by instantaneous grid fluctuations or measurement noise.

[0117] In the harsh power grid environment mode, the recovery threshold is set to 0.88 and the recovery confirmation time is set to 15s.

[0118] For example, in remote long-distance power transmission areas, areas with concentrated industrial loads, or aging power grids, even if the grounding system is completely normal, fluctuations in the power grid itself and harmonic interference can cause a large instantaneous potential difference between the ground wire and the neutral wire, making it difficult for the voltage ratio to stabilize at a high level close to 1.0. If a high threshold of 0.98 is still used, even if the grounding system has been repaired, it may not be able to unlock because the threshold requirement is not met. Therefore, the recovery threshold is appropriately relaxed to 0.88. This threshold takes into account the actual situation of harsh power grid environments while ensuring safety. A ratio of 0.88 corresponds to a ground wire voltage that is about 12% lower than the neutral wire voltage, which can still indicate that the grounding loop impedance is within an acceptable range. At the same time, the recovery confirmation time is extended to 15 seconds, corresponding to 150 voltage ratio calculations. Although the threshold is relaxed, the stability and reliability of the judgment are enhanced by extending the confirmation time, ensuring that the true recovery status can be accurately determined even in a power grid fluctuation environment.

[0119] The voltage criterion determination process is executed by the status determination module of the main control unit. This module maintains a recovery timer and a continuous satisfaction counter. After entering the fault recovery verification process, the recovery timer and the continuous satisfaction counter are initialized to 0. Whenever the main control unit completes a calculation of the voltage ratio K, the status determination module immediately compares K with the recovery threshold. If K ≥ the recovery threshold, the continuous satisfaction counter is incremented by 1, and the recovery timer is incremented by 0.1 seconds. If K < the recovery threshold, both the continuous satisfaction counter and the recovery timer are reset to 0, and the counting must start again. When the recovery timer reaches the recovery confirmation duration Trecover (10 seconds in normal power grid environment and 15 seconds in severe power grid environment), the status determination module checks the value of the continuous satisfaction counter. If the counter equals Trecover / 0.1 (i.e., 100 in normal power grid environment and 150 in severe power grid environment), it indicates that the voltage ratio calculated each time within the entire confirmation duration meets the threshold requirement, and the voltage criterion is determined to be satisfied. This decision logic ensures strict continuity requirements. Any instantaneous voltage drop will cause the decision process to restart. Only after the grounding system has truly stabilized and recovered can the voltage ratio continuously meet the threshold requirements and ultimately pass the voltage criterion.

[0120] The impedance criterion is similar to the voltage criterion but based on a different data source. The impedance criterion determines whether the current loop impedance characteristics have recovered to the normal impedance range and maintains the impedance confirmation duration. The normal impedance range is a multi-dimensional parameter space pre-determined through theoretical analysis and experimental testing. For a standard charging pile grounding system, the normal impedance range is defined as: impedance amplitude |Z| between 1 and 15 ohms, and impedance phase angle θ between -15 degrees and +15 degrees. The lower limit of impedance amplitude, 1 ohm, corresponds to a grounding loop approaching an ideal conductor state, including the sum of the conductor resistance of the grounding wire itself, the contact resistance of the grounding terminal, and the grounding resistance of the grounding electrode. This value cannot be infinitely close to zero because any physical conductor has a finite resistance. The upper limit of impedance amplitude, 15 ohms, is determined according to safety standards. For example, GB / T18487.1 stipulates that the protective grounding resistance of charging equipment should be less than 10 ohms. Considering other impedances in the measurement loop (such as internal wiring impedance), appropriately relaxing the threshold to 15 ohms can accommodate more actual operating conditions. The impedance phase angle range of -15 to +15 degrees indicates that the grounding loop should primarily exhibit resistive characteristics. A phase angle close to 0 degrees means that the impedance is mainly composed of resistance, which conforms to the physical characteristics of a good grounding system. An allowable deviation of ±15 degrees takes into account potential parasitic inductance (from the self-inductance of long-distance cables) or parasitic capacitance (from the cable-to-ground distributed capacitance) in the loop. These parasitic parameters introduce small phase shifts, but as long as the absolute value of the phase angle does not exceed 15 degrees, it indicates that the loop is still predominantly resistive, and the grounding function is normal. The impedance verification time is typically set to 15 to 30 seconds, which is longer than the verification time for voltage criteria. This is because impedance detection is performed every 5 seconds, compared to voltage sampling every 0.1 seconds. Impedance detection has a lower time resolution, thus requiring a longer observation window to ensure the reliability of the judgment.

[0121] The impedance criterion is determined by the impedance analysis module of the main control unit. After each active detection is completed and the current loop impedance characteristics are calculated, this module immediately compares the impedance characteristics with the normal impedance range. The comparison process consists of two steps: first, it determines whether the impedance amplitude |Z| is within the range of 1 to 15 ohms, i.e., it checks whether the condition 1Ω≤|Z|≤15Ω is met; second, it determines whether the impedance phase angle θ is within the range of -15 degrees to +15 degrees, i.e., it checks whether the condition -15°≤θ≤+15° is met. Only when both conditions are met is the impedance characteristic of the current detection determined to be normal. The impedance analysis module maintains the aforementioned sliding window array, and after each detection result is determined to be normal or abnormal, the result is stored in the array along with the determination result. Once a sufficient number of detection results have accumulated in the array, the impedance analysis module checks whether all results within the sliding window have been deemed normal. For example, if the impedance confirmation time is set to 15 seconds, with a detection every 5 seconds and a sliding window array length of 3, the impedance criterion is only considered met if the most recent three detection results are all deemed normal, and the time span from the first normal detection to the last normal detection reaches 15 seconds. If any detection result is abnormal during this period, such as an impedance amplitude exceeding the upper limit of 18 ohms or a phase angle exceeding the range of -20 degrees, the impedance criterion is deemed unmet, the timer is reset, and the verification process must restart after further repair of the grounding system.

[0122] When the voltage or impedance criterion meets the recovery condition, the main control unit's state machine executes the operation to release the ground fault lockout state. The release operation is a multi-step atomic transaction, ensuring consistent system state transitions. The main control unit clears the fault flag bit in its internal RAM. This flag bit is a Boolean variable that is set to True when a ground fault is detected and cleared to False when the fault is cleared. All software modules involved in ground fault detection and charging process control check this flag bit to determine their behavior. The state machine transitions from the fault recovery verification state back to the ready state. This state transition triggers a series of initialization actions, including resetting various timers, clearing the sliding window array, and stopping the injection of active probe signals. The main control unit sends a fault clearance command to the human-machine interface module (HMI). The HMI module stops the audible and visual fault alarm prompts, including turning off the alarm LEDs, stopping the buzzer, and clearing the fault message on the LCD screen. Simultaneously, it displays the message "Grounding system has returned to normal, equipment is ready" on the screen, providing clear feedback to the user. The main control unit unlocks the charging process, allowing subsequent charging operations. This includes re-enabling the handshake logic of the CC / CP signals, enabling contactor closure control, and allowing power output, restoring the charging pile to normal operation and enabling charging services for electric vehicles. The main control unit generates a fault recovery log, a structured data packet containing multiple fields: timestamp of the fault recovery time (accurate to the second), fault duration (total duration from the first fault detection to unlocking), final voltage ratio (K value at the unlocking time), final impedance characteristics (impedance amplitude and phase angle of the last detection), satisfied recovery criterion type (voltage criterion / impedance criterion / both satisfied), and optional user operation records (such as gun removal time). This recovery log is associated with the fault diagnosis log previously generated in the fault diagnosis process via a unique fault event ID, forming a complete fault event file stored in the main control unit's non-volatile memory and can be uploaded to the cloud management platform via the communication interface.

[0123] This application embodiment also provides a charging pile grounding fault diagnosis and locking control system. The system includes an acquisition unit, a processing unit, a locking unit, and a recovery unit. The acquisition unit acquires the charging pile's plug-in status signal and continuously collects the live-to-neutral voltage and live-to-ground voltage of the power supply line. The processing unit extracts the instantaneous value sequence of the live-to-neutral voltage within a preset time window, and calculates the total harmonic distortion score, voltage event score, and fundamental frequency offset score based on the instantaneous value sequence. The total harmonic distortion score, voltage event score, and fundamental frequency offset score are weighted and summed to obtain the total power grid environment score. The power grid environment mode of the charging pile is determined based on the total power grid environment score, and the corresponding safety threshold, recovery threshold, anomaly confirmation time, and recovery threshold are determined based on the power grid environment mode. The system includes the following steps: 1. **Recovery Confirmation Duration:** When the charging gun status signal indicates "not plugged in," calculate the voltage ratio between the live wire and ground wire and the live wire and neutral wire. 2. **Locking Unit:** If the voltage ratio is less than a safety threshold and the duration reaches the abnormal confirmation duration, place the charging pile in a ground fault locking state and prohibit charging. 3. **Recovery Unit:** When the charging pile is in a ground fault locking state, if the charging gun status signal indicates "not plugged in" and the preset ground fault recovery conditions are met, release the ground fault locking state and allow charging. The preset ground fault recovery conditions include a voltage ratio greater than or equal to a recovery threshold and a continuous recovery confirmation duration.

[0124] In one possible implementation, the processing unit performs a Fast Fourier Transform on the instantaneous value sequence to obtain a spectrum, extracts the fundamental amplitude and harmonic amplitudes from the spectrum, calculates the real-time total harmonic distortion (THD) based on the fundamental amplitude and harmonic amplitudes, calculates the difference between the real-time THD and the reference THD, compares the difference with multiple preset deviation thresholds, and obtains a THD score based on the comparison results; calculates the effective voltage value corresponding to the instantaneous value sequence, and records a voltage event when the effective voltage value exceeds the preset upper and lower limits of the rated voltage; when the instantaneous value sequence... When the absolute value of a column exceeds a preset transient peak threshold, it is recorded as a transient overvoltage event. The total number of voltage events and transient overvoltage events within a preset time window is counted, and a voltage event score is calculated based on the total number of occurrences. The zero-crossing timestamps of consecutive zero-crossing points in the same direction are identified from the instantaneous value sequence, and the time difference between two adjacent zero-crossing timestamps is calculated as the real-time period, and the reciprocal of the real-time period is used as the real-time frequency. The maximum offset of the real-time frequency relative to the preset reference frequency within the preset time window is extracted, and a fundamental frequency offset score is calculated based on the maximum offset.

[0125] In one possible implementation, the processing unit compares the total grid environment score with a severe environment score threshold and a normal environment score threshold, wherein the severe environment score threshold is greater than the normal environment score threshold; when the total grid environment score is greater than the severe environment score threshold, it determines that the charging pile is in a severe grid environment mode; when the charging pile is in a severe grid environment mode and the total grid environment score calculated for a consecutive preset number of times is less than or equal to the normal environment score threshold, it determines that the charging pile switches to a normal grid environment mode; it matches the corresponding basic safety threshold, basic recovery threshold, anomaly confirmation time, and recovery confirmation time according to the grid environment mode in which the charging pile is located; it obtains the voltage ratio sequence within a preset historical time period, and calculates the basic recovery threshold and basic safety threshold based on the voltage ratio sequence to obtain the safety threshold and recovery threshold.

[0126] In one possible implementation, the processing unit is used to calculate the standard deviation of the voltage ratio sequence; calculate the ratio of the total grid environment score to the benchmark environment score to obtain an environmental degradation coefficient; multiply the environmental degradation coefficient by a basic first factor to obtain a first adjustment factor; subtract the product of the voltage ratio standard deviation and the first adjustment factor from the basic safety threshold to obtain a safety threshold; multiply the environmental degradation coefficient by a basic second factor and add a hysteresis compensation constant to obtain a second adjustment factor; and add the product of the voltage ratio standard deviation and the second adjustment factor to the basic recovery threshold to obtain a recovery threshold.

[0127] In one possible implementation, the acquisition unit is used to acquire the first average live wire-to-ground voltage during a first target time period before the charging gun status signal changes to the "charger inserted" state, and the second average live wire-to-ground voltage during a second target time period after the change to the "charger inserted" state; the processing unit is used to calculate the rate of change of the live wire-to-ground voltage before and after charging gun insertion based on the first average live wire-to-ground voltage and the second average live wire-to-ground voltage; inject a first active detection signal into the protective grounding circuit of the charging pile, and collect the response current of the first active detection signal in the protective grounding circuit; and calculate the real-time circuit based on the first active detection signal and the response current. Impedance characteristics: The rate of change of the live wire to ground voltage is compared with a preset rate of change threshold, and the real-time loop impedance characteristics are matched with a preset fault characteristic database. If the rate of change of the live wire to ground voltage is greater than the preset rate of change threshold, and the real-time loop impedance characteristics match the impedance drop in the preset fault characteristic database, then the ground fault is determined to originate from the vehicle end, and vehicle end illegal connection diagnostic information is generated. If the rate of change of the live wire to ground voltage is less than or equal to the preset rate of change threshold, or the real-time loop impedance characteristics do not match the impedance drop, then the ground fault is determined to originate from the charging pile itself, and charging pile itself ground fault diagnostic information is generated.

[0128] In one possible implementation, the locking unit is used to output ground fault alarm information through the human-machine interface of the charging pile when the charging pile is in a ground fault locked state and the charging gun status signal is in the plugged-in state; the charging gun removal guidance prompt information is displayed simultaneously on the human-machine interface to guide the user to remove the charging gun; when a change in the charging gun status signal is detected, it is confirmed that the user has removed the charging gun according to the charging gun removal guidance prompt information, and it is determined that the charging gun status signal has changed from the plugged-in state to the unplugged state.

[0129] In one possible implementation, the recovery unit is used to calculate the voltage ratio when the charging pile is in an unplugged state, inject a second active detection signal into the protective grounding circuit of the charging pile, and continuously calculate the current circuit impedance characteristics based on the collected current response current; determine whether the voltage ratio is greater than or equal to the recovery threshold and continue to recover for a confirmation time, or determine whether the current circuit impedance characteristics have recovered to the normal impedance range and continue to confirm the impedance for a confirmation time; if the voltage ratio is greater than or equal to the recovery threshold and continues to recover for a confirmation time, or if the current circuit impedance characteristics have recovered to the normal impedance range and continue to confirm the impedance for a confirmation time, then it is determined that the ground fault recovery condition is met and the ground fault lockout state is released.

[0130] It should be noted that the system provided in the above embodiments is only illustrated by the division of the above functional modules. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the system and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0131] This application also discloses an electronic device. (See reference...) Figure 3 , Figure 3 This application provides a schematic diagram of the structure of an electronic device. The electronic device 300 may include: at least one processor 301, at least one network interface 304, a user interface 303, a memory 302, and at least one communication bus 305.

[0132] The communication bus 305 is used to enable communication between these components.

[0133] The user interface 303 may include a display screen and a camera. Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.

[0134] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).

[0135] The processor 301 may include one or more processing cores. The processor 301 connects to various parts of the server using various interfaces and lines, and performs various server functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 302, and by calling data stored in memory 302. Optionally, the processor 301 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 301 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and application requests; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 301 and may be implemented as a separate chip.

[0136] The memory 302 may include random access memory (RAM) or read-only memory. Optionally, the memory 302 may include a non-transitory computer-readable storage medium. The memory 302 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 302 may include a program storage area and a data storage area. The program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch functionality, sound playback functionality, image playback functionality, etc.), instructions for implementing the various method embodiments described above, etc. The data storage area may store data involved in the various method embodiments described above. Optionally, the memory 302 may also be at least one storage device located remotely from the aforementioned processor 301.

[0137] like Figure 3 As shown, the memory 302, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an application program for diagnosing and locking grounding faults in charging piles.

[0138] exist Figure 3In the electronic device 300 shown, the user interface 303 is mainly used to provide an input interface for the user and to obtain the user input data; while the processor 301 can be used to call the application program stored in the memory 302 for charging pile grounding fault diagnosis and locking control. When executed by one or more processors, the electronic device performs one or more of the methods described in the above embodiments.

[0139] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0140] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0141] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some service interfaces; indirect couplings or communication connections between devices or units may be electrical or other forms.

[0142] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0143] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0144] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, portable hard drives, magnetic disks, or optical disks.

[0145] The foregoing description is merely an exemplary embodiment of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Those skilled in the art will readily conceive of other embodiments of this disclosure upon considering the specification and practical application disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not described in this disclosure.

Claims

1. A charging pile ground fault diagnosis and locking control method, characterized in that, The method includes: Acquire the charging station's plug-in status signal and continuously collect the live wire to neutral wire voltage and live wire to ground wire voltage of the power supply line; Extract the instantaneous value sequence of the live wire to neutral wire voltage within a preset time window, and calculate the total harmonic distortion score, voltage event score, and fundamental frequency offset score based on the instantaneous value sequence. The total harmonic distortion score, the voltage event score, and the fundamental frequency offset score are weighted and summed to obtain the total power grid environment score. The power grid environment mode of the charging pile is determined based on the total power grid environment score, and the corresponding safety threshold, recovery threshold, anomaly confirmation time, and recovery confirmation time are determined based on the power grid environment mode. When the plug-in status signal indicates that the plug is not plugged in, calculate the voltage ratio between the live wire and ground voltage and the live wire and neutral voltage. If the voltage ratio is less than the safety threshold and the duration reaches the abnormal confirmation duration, the charging pile will be placed in a ground fault lockout state and charging operation will be prohibited. When the charging pile is in the ground fault locked state, if the plug-in status signal changes to plugged-in state, the ground fault locked state is maintained and charging is prohibited. When the charging pile is in the ground fault locked state, if the plug-in status signal indicates the unplugged state and the preset ground fault recovery condition is met, the ground fault locked state is released and charging operation is allowed; wherein, the preset ground fault recovery condition includes the voltage ratio being greater than or equal to the recovery threshold and continuing for the recovery confirmation duration.

2. The method of claim 1, wherein, The step of extracting the instantaneous value sequence of the live-to-neutral voltage within a preset time window, and calculating the total harmonic distortion score, voltage event score, and fundamental frequency offset score based on the instantaneous value sequence, specifically includes: The instantaneous value sequence is subjected to a fast Fourier transform to obtain the spectrum, and the fundamental amplitude and each harmonic amplitude are extracted from the spectrum. The real-time total harmonic distortion is calculated based on the fundamental amplitude and each harmonic amplitude. The difference between the real-time total harmonic distortion (THD) and the reference THD is calculated, and the difference is compared with multiple preset deviation thresholds. The THD score is obtained based on the comparison results. Calculate the effective voltage value corresponding to the instantaneous value sequence. When the effective voltage value exceeds the preset upper and lower limits of the rated voltage, it is recorded as a voltage event. When the absolute value of the instantaneous value sequence exceeds a preset transient peak threshold, it is recorded as a transient overvoltage event; The total number of occurrences of the voltage events and transient overvoltage events within the preset time window is counted, and the voltage event score is calculated based on the total number of occurrences. The zero-crossing timestamps of consecutive zero-crossing points in the same direction are identified from the instantaneous value sequence, and the time difference between two adjacent zero-crossing timestamps is calculated as the real-time period, and the reciprocal of the real-time period is used as the real-time frequency. Extract the maximum offset of the real-time frequency relative to the preset reference frequency within the preset time window, and calculate the fundamental frequency offset score based on the maximum offset.

3. The method of claim 1, wherein, The power grid environment mode includes a severe power grid environment mode and a normal power grid environment mode. The power grid environment mode of the charging pile is determined based on the total power grid environment score, and the corresponding safety threshold, recovery threshold, anomaly confirmation time, and recovery confirmation time are determined based on the power grid environment mode. Specifically, this includes: The total score of the power grid environment is compared with a severe environment score threshold and a normal environment score threshold, wherein the severe environment score threshold is greater than the normal environment score threshold; When the total score of the power grid environment is greater than the severe environment score threshold, the charging pile is determined to be in a severe power grid environment mode. When the charging pile is in the adverse power grid environment mode, and the total score of the power grid environment calculated for a preset number of consecutive times is less than or equal to the normal environment score threshold, it is determined that the charging pile is switched to the normal power grid environment mode. The basic safety threshold, basic recovery threshold, anomaly confirmation time, and recovery confirmation time are matched according to the power grid environment mode in which the charging pile is located; Obtain the voltage ratio sequence within a preset historical time period, and calculate the basic recovery threshold and the basic safety threshold based on the voltage ratio sequence to obtain the safety threshold and the recovery threshold.

4. The method of claim 3, wherein, The step of calculating the basic recovery threshold and the basic safety threshold based on the voltage ratio sequence to obtain the safety threshold and the recovery threshold specifically includes: Calculate the standard deviation of the voltage ratios in the voltage ratio sequence; The ratio of the total power grid environment score to the baseline environment score is calculated to obtain the environmental degradation coefficient. The environmental degradation coefficient is then multiplied by the basic first factor to obtain the first adjustment factor. The safety threshold is obtained by subtracting the product of the standard deviation of the voltage ratio and the first adjustment factor from the basic safety threshold. The environmental degradation coefficient is multiplied by the basic second factor, and a hysteresis compensation constant is added to obtain the second adjustment factor; The recovery threshold is obtained by adding the product of the standard deviation of the voltage ratio and the second adjustment factor to the basic recovery threshold.

5. The method of claim 1, wherein, When the charging pile is in the ground fault locked state, if the charging gun status signal changes to "charging gun inserted", then after maintaining the ground fault locked state and prohibiting charging, the method further includes: The first average fire line to ground voltage during the first target time period before the gun insertion status signal changes to the inserted gun status, and the second average fire line to ground voltage during the second target time period after the inserted gun status changes. Calculate the rate of change of the live wire to ground voltage before and after inserting the gun based on the first average live wire to ground voltage and the second average live wire to ground voltage. A first active detection signal is injected into the protective grounding circuit of the charging pile, and the response current of the first active detection signal in the protective grounding circuit is collected; Based on the first active detection signal and the response current, the real-time loop impedance characteristics are calculated. The rate of change of the live wire to ground voltage is compared with a preset rate of change threshold, and the real-time loop impedance characteristics are matched with a preset fault characteristic database. If the rate of change of the voltage between the live wire and the ground wire is greater than the preset rate of change threshold, and the real-time loop impedance characteristic matches the impedance drop in the preset fault characteristic database, then it is determined that the ground fault originates from the vehicle end, and vehicle end illegal connection diagnostic information is generated. If the rate of change of the live wire to ground voltage is less than or equal to the preset rate of change threshold, or if the real-time loop impedance characteristics do not match the impedance drop, then the grounding fault is determined to originate from the charging pile body, and grounding fault diagnosis information of the charging pile body is generated.

6. The method of claim 1, wherein, When the charging pile is in the ground fault locked state, if the charging gun status signal changes to "charging gun inserted", then after maintaining the ground fault locked state and prohibiting charging, the method further includes: When the charging pile is in the ground fault locked state and the plug-in status signal is the plugged-in state, a ground fault alarm message is output through the human-machine interface of the charging pile. The human-computer interaction interface synchronously displays a gun-unplugging guidance prompt, which guides the user to unplug the charging gun. When a change in the plug-in status signal is detected, it is confirmed that the user has unplugged the charging gun according to the unplugging guidance information, and the plug-in status signal is determined to have changed from the plugged-in state to the unplugged state.

7. The method of claim 1, wherein, If the gun insertion status signal indicates the uninserted state and the preset ground fault recovery conditions are met, then the ground fault lockout state is released, specifically including: When the charging pile is in the unplugged state, the voltage ratio is calculated, a second active detection signal is injected into the protective grounding circuit of the charging pile, and the current circuit impedance characteristics are continuously calculated based on the collected current response current. Determine whether the voltage ratio is greater than or equal to the recovery threshold and continue for the recovery confirmation duration, or determine whether the current circuit impedance characteristics have recovered to the normal impedance range and continue for the impedance confirmation duration; If the voltage ratio is greater than or equal to the recovery threshold and continues for the recovery confirmation duration, or if the current loop impedance characteristics recover to the normal impedance range and continue for the impedance confirmation duration, then it is determined that the ground fault recovery condition is met, and the ground fault lockout state is released.

8. A charging pile ground fault diagnosis and locking control system, characterized in that, The system includes an acquisition unit, a processing unit, a locking unit, and a recovery unit. The acquisition unit acquires the charging pile's plug-in status signal and continuously collects the live wire to neutral wire voltage and live wire to ground wire voltage of the power supply line. The processing unit extracts the instantaneous value sequence of the live wire to neutral wire voltage within a preset time window, and calculates the total harmonic distortion score, voltage event score, and fundamental frequency offset score based on the instantaneous value sequence. The total harmonic distortion score, the voltage event score, and the fundamental frequency offset score are weighted and summed to obtain the total power grid environment score. The power grid environment mode of the charging pile is determined based on the total power grid environment score, and the corresponding safety threshold, recovery threshold, anomaly confirmation time, and recovery confirmation time are determined based on the power grid environment mode. When the charging gun status signal indicates that the charging gun is not plugged in, the voltage ratio of the live wire to ground voltage to the live wire to neutral voltage is calculated. If the voltage ratio is less than the safety threshold and the duration reaches the abnormal confirmation duration, the locking unit will place the charging pile in a ground fault lockout state and prohibit charging operations; if the charging gun status signal changes to "gun inserted" while the charging pile is in the ground fault lockout state, the ground fault lockout state will be maintained and charging will be prohibited. When the charging pile is in the ground fault locked state, if the plug-in status signal indicates the unplugged state and the preset ground fault recovery conditions are met, the recovery unit releases the ground fault locked state and allows charging operation; wherein, the preset ground fault recovery conditions include the voltage ratio being greater than or equal to the recovery threshold and continuing for the recovery confirmation duration.

9. An electronic device, comprising: The device includes a processor, a memory, a user interface, and a network interface. The memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory to cause the electronic device to perform the method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed, perform the method as described in any one of claims 1-7.