Insulation Detection of Electric Vehicles by Using FPGA-Based Recursive-Least-Squares Algorithm

: The principal reason for why electric vehicles are required to serve as an alternative to the more widespread gasoline and petroleum-based vehicles used in modern times is due to the use of an environmentally conscious means of transportation or to circumvent the tumultuous economic dealings of the compressed natural gas and petroleum industries. There is a growing daily need for large, high-voltage e-mobilities, mostly driven by anticipated advancements in electric vehicle technology. Consequently, all of the various components of these vehicles must be able to be accommodated within a limited and compact space. The battery is an essential component in e-mobility. The insulation, health monitoring, and problem diagnostics of lithium-ion (Li-ion) batteries are of utmost importance in ensuring these vehicles’ safety and efficient functioning. Real-time and fast insulation detection techniques are required to ensure safety in high-voltage (HV) vehicles and to avoid insulation failure. This paper used the Recursive-Least-Squares (RLS) algorithm because it is computationally efficient for building the insulation detection system. Based on the RLS technique, we proposed field programmable gate array (FPGA)-based algorithms and implemented them using VHDL coding. The FPGA is very fast at detection, and the error is lower. We validated the FPGA results with MATLAB simulation results from the existing literature, and the errors are much less when using FPGAs. An experimental hardware platform was also created to validate the proposed FPGA technique with various motor and resistive loadings on electric vehicles (EVs).


Introduction
In response to the global need to decrease reliance on fossil fuels and traditional transportation-related emissions, much research and production is being performed on electric vehicles (EVs) [1][2][3][4].Li-ion batteries are crucial to the electric vehicle's energy storage system.The safety of the system is seriously jeopardized by the large-scale battery module, particularly the electrical insulation [5][6][7][8][9].Insulation failure in a system can be caused by environmental causes such as rain erosion, vibrations, temperature, short circuit occurrences in the electrical circuits, and aged lines [10][11][12][13][14]. Thus, efficient and prompt insulation defect monitoring is essential to the system's safe operation.Researchers have proposed several detection approaches to identify insulation resistance in DC systems.Insulation detection strategies have been published in the literature [15][16][17].Methods like the voltmeter, the balanced and unbalanced bridge method, and marginal insulation detection are frequently employed.The voltmeter approach can only be used when conducting an offline measurement.The bridge-balanced method is a static measurement technique.
Instances where the bilateral insulating resistances decrease simultaneously are not a good fit for this method.When there is an excessive gap between the negative and positive insulating resistance, it is easy to trigger false alarms.
After a thorough literature review [18][19][20][21][22][23][24][25], this paper focused on battery insulation detection for safety reasons.For the insulation detection of the battery, which is a highvalue resistor linked between the battery and the vehicle's chassis so that the current cannot come into touch with the chassis, the theory of insulation resistance is employed in the literature [26,27].Therefore, the working circumstances of these components are quite complex, even after several safety components have been arranged.The power supply terminal insulation is susceptible to various corrosion scenarios and temperature, humidity, and vibration variations.These factors weaken the insulation of all equipment and increase the risk of short circuits [28][29][30][31].Therefore, when in touch with the body's chassis, each positive and negative battery terminal should have a particular resistance.In insulation detection, adaptive filtering techniques such as RLS and LMS are commonly utilized in signal processing and adaptive filtering [32,33].While both algorithms share the goal of minimizing the discrepancy between the desired and observed outputs by manipulating filter coefficients, they differ in their approaches and degrees of efficacy.The RLS method possesses some advantages compared to the LMS algorithm [34][35][36].The RLS algorithm exhibits faster convergence compared to the LMS algorithm, rendering it suitable for scenarios that demand prompt adaptability to changes in input data.The FPGAs offer several advantages when implementing adaptive filter algorithms, such as performing parallel processing, enabling them to execute multiple tasks simultaneously.This is advantageous for adaptive filter algorithms, as it allows for the parallel computation of filter coefficients, resulting in faster processing times.FPGAs are highly customizable, allowing designers to implement adaptive filter algorithms with specific requirements.This flexibility is beneficial for tailoring the hardware to the characteristics of the algorithm, optimizing performance, and potentially reducing power consumption.This paper proposes an FPGA solution for real-time insulation failure detection.Validated the FPGA results with the existing literature's MATLAB simulation results; the error is significantly less in the FPGA results.Improved FPGA results were observed and explained in detail in the Section 3.
Furthermore, an FPGA-based hardware experimental platform was created, with various motor and resistive loading experiments on electric cars being conducted to validate the suggested FPGA technique.
The rest of this study is organized as follows: Section 2 introduces the materials and methods, broadly discusses the insulation detection analysis and the battery simplified circuit model, and presents the traditional RLS algorithm and FPGA algorithm.Section 3 presents the simulation and experimental results, discussed in detail; and Section 4 presents the conclusion.

Materials and Methods
Figure 1 illustrates the equivalent circuit of the insulation resistance detection circuit model for detecting insulation resistance using the low-frequency signal injection method in the battery kit.The illustration showcases the primary constituents of a high-power supply for an electric car, including the inverter, motor, disconnectors, vehicle chassis, and battery circuit module.The genesis of the HV system has been investigated in the literature [10][11][12][13].The battery's insulation resistance counting model and voltage resistance values are considered [11,12] as the input values for Simulink and the proposed FPGA algorithm.According to Figure 1a,b, V bt denotes the battery kit terminal voltage, U s denotes the low-signal source, R 1 and R 2 are current-limiting resistances with values of R l m, and R f b denotes the feedback resistance for sampling the feedback voltage.The electric vehicle chassis is also referred to as ground (GND).It is crucial to assess the battery pack's positive and negative insulating resistance since the positive and negative electrodes experience the highest levels of leakage current [14,15].The positive side-insulation defect is depicted in Figure 1a, whereas a simplified version of the negative side-insulation defect is presented in Figure 1b.The battery pack voltage V bt can be defined as: I 1 and I 2 indicate the currents of mesh-1 and mesh-2.V f b is the feedback voltage.U s is the the voltage of the signal source.R c represents the negative insulation resistance.The circuit loop equations can be written when R 1 = R 2 = R lm , then the above equation is re-written as where The expression for the negative insulating resistance is The following equations demonstrate how the same strategy may be used to derive the positive insulation resistance R a .

Formulation of the RLS Algorithm
The RLS algorithm demonstrates superior performance in non-stationary situations, characterized by the fluctuating statistical properties of input signals across time.In such scenarios, it is worth noting that the performance of the LMS algorithm may be hindered due to the potential challenges associated with the step size parameter [37,38].Specifically, the necessity for the dynamic adjustment of this parameter might significantly impact the rate at which the algorithm adapts.When applied to small to intermediate-scale problems, the RLS algorithm is generally recognized as being more computationally efficient.The computational cost of each iteration of the RLS algorithm remains constant, while the computational complexity of the LMS algorithm grows exponentially as the number of filter taps rises.RLS can potentially enhance tracking performance in applications that are characterized by system fluctuations.LMS algorithms may take longer to converge or they may need extra steps, like pre-whitening, to be taken into account when there are correlated input signals.Maintaining a recursive estimate of the inverse correlation matrix achieves the RLS algorithm's memory efficiency.This enables the algorithm to update its parameters while maintaining constant memory requirements.On the other hand, the LMS algorithm necessitates the retainment of a record of input samples for every tap in the filter, leading to increased memory demands [39,40].
The RLS algorithms are formulated such that the total-squared-error E(n) at the nth iteration is denoted as [35][36][37][38][39] The standard least-squares method was changed by adding a "forgetting factor".λ m−j is added to each error term, making sure that 0 < λ < 1; then, Equation ( 8) is modified as follows: where u ′ (j) = √ λ m−j u(j) and y ′ (j) = √ λ m−j y(j).The λ factor provides more weight to recent data points, enabling the filter to monitor changing statistics in the input data.The convolution sum determines the FIR filter output.
Additionally, for stationary waveforms, Equation ( 8) at time step n reduces to By setting the derivatives of each of the filter coefficients c k (m) to zero, it is feasible to determine the optimum FIR filter coefficients c k (m), k = 0,. .., N − 1, that minimize E ′ (m).
This generates a series of linear equations with the best coefficients feasible, c k (m).Equation ( 12) can be used to formulate these equations in matrix form. where is a N × N matrix, and is a column vector of the recent input history and is a N × 1 column vector.
The approach leverages the outcome of the preceding step to obtain the updated inverse of Q(m) using an iterative algebraic procedure.One may compute Q(m) iteratively, as demonstrated by Equation (16).
To compute the filter coefficients in Equation ( 15), we need a recursive formulation of Q − 1(m) based on Q − 1(m − 1).From Equation (19), the matrix inversion is The equation Q −1 (m) may be calculated using the output of the prior time-step and the current input history vector x(m) thanks to an algebraic recursion relationship.Equation ( 18) also allows for the recursive definition of V(m).
Therefore, the RLS filter design is based on Equations ( 15), ( 20) and (21).Assuming the establishment of a vector of Kalman gains with N dimensions, Rewriting Equation (20) allows us to The filter update equation, Equation (15), can be written as a recursion.
Using the preceding set of filter coefficients, It is observed that y(m) = x T (m)c(m − 1) is the convolution sum that generates the filter output y(m).As a result, Above are the equations for updating the recursive filter concerning the filter output error and Kalman gains.The Pseudo code for the RLS algorithm is shown in the section of Algorithm 1.
For the subsequent iteration, update the filter coefficientsc(m) = c(m − 1) + G(m)e(m) The experimental setup created and simulated the FPGA algorithms using VHDL coding based on the RLS.FPGA has several advantages over the LMS and RLS filters in insulation detection systems.FPGAs provide low-latency processing, making them suitable for applications where real-time or near-real-time processing is essential, such as communication systems, audio processing, or control systems.Users can reprogram FPGAs to adapt to changing algorithmic requirements or to implement different adaptive filter structures.This reconfigurability benefits scenarios where the algorithm needs updating or modification.The FPGAs are more energy-efficient for specific computations than are software-based implementations running on general-purpose processors.This is particularly important in applications where power consumption is a critical factor.The implementation of the FPGA algorithms is shown in the Algorithm 2 section.for i in 0 to N-1 loop P_x := P_x + to_fixed(x_reg(i), 8) * w(i); end loop; signal alpha : real := 1.0 / (lambda + P_x); -Update weight vector, for i in 0 to N-1 loop w(i) <= w(i) + alpha * error_reg(i); end loop; -Update P matrix P <= lambda * P + alpha * P_x * alpha; end if; end if; end process; function to_slv(data : real) return std_logic_vector is variable result : std_logic_vector(7 downto 0) := (others => '0'); begin result := std_logic_vector(resize(real(to_integer(signed(result)) + data), result'length)); return result; end function; function to_fixed(data : real; width : integer) return real is variable factor : real := 2.0 * * width; begin return data * factor; end function;

Results and Discussion
An experimental platform has been established to confirm the efficacy of the suggested insulation resistance estimate technique and to facilitate test verification.The voltage and resistance of the positive and negative battery connectors are 300 V and 2400 KΩ, respectively.The MATLAB simulation is simulated based on an unbalanced bridge circuit, and the signal injection method for analysis using the RLS method in R2022a MATLAB software.Four unique situations are categorized based on the battery terminal insulation under normal and fault conditions.All four conceivable conditions are confirmed using the RLS algorithm of the previous MATLAB findings, and the FPGA results are enhanced.

Constant voltage and constant resistance condition:
The MATLAB setup provided the system with a constant 300 V battery voltage, accompanied by noise.The system operates at a constant voltage of 300 V and maintains a positive constant insulation resistance of 220 KΩ.The filtration characteristics have allowed for a considerable improvement in the system's insulation resistance and battery performance, as tested by the RLS algorithm, and it can be observed in Figure 2. The RLS algorithm recursively keeps track of the inverse correlation matrix, allowing it to update its parameters while requiring less memory overall.The system's error has also decreased significantly, and its constant forgetting factor is 0.992, making it more stable.The error output of the system falls between −6.3177 and 5.488.

Constant voltage and variable resistance condition:
The battery pack's insulating resistance may fluctuate abruptly due to unforeseen circumstances, such as short circuits.For the insulation detection technique, this presents a more substantial real-time performance problem.In this state, the system is subjected to varying resistance and constant voltage.The resistance is changing by 20 KΩ, with a steady change starting at 150 KΩ and concentrating mainly at 220 KΩ.The test results shown above reflect a form of positive insulating resistance.The in-error output signal below varies in the range of −7 to 8 using the RLS algorithm, shown in Figure 3.The measured voltage has a lot of noise because of system noise and sampling precision.The direct measurement method's computation results suffer greatly due to this.Specifically, the feedback signal's amplitude gradually diminishes.This is a result of the split voltage on the feedback resistance decreasing as the insulation resistance increases; altering the resistance will cause the system to become less stable than it was previously.Similarly, practical outcomes have been observed for the insulation resistance on the negative side.This test condition demonstrates that the previously employed CVCR condition is stable when compared with the CVVR condition.
Variable voltage and constant resistance condition: A steady 220 KΩ of resistance and the battery voltage, which is added with noise, varies from 290 V to 330 V.In this test, the conditions of positive-side constant insulating resistance and variable voltage are considered.The RLS algorithm was utilized to test the system's battery terminal insulation resistance.The system is less stable than in the above two circumstances when the voltage varies.In this case, the algorithm's computation inaccuracy increases noticeably when there is a quick shift in battery voltage.Figure 4 shows the errors, ranging from −9 to 12.The voltage fluctuations cause a decrease in the system's stability.Researchers have noted similar experimental results on the negative side of the insulating resistance.This test condition demonstrates that the previously employed approach, which is CVVR, is appropriate when compared with VVCR.

Variable voltage and variable resistance condition:
The battery's resistance gradually changes from 150 KΩ, but it is primarily concentrated at around 220 KΩ.The change in resistance is 20 KΩ.The variable battery voltage fluctuates between 290 V and 330 V.The aforementioned test findings are seen in situations where the insulating resistance is not favorable, both because of sudden changes in the voltage and gradual changes in the resistance, which will make the system more unstable.Due to the slow changes in voltage and resistance, the system will not be as stable, and errors will occur.The error in this condition is very high, in the range of −25 to 15, as observed in Figure 5.The system undergoes the same condition with a negative constant insulating resistance.The RLS algorithm was utilized to assess the system's insulation resistance and battery performance.The system is less stable than in the preceding three circumstances when the voltage and resistance are varied.

FPGA Results and Discussion
The FPGA-based RLS algorithm verified the four distinct conditions of the insulation circuit model.The VHDL code for the RLS algorithm is produced, and Xilinx Vivado is used to simulate the results.The simulation results of the RLS algorithm, with clock, reset, constant voltage, constant resistance, variable voltage, variable resistance, enable, and desired voltage as inputs and anticipated output data, error output, filter weight data, and forgetting factor as outputs, are used in the FPGA kit.When the reset button is removed and the enable signal is in a high position, the system sends input to the FPGA for additional processing.The FPGA's high-speed performance yields a more precise and steady output.The system will become more stable as the frequency of changing the algorithm's weight rises.The update rate and estimation frequency are higher in this test setup because the data sampling will happen at a higher rate, and an improvement in the estimation of error has also been observed.An experimental setup was built to test the proposed FPGA algorithm for the above four MATLAB test conditions.The electric vehicle and insulation detection experimental setup configuration is shown in Figure 6.This experiment introduces the battery pack, controller, motor systems, resistive loading, and battery management system (BMS).The BMS is an electronic device that manages the rechargeable battery pack in a system.The main working principle of a BMS involves the monitoring and control of various parameters of the battery, such as its state of charge, temperature, and voltage.The motor and resistive loading are applied to the electric vehicle kit for the current and voltage variations.The insulation detection test bench components include a battery pack, a power supply module (0-5 A, 0-30 V), a highvoltage power supply module, a DC resistor, an FPGA-based insulation detector, a personal computer (PC), and a high-voltage power supply module.The battery pack achieves the desired voltage for the experiments by linking the cells both in series and in parallel.The battery pack supplies a high fixed voltage for the static experiment.To simulate insulation resistance, a resistor is utilized.We use the PC to store and to analyze the experimental data, which includes the voltage of the battery pack, the voltage of the injection signal, the voltage of the feedback signal, and the estimation value for the insulation resistance.The experiments are conducted at room temperature.The Artix 7 FPGA from Xilinx is used instead of the MCU to test the proposed method for improved expected results.The advanced FPGA is very suitable for handling insulation detection failures in EVs.All four conditions mentioned in the MATLAB Section 3 were practically tested using the Virtex 7 FPGA, and Xilinx Vivado software, and compared with the MATLAB results.The discussion included the improved FPGA results.Under CVCR conditions, the system's error output ranged from −2 to +3, showing that the system improved as compared to MATLAB in Figure 7. Researchers have also observed similar experimental findings regarding the negative side of insulating resistance.Under CVVR conditions, in Figure 8, the system's error output was observed to range from −4 to 6, indicating an improvement compared to the MATLAB results.Analogous experiments were performed to measure the insulating resistance on the negative side.Compared to FPGA CVVR, the system is stable under a constant resistance and voltage.In the VVCR conditions, the system's error output, which is within the range of −8 to 9, shows improvement compared to the MATLAB simulations in Figure 9. Similar experimental outcomes have also been conducted on the negative side.This test condition demonstrates that the previously employed approach is stable compared with the FPGA results of VVCR.
In the VVVR condition, the system's error output ranges from −9 to +10, indicating system improvement compared to the MATLAB results (Figure 10).This test scenario demonstrates that the previously employed technique is stable, and it collates with variable resistance and voltage conditions.

Conclusions
This paper looks into the insulation resistance of electric car battery packs, studies different insulation detection techniques, and designs and implements an adaptive RLS predictor in the hardware description language VHDL.The RLS was the most effective technique for adaptive filter implementation on FPGAs.The goal is to find an algorithm that can follow signals well, especially ones that change over time.FPGAs are well-suited for implementing RLS, due to their high-speed capabilities and register-rich architectures.In this paper, an FPGA-based detection model was developed, simulated, and compared to the existing literature results.In addition, the experimental results show that the proposed method can quickly track changes in insulation resistance.The output errors of the FPGAbased proposed method are much lower than the existing MATLAB results.The proposed FPGA method will be applied to heavy vehicles in future work.

Algorithm 1
Pseudo Code for the RLS Algorithm • Provide inputs source, and desired and battery voltage to the system • Calculate and estimate the Insulation Resistance and observe the error • Iterate for j = 0 to m− 1 samples • Update the input history vector x(m) using Desired output u(m).• Use the last set of filter values to figure out the filter output c(m − 1).

Figure 2 .
Figure 2. Insulation Resistance Error under CR and CV conditions.

Figure 3 .
Figure 3. Insulation Resistance Error under CV and VR conditions.

Figure 4 .
Figure 4. Insulation Resistance Error under VV and CR conditions.

Figure 5 .
Figure 5. Insulation Resistance Error under VR and VV conditions.

Figure 6 .
Figure 6.Experimental setup of electric vehicle and insulation detection test.

Figure 7 .
Figure 7. FPGA Hardware Simulation under CR and CV conditions.

Figure 8 .
Figure 8. FPGA Hardware Simulation under CV and VR conditions.

Figure 9 .
Figure 9. FPGA Hardware Simulation under VV and CR conditions.

Figure 10 .
Figure 10.FPGA Hardware Simulation under VV and VR conditions.