Electromagnetic lock constant current control method and device
By digitally processing and frequency domain analysis of the power supply voltage and coil current signals, accurate identification and dynamic compensation of voltage fluctuations and current disturbances are achieved, solving the problem of insufficient control precision of electromagnetic locks and improving the stability and reliability of electromagnetic locks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUIZHOU KAISHENG ELECTRONIC TECH CO LTD
- Filing Date
- 2026-02-13
- Publication Date
- 2026-05-15
AI Technical Summary
Existing electromagnetic lock control methods cannot effectively cope with current instability caused by power supply voltage fluctuations and coil parameter changes, affecting the reliability and consistency of operation.
By acquiring power supply voltage and coil current signals, anti-aliasing filtering and synchronous sampling are performed. Combined with analog-to-digital conversion, voltage disturbance and current disturbance spectrum are calculated, frequency domain feature analysis and parameter mapping compensation are performed, dynamic compensation and disturbance suppression of current response are achieved, and the drive signal is optimized to achieve closed-loop constant current control.
It improves the control accuracy and response speed of the electromagnetic lock, enhances the system's anti-interference capability, and ensures the high stability and reliability of the electromagnetic lock under complex working conditions.
Smart Images

Figure CN122044286A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of constant current control technology, and in particular to a method and apparatus for constant current control of an electromagnetic lock. Background Technology
[0002] Currently, in the actual operation of electromagnetic locks, fluctuations in power supply voltage directly affect the stability of the coil current. Furthermore, the coil's resistance and inductance parameters change in real time with temperature, magnetic saturation, and current magnitude, creating dynamic coupling. This coupling effect makes the current susceptible to interference, leading to electromagnetic attraction fluctuations or response delays, affecting the reliability and consistency of the action. To ensure the long-term stable operation of the intelligent lock control board, a control method capable of simultaneously addressing voltage fluctuations and time-varying parameters is needed. This method must integrate the real-time monitoring capabilities of intelligent sensors to accurately identify and dynamically compensate for voltage and current disturbances, thereby achieving high-precision constant current control.
[0003] In a current technology, the electromagnetic lock control method first samples the coil current to obtain a real-time current signal, compares it with a preset target current value, and calculates the deviation. This deviation is then fed into a proportional, integral, and derivative circuit, each operating according to pre-set fixed coefficients. The outputs of the three circuits are then summed to form the final drive voltage control command. This command is converted into an actual voltage signal by a power drive circuit and continuously applied to the electromagnetic lock coil. Throughout the control process, the proportional, integral, and derivative coefficients remain constant, unaffected by fluctuations in the power supply voltage or changes in the coil's resistance and inductance due to temperature or magnetic saturation. The system adjusts based solely on the current deviation, lacking both a power supply voltage feedforward compensation mechanism and an online identification and correction mechanism for the coil's dynamic parameters. Traditional control relies on fixed parameters, making it unable to accurately distinguish the source of disturbances during voltage fluctuations and coil parameter changes, leading to adjustment lag and oscillations. This significantly deviates from the high-precision and highly adaptable control goals pursued by intelligent lock control boards.
[0004] Therefore, existing technologies cannot improve the control precision of electromagnetic locks. Summary of the Invention
[0005] This invention provides a constant current control method and device for electromagnetic locks to improve the control accuracy of electromagnetic locks.
[0006] Firstly, in order to solve the above-mentioned technical problems, the present invention provides an electromagnetic lock constant current control method, comprising: Acquire power supply voltage signal and coil current signal; The power supply voltage signal and the coil current signal are subjected to anti-aliasing filtering and synchronous sampling to obtain a voltage analog sequence and a current analog sequence. The voltage analog sequence and the current analog sequence are then converted from analog to digital to obtain a digital voltage value and a digital current value. Based on the digital voltage value, the difference between the digital voltage value and the preset standard voltage is calculated, and the calculation result is smoothed and estimated to obtain the voltage disturbance amount; Based on the voltage disturbance and the digital current value, the current deviation is extracted, and the extraction result is subjected to frequency domain feature analysis to obtain the current disturbance spectrum; Based on the current disturbance spectrum, the dominant frequency component and amplitude are extracted, and the extraction result is calculated according to the preset parameter mapping relationship and superimposed on the preset reference duty cycle value. The adjustment drive signal is obtained through conversion. Based on the adjusted drive signal and the digital current value, the expected current value is extracted, and the difference between the extracted result and the digital current value is calculated. The calculation result is then subjected to linear fitting and error analysis to obtain the fitting residual index. Based on the fitting residual index, the current response at the next moment is deduced, and the deduction results are weighted and corrected to obtain the predicted current value. Based on the absolute value of the difference between the predicted current value and the digital current value, the feedback correction amount is obtained by querying the preset deviation gain mapping table and superimposed on the adjustment drive signal to obtain the optimized drive signal. The optimized drive signal is output to the power drive circuit of the electromagnetic lock, and the optimized drive signal output is dynamically updated based on the latest coil current feedback to complete closed-loop constant current control.
[0007] In one optional implementation, the step of performing anti-aliasing filtering on the power supply voltage signal and the coil current signal and obtaining a voltage analog sequence and a current analog sequence through synchronous sampling, and performing analog-to-digital conversion on the voltage analog sequence and the current analog sequence to obtain digital voltage values and digital current values, includes: Based on the power supply voltage signal and the coil current signal, high-frequency noise is suppressed by an anti-aliasing low-pass filter to obtain voltage waveform signals and current waveform signals. Based on the voltage waveform signal and the current waveform signal, the signal amplitude is maintained at equal time points by a synchronous sample-and-hold circuit to obtain the voltage analog sequence and the current analog sequence. The amplitudes of the voltage analog sequence and the current analog sequence are converted into binary digital values by an analog-to-digital converter to obtain voltage digital data and current digital data. When the fluctuation amplitude of adjacent values in the voltage digital data or the current digital data exceeds the preset noise tolerance threshold, noise smoothing is performed by calculating the arithmetic mean of the corresponding values in the voltage digital data and the current digital data within a preset time window to obtain a smoothed voltage digital sequence and a smoothed current digital sequence. When the fluctuation amplitude of adjacent values in the voltage digital data and the current digital data does not exceed the preset noise tolerance threshold, the voltage digital data is used as the smoothed voltage digital sequence, and the current digital data is used as the smoothed current digital sequence. The digital voltage value and the digital current value are obtained by multiplying each digital value of the smoothed voltage digital sequence and the smoothed current digital sequence by a preset scaling factor and adding a preset constant offset.
[0008] In one optional implementation, the step of calculating the difference between the digital voltage value and a preset standard voltage based on the digital voltage value, and smoothing the calculation result to obtain the voltage disturbance, includes: By calculating the algebraic difference between the digital voltage value and the preset standard voltage and taking the absolute value, the instantaneous voltage fluctuation amplitude sequence is obtained; Based on the instantaneous voltage fluctuation amplitude sequence, the changing trend is optimally estimated using the Kalman filter algorithm, and dynamic correction is performed based on the optimal estimation result and the preset observation noise variance to obtain the voltage disturbance.
[0009] In one optional implementation, the step of extracting the current deviation based on the voltage disturbance and the digital current value, and performing frequency domain feature analysis on the extraction result to obtain the current disturbance spectrum, includes: Based on the voltage disturbance and the digital current value, the power frequency fundamental component is filtered out by a notch filter to obtain the current deviation time-domain sequence. The current deviation time-domain sequence is transformed from the time domain to the frequency domain using the Fast Fourier Transform algorithm to obtain current deviation spectrum data containing complex values of frequency points. Based on the current deviation spectrum data, the amplitude features are extracted by calculating the magnitude of the complex values at the frequency points to obtain a set of frequency amplitudes; Based on the set of frequency amplitudes, a two-dimensional data table containing frequency points and corresponding amplitudes is established to obtain the current disturbance spectrum.
[0010] In one optional implementation, the step of extracting the dominant frequency component and amplitude based on the current disturbance spectrum, calculating the compensation amount of the extraction result according to a preset parameter mapping relationship and superimposing it onto a preset reference duty cycle value, and obtaining the adjustment drive signal through conversion includes: Based on the current disturbance spectrum, the frequency point with the largest amplitude and the corresponding frequency point amplitude are extracted to obtain the maximum spectrum amplitude data; Based on the maximum spectral amplitude data and the preset frequency-control parameter mapping relationship, the voltage compensation amount is obtained by using a PID algorithm to control the compensation amount. The voltage compensation amount is superimposed onto a preset reference duty cycle value using an adder to obtain a corrected duty cycle value; Based on the corrected duty cycle value, the value is converted into a square wave signal by pulse width modulation to obtain the adjustment drive signal.
[0011] In one optional implementation, the step of extracting a expected current value based on the adjusted drive signal and the digital current value, performing a difference calculation between the extracted result and the digital current value, and performing linear fitting and error analysis on the calculation result to obtain a fitting residual index includes: The adjustment drive signal is converted into a current value using a pre-built coil electrical model to obtain the expected current value; Based on the expected current value and the digital current value, a discrete residual sequence is obtained by calculating the difference between the values at the same time. Based on the discrete residual sequence, linear regression analysis is performed using the least squares method to obtain the regression slope value; The mean square error of the discrete residual sequence is calculated to obtain the fluctuation intensity index; The weighted sum of the absolute values of the fluctuation intensity index and the regression slope is used to obtain the fitting residual index.
[0012] In one optional implementation, the step of extrapolating the current response at the next time step based on the fitted residual index, and then weighting and correcting the extrapolation results to obtain the predicted current value, includes: When the fitting residual index is less than the preset fitting residual threshold, the resistance correction factor and the inductance correction factor are obtained by recursively least squares estimation algorithm based on the fitting residual index. When the fitting residual index is not less than the fitting residual threshold, the preset original resistance correction factor and the preset original inductance correction factor are directly used as the resistance correction factor and the inductance correction factor. Multiply the preset coil reference resistance value by the resistance correction factor to obtain the resistance parameter, and multiply the preset coil reference inductance value by the inductance correction factor to obtain the inductance parameter; Based on the resistance parameters, the inductance parameters, and the adjustment drive signal, the response value of the coil at the next sampling moment is calculated using Ohm's law and the inductance volt-ampere relationship formula, thus obtaining the transient current response value. When the absolute deviation between the transient current response value and the preset target current value is less than the preset allowable error range, the transient current response value is directly used as the predicted current value. When the absolute deviation between the transient current response value and the target current value is not less than the allowable error range, the predicted current value is obtained by weighted averaging the target current value and the transient current response value.
[0013] In one optional implementation, the step of querying a preset deviation gain mapping table to obtain a feedback correction amount based on the absolute value of the difference between the predicted current value and the digital current value, and then adding it to the adjusted drive signal to obtain an optimized drive signal, includes: The current deviation is obtained by calculating the difference between the predicted current value and the digital current value; Based on the absolute value of the current deviation, the adjustment gain coefficient is determined by querying a preset deviation gain mapping table; Multiply the current deviation by the adjustment gain coefficient to obtain the feedback correction amount; The feedback correction amount is superimposed onto the adjustment drive signal through an adder to obtain a composite control signal; The composite control signal is compared with the preset upper and lower limits of the drive signal and truncated to the allowable range to obtain the optimized drive signal.
[0014] In a second aspect, the present invention provides an electromagnetic lock constant current control device, comprising: The data acquisition module is used to acquire power supply voltage signals and coil current signals; The digital conversion module is used to perform anti-aliasing filtering on the power supply voltage signal and the coil current signal, and obtain a voltage analog sequence and a current analog sequence through synchronous sampling. The voltage analog sequence and the current analog sequence are then converted from analog to digital to obtain digital voltage value and digital current value. The estimation module is used to calculate the difference between the digital voltage value and the preset standard voltage based on the digital voltage value, and to perform a smooth estimation on the calculation result to obtain the voltage disturbance amount; The analysis module is used to extract the current deviation based on the voltage disturbance and the digital current value, and to perform frequency domain feature analysis on the extraction result to obtain the current disturbance spectrum. The adjustment module is used to extract the dominant frequency component and amplitude according to the current disturbance spectrum, calculate the compensation amount of the extraction result according to the preset parameter mapping relationship and superimpose it on the preset reference duty cycle value, and obtain the adjustment drive signal through conversion. The fitting module is used to extract the expected current value based on the adjustment drive signal and the digital current value, perform difference calculation between the extracted result and the digital current value, perform linear fitting and error analysis on the calculation result, and obtain the fitting residual index. The prediction module is used to extrapolate the current response at the next moment based on the fitting residual index, and to perform weighted correction on the extrapolation results to obtain the predicted current value. The optimization module is used to query a preset deviation gain mapping table based on the absolute value of the difference between the predicted current value and the digital current value to obtain a feedback correction amount, which is then added to the adjustment drive signal to obtain an optimized drive signal. The output module is used to output the optimized drive signal to the power drive circuit of the electromagnetic lock, and dynamically update the output of the optimized drive signal based on the latest coil current feedback to complete closed-loop constant current control.
[0015] Compared with the prior art, the present invention has the following beneficial effects: (1) This invention acquires power supply voltage and coil current signals and performs digital processing. By combining smooth estimation of voltage disturbance and frequency analysis of current disturbance spectrum, it achieves accurate identification of voltage fluctuation and current disturbance, providing a high-precision input data basis for constant current control of electromagnetic lock.
[0016] (2) This invention extracts the dominant frequency component and compensates the parameter mapping of the current disturbance spectrum, generates an adjustment driving signal in real time, and combines the linear fitting and error analysis of the expected current and the actual current to achieve dynamic compensation and disturbance suppression of the current response, thereby improving the system's anti-interference capability.
[0017] (3) Based on the fitting residual index, the present invention extrapolates and weights the current at the next moment, and combines gain adjustment and signal limiting optimization to achieve real-time optimization and adaptive adjustment of the driving signal, effectively cope with the time-varying nature of coil parameters and external voltage fluctuations, and improve control accuracy and response speed.
[0018] (4) This invention achieves high-stability constant current control of electromagnetic lock under complex working conditions by using closed-loop control of suction stability monitoring, combined with voltage disturbance identification, current spectrum analysis, dynamic prediction and drive optimization, thereby improving the reliability and consistency of electromagnetic lock operation. Attached Figure Description
[0019] Figure 1 This is a flowchart illustrating the electromagnetic lock constant current control method provided in the first embodiment of the present invention; Figure 2 This is a schematic diagram of the electromagnetic lock constant current control device provided in the second embodiment of the present invention. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] Reference Figure 1 The first embodiment of the present invention provides an electromagnetic lock constant current control method, including the following steps: S11, acquire the power supply voltage signal and the coil current signal; S12, perform anti-aliasing filtering on the power supply voltage signal and the coil current signal, and obtain a voltage analog sequence and a current analog sequence through synchronous sampling. Perform analog-to-digital conversion on the voltage analog sequence and the current analog sequence to obtain digital voltage value and digital current value. S13, Based on the digital voltage value, calculate the difference between the digital voltage value and the preset standard voltage, and perform a smooth estimation on the calculation result to obtain the voltage disturbance amount; S14, based on the voltage disturbance and the digital current value, the current deviation is extracted, and the extraction result is subjected to frequency domain feature analysis to obtain the current disturbance spectrum; S15, based on the current disturbance spectrum, extract the dominant frequency component and amplitude, calculate the compensation amount of the extraction result according to the preset parameter mapping relationship and superimpose it on the preset reference duty cycle value, and obtain the adjustment drive signal through conversion; S16, Based on the adjustment drive signal and the digital current value, the expected current value is extracted, and the difference between the extracted result and the digital current value is calculated. The calculation result is linearly fitted and error analyzed to obtain the fitting residual index. S17. Based on the fitting residual index, the current response at the next moment is deduced, and the deduction result is weighted and corrected to obtain the predicted current value. S18. Based on the absolute value of the difference between the predicted current value and the digital current value, a preset deviation gain mapping table is consulted to obtain the feedback correction amount, which is then added to the adjustment drive signal to obtain the optimized drive signal. S19, the optimized drive signal is output to the power drive circuit of the electromagnetic lock, and the optimized drive signal output is dynamically updated based on the latest coil current feedback to complete the closed-loop constant current control.
[0022] In step S11, the power supply voltage signal and the coil current signal are acquired.
[0023] Specifically, the power supply voltage signal originates from the output of the DC or AC power supply that powers the electromagnetic lock. It is measured and converted in real time by a voltage sensor (e.g., a resistor divider network and an isolated operational amplifier), outputting an analog voltage signal proportional to the instantaneous value of the power supply voltage. The coil current signal originates from a current sampling resistor or current transformer connected in series in the electromagnetic lock coil circuit. It is measured by the voltage across the sampling resistor or the secondary current of the transformer, and then converted into an analog voltage signal proportional to the instantaneous value of the coil current by a signal conditioning circuit. Both the power supply voltage signal and the coil current signal are continuously varying analog voltage signals, and their amplitude range matches the measurement range designed for the system. These two analog variables serve as inputs for subsequent steps.
[0024] In step S12, the power supply voltage signal and the coil current signal are subjected to anti-aliasing filtering and synchronous sampling to obtain a voltage analog sequence and a current analog sequence. The voltage analog sequence and the current analog sequence are then converted from analog to digital to obtain a digital voltage value and a digital current value.
[0025] In one specific implementation, based on the power supply voltage signal and the coil current signal, high-frequency noise is suppressed by an anti-aliasing low-pass filter to obtain voltage waveform signals and current waveform signals. Based on the voltage waveform signal and the current waveform signal, the signal amplitude is maintained at equal time points by a synchronous sample-and-hold circuit to obtain the voltage analog sequence and the current analog sequence. The amplitudes of the voltage analog sequence and the current analog sequence are converted into binary digital values by an analog-to-digital converter to obtain voltage digital data and current digital data. When the fluctuation amplitude of adjacent values in the voltage digital data or the current digital data exceeds the preset noise tolerance threshold, noise smoothing is performed by calculating the arithmetic mean of the corresponding values in the voltage digital data and the current digital data within a preset time window to obtain a smoothed voltage digital sequence and a smoothed current digital sequence. When the fluctuation amplitude of adjacent values in the voltage digital data and the current digital data does not exceed the preset noise tolerance threshold, the voltage digital data is used as the smoothed voltage digital sequence, and the current digital data is used as the smoothed current digital sequence. The digital voltage value and the digital current value are obtained by multiplying each digital value of the smoothed voltage digital sequence and the smoothed current digital sequence by a preset scaling factor and adding a preset constant offset.
[0026] Specifically, the power supply voltage signal and the coil current signal are input to a pre-designed anti-aliasing low-pass filter. This filter employs a Butterworth second-order low-pass filter circuit. The target cutoff frequency of the filter is determined based on the system sampling frequency, and this cutoff frequency is set to half of the sampling frequency. A standard dual-op-amp active filter circuit topology is used, which includes two operational amplifiers and an external resistor-capacitor network. During the design, a capacitor value is first selected from a commonly used standard value sequence as a reference capacitor. Then, the resistance value of the first reference resistor is obtained by calculating the target cutoff frequency with a constant determined by pi and the reference capacitor value. Next, based on the specific damping coefficient required by the Butterworth filter to achieve the maximum flat passband response, the resistance value of the second critical resistor is calculated using the relationship between this damping coefficient and the obtained reference resistor value. The resistance or capacitance values of other resistors and capacitors in the circuit are determined sequentially according to the fixed proportional relationship specified in the selected circuit topology with the aforementioned reference components. High-frequency noise components in the power supply voltage signal and the coil current signal are attenuated by this filter, resulting in smooth voltage and current waveform signals at the output.
[0027] The voltage and current waveforms are then fed into a synchronous sample-and-hold circuit. This circuit consists of an analog switch and a capacitor holder, driven by a common clock signal. At each rising edge of the clock signal, the circuit simultaneously captures the instantaneous amplitudes of the voltage and current waveforms at that moment and holds these two amplitudes on separate capacitors until the next clock edge. This process is repeated at each equally spaced sampling point, thereby generating two time-aligned discrete amplitude sequences: a voltage analog sequence and a current analog sequence.
[0028] The analog voltage and current sequences are then input to an analog-to-digital converter (ADC). This ADC employs a successive approximation architecture with a 16-bit resolution. The ADC sequentially reads each analog amplitude from the analog voltage and current sequences, converting it into a 16-bit binary digital value. All conversion results are arranged in chronological order to obtain the digital voltage and digital current data, respectively.
[0029] The preset noise margin threshold is used to determine whether there is noise in the data that needs to be smoothed. This threshold is determined by analyzing long-term historical voltage and current digital data collected by the system under static operating conditions without external interference. Specifically, the absolute values of the differences between adjacent sampling points in these historical data sequences are sorted in ascending order, and the 95th percentile value after sorting is taken as the noise margin threshold.
[0030] The system sequentially checks the digital voltage and current data. For any given data sequence, it calculates the absolute value of the difference between each value and its preceding value. If the absolute value of any difference exceeds the noise tolerance threshold, the sequence is considered to be affected by noise. For sequences deemed disturbed, the system uses a moving average method for smoothing. This method sets a fixed-length time window. For each data point in the sequence, it calculates the arithmetic mean of all data points within the time window centered on that point, and replaces the original data point with this average. After this processing, smoothed voltage and current digital sequences are obtained. If the absolute value of the difference between all adjacent values in the voltage and current digital data does not exceed the noise tolerance threshold, the original voltage digital data is directly used as the smoothed voltage digital sequence, and the original current digital data is directly used as the smoothed current digital sequence.
[0031] Finally, scaling transformation is performed on the smoothed voltage and current digital sequences. The preset scaling factor is determined based on the sensor sensitivity and the analog-to-digital converter (ADC) range. In the calculation, the voltage scaling factor equals the rated voltage measurement range of the power supply voltage sensor divided by its output analog signal range, and then divided by the digital range of the ADC voltage channel; the current scaling factor equals the rated current measurement range of the current sensor divided by its output analog signal range, and then divided by the digital range of the ADC current channel. This factor is used to convert digital quantities into values with actual physical units. A preset constant offset is used to correct for zero-point drift of the sensor. Each digital value in the smoothed voltage digital sequence is multiplied by the voltage scaling factor and then added to the voltage constant offset to obtain the digital voltage value sequence. Similarly, each digital value in the smoothed current digital sequence is multiplied by the current scaling factor and then added to the current constant offset to obtain the digital current value sequence. The digital voltage and digital current value sequences are the final digital voltage and digital current values.
[0032] In step S13, the difference between the digital voltage value and the preset standard voltage is calculated based on the digital voltage value, and the calculation result is smoothed and estimated to obtain the voltage disturbance.
[0033] In one specific implementation, the instantaneous voltage fluctuation amplitude sequence is obtained by calculating the algebraic difference between the digital voltage value and the preset standard voltage and taking the absolute value. Based on the instantaneous voltage fluctuation amplitude sequence, the changing trend is optimally estimated using the Kalman filter algorithm, and dynamic correction is performed based on the optimal estimation result and the preset observation noise variance to obtain the voltage disturbance.
[0034] Specifically, the system reads each voltage value from the digital voltage value sequence and performs the following calculations sequentially. First, it calculates the algebraic difference between the current voltage value and a preset standard voltage, i.e., subtracting the standard voltage from the current voltage value. Then, it takes the absolute value of this difference to obtain the instantaneous voltage fluctuation amplitude at that sampling moment. This process is repeated for each voltage value in the digital voltage value sequence to generate an instantaneous voltage fluctuation amplitude sequence of the same length as the input sequence.
[0035] Based on the instantaneous voltage fluctuation amplitude sequence, the Kalman filter algorithm is used to optimally estimate the voltage fluctuation trend and output a smoothed voltage disturbance. The implementation process of the Kalman filter algorithm is as follows: The algorithm maintains two state variables: an estimated value of the voltage disturbance and the uncertainty of that estimated value. At each new sampling moment, the algorithm performs a prediction step, using the state estimate from the previous moment and a preset system process model to predict the state at the current moment. Then, an update step is initiated, where the algorithm acquires the measured value at the current moment. A preset observation noise variance is used to characterize the uncertainty of the measured value. This variance is determined during the system calibration phase by the squared deviation of the long-term collected digital voltage values under stable power supply conditions from their average value. The algorithm calculates the difference (i.e., innovation) between the predicted state and the current measured value, and corrects the state estimate based on the covariance of the predicted state, the observation noise variance, and a pre-calculated gain coefficient (Kalman gain), while simultaneously updating the uncertainty of the state. The Kalman gain determines whether the algorithm trusts the predicted value more or the new measured value more; its calculation depends on the prediction covariance and the observation noise variance. After this correction, the optimal estimated voltage disturbance value for the current moment is obtained, and the state covariance is updated to prepare for the calculation at the next moment. The above prediction and update steps are performed sequentially on each value in the instantaneous voltage fluctuation amplitude sequence, ultimately outputting a smoothed estimated voltage disturbance value sequence of the same length as the input sequence. This sequence represents the voltage disturbance value required for the next step.
[0036] In step S14, the current deviation is extracted based on the voltage disturbance and the digital current value, and the extraction result is subjected to frequency domain feature analysis to obtain the current disturbance spectrum.
[0037] In one specific implementation, based on the voltage disturbance and the digital current value, the power frequency fundamental component is filtered out by a notch filter to obtain the current deviation time-domain sequence. The current deviation time-domain sequence is transformed from the time domain to the frequency domain using the Fast Fourier Transform algorithm to obtain current deviation spectrum data containing complex values of frequency points. Based on the current deviation spectrum data, the amplitude features are extracted by calculating the magnitude of the complex values at the frequency points to obtain a set of frequency amplitudes; Based on the set of frequency amplitudes, a two-dimensional data table containing frequency points and corresponding amplitudes is established to obtain the current disturbance spectrum.
[0038] Specifically, the system first processes the digital current value based on the magnitude of the voltage disturbance to extract the current deviation. This processing is achieved through a notch filter. The center frequency of this notch filter is set to the fundamental power frequency, and its bandwidth is set to a narrow value to filter out the periodic fundamental component introduced by the power grid frequency in the current signal. The digital current value sequence serves as the input to this filter, which processes each current sample value in the sequence sequentially and outputs a new sequence. This new sequence is the current deviation time-domain sequence with the fundamental power frequency component removed.
[0039] Subsequently, a Fast Fourier Transform (FFT) algorithm is applied to the current deviation time-domain sequence to transform it from the time domain to the frequency domain. The algorithm first checks the length of the sequence; if the length is not a power of two, it extends the length to the nearest power of two by padding the end with zeros. Next, the algorithm performs a series of butterfly operations on the sequence, rearranging and combining data points in a specific order to ultimately calculate a set of complex numbers. This set of complex numbers represents the current deviation spectrum data, where each complex number corresponds to a specific frequency point. The real and imaginary parts of the complex number together characterize the amplitude and phase information of that frequency component in the original time-domain signal.
[0040] Based on the obtained current deviation spectrum data, the system extracts the amplitude characteristics of each frequency point. For each complex number in the spectrum data, the sum of the squares of its real part and the squares of its imaginary part is calculated, and then the square root of this sum is taken to obtain the amplitude corresponding to that frequency point. This calculation is performed on all frequency points to obtain a set of frequency amplitudes, which is a list in which each item contains a frequency value and its corresponding amplitude.
[0041] Finally, the system constructs a current disturbance spectrum based on the set of frequency amplitudes. This spectrum forms a two-dimensional data table with frequency on the x-axis and the corresponding amplitude on the y-axis. Each row in the table records a frequency point and its corresponding amplitude. All frequency points are arranged in ascending order of their frequency values. This complete two-dimensional data table is the current disturbance spectrum, which clearly shows the energy distribution of the current deviation signal at different frequencies.
[0042] In step S15, the dominant frequency component and amplitude are extracted according to the current disturbance spectrum. The extraction result is calculated according to the preset parameter mapping relationship and superimposed on the preset reference duty cycle value. The adjustment drive signal is obtained by conversion.
[0043] In one specific implementation, based on the current disturbance spectrum, the frequency point with the largest amplitude and the corresponding frequency point amplitude are extracted to obtain the maximum spectrum amplitude data; Based on the maximum spectral amplitude data and the preset frequency-control parameter mapping relationship, the voltage compensation amount is obtained by using a PID algorithm to control the compensation amount. The voltage compensation amount is superimposed onto a preset reference duty cycle value using an adder to obtain a corrected duty cycle value; Based on the corrected duty cycle value, the value is converted into a square wave signal by pulse width modulation to obtain the adjustment drive signal.
[0044] Specifically, the system iterates through the current disturbance spectrum data table and finds the record with the largest amplitude value. It then extracts the corresponding frequency point value and its amplitude; these two data points constitute the maximum spectrum amplitude data.
[0045] The compensation amount is calculated based on the maximum spectral amplitude data and the preset frequency-control parameter mapping relationship. The preset frequency-control parameter mapping relationship is a lookup table established through experimental calibration. The table is constructed as follows: during the development phase of the electromagnetic lock control system, a series of simulated current disturbance signals with known frequencies and amplitudes are injected into the system. The changes in the controller output compensation amount required to eliminate these disturbances are recorded, ultimately forming a mapping relationship from the disturbance frequency and amplitude to the suggested proportional, integral, and derivative control parameters. Based on the currently extracted disturbance frequency and amplitude, the system queries this mapping relationship to obtain a set of corresponding suggested control parameters, including the proportional coefficient, integral coefficient, and derivative coefficient.
[0046] Based on this set of control parameters, the system employs a PID algorithm for compensation control. The PID algorithm uses the difference between the preset target current value and the current actual digital current value as the input deviation. This deviation is sequentially processed by three parallel computational stages. The proportional stage multiplies the current deviation by a proportional coefficient. The integral stage multiplies the sum of historical deviations by an integral coefficient. The derivative stage multiplies the difference between the current deviation and the deviation at the previous time step by a derivative coefficient. The outputs of these three stages are algebraically summed, and the sum is then passed through a limiter to obtain the voltage compensation amount.
[0047] The calculated voltage compensation is input into an adder. The other input to the adder is a preset reference duty cycle value, which is pre-calculated based on the average current required for steady-state operation of the electromagnetic lock. The adder algebraically adds the voltage compensation to the reference duty cycle value, outputting the corrected duty cycle value.
[0048] Finally, based on the corrected duty cycle value, an adjustment drive signal is generated by the pulse width modulation (PWM) drive circuit. The PWM drive circuit internally contains a counter and a comparator. The counter generates a fixed-frequency triangular or sawtooth wave carrier signal. The comparator compares the corrected duty cycle value with the instantaneous value of the carrier signal. When the carrier signal value is lower than the threshold corresponding to this ratio, the comparator outputs a high level; otherwise, it outputs a low level. Thus, the comparator outputs a square wave signal, the proportion of its high-level time to the entire cycle being equal to the corrected duty cycle value. This square wave signal is the adjustment drive signal, used to directly drive the power switching device of the electromagnetic lock coil.
[0049] In step S16, the expected current value is extracted based on the adjustment drive signal and the digital current value, and the difference between the extracted result and the digital current value is calculated. The calculation result is then subjected to linear fitting and error analysis to obtain the fitting residual index.
[0050] In one specific implementation, the adjustment drive signal is converted into a current value using a pre-built coil electrical model to obtain the expected current value; Based on the expected current value and the digital current value, a discrete residual sequence is obtained by calculating the difference between the values at the same time. Based on the discrete residual sequence, linear regression analysis is performed using the least squares method to obtain the regression slope value; The mean square error of the discrete residual sequence is calculated to obtain the fluctuation intensity index; The weighted sum of the absolute values of the fluctuation intensity index and the regression slope is used to obtain the fitting residual index.
[0051] Specifically, the system first converts the adjustment drive signal into the expected current value using a pre-built coil electrical model. This coil electrical model is a discrete-time state-space model, constructed based on the physical characteristics of the electromagnetic lock coil. The model's state variable is the coil current, and the input is the equivalent average voltage of the adjustment drive signal. The model parameters include the coil's reference resistance and reference inductance values. These two parameters are derived from the nominal DC resistance and inductance values of the coil provided in the electromagnetic lock product specifications and have been verified through actual measurements at rated temperatures. The model describes the dynamic response of the current using a difference equation. This equation determines the expected current value at the current sampling moment, which is equal to the current value at the previous sampling moment multiplied by a coefficient A, plus the current equivalent input voltage multiplied by a coefficient B. Coefficient A is obtained by dividing the inductance reference value by the sum of the inductance reference value and the resistance reference value multiplied by the sampling period. Coefficient B is obtained by dividing the sampling period by the sum of the inductance reference value and the resistance reference value multiplied by the sampling period. The value of the sampling period is consistent with the sampling rate of the system data acquisition. During the model usage phase, the system adjusts the duty cycle of the driving signal in each sampling period, converting it into an equivalent voltage, which is then used as the model input. Based on the current state at the previous moment, the current input voltage, and the model parameters, the model calculates the expected current value at the current sampling moment. This calculation is repeated for all sampling moments to generate a sequence of expected current values of the same length as the sampling sequence.
[0052] The system aligns the expected current value sequence with the digital current value sequence for the same time period. For each sampling time, the algebraic difference between the expected current value and the digital current value at that time is calculated, i.e., the expected current value is subtracted from the digital current value. This calculation is performed for all sampling times to obtain a discrete residual sequence.
[0053] Linear regression analysis is performed using the least squares method based on the discrete residual sequence. This method aims to find a straight line that minimizes the sum of squared vertical distances between this line and all data points in the discrete residual sequence. Specifically, the sampling time point indices of the discrete residual sequence are used as independent variables, and the residual values are used as dependent variables. The optimal regression slope and intercept are obtained by solving a system of two linear equations in two variables concerning the slope and intercept of the line. The regression slope characterizes the trend of the residuals over time.
[0054] Simultaneously, the mean squared error of the discrete residual sequence is calculated as an indicator of volatility intensity. The calculation process is as follows: First, the arithmetic mean of all values in the discrete residual sequence is calculated. Then, the difference between each residual value and this mean is calculated, and this difference is squared. Finally, the arithmetic mean of all these squared values is calculated to obtain the mean squared error. This value quantifies the degree of volatility of the residual sequence around its mean.
[0055] The weighted sum of the fluctuation intensity index and the absolute value of the regression slope is used to obtain the fitting residual index. Preset weighting coefficients are used to balance the impact of trend bias and random fluctuations on the overall fitting quality. These weighting coefficients are determined by collecting multiple sets of discrete residual sequences under different operating conditions and their corresponding manually evaluated control effectiveness levels during the system debugging phase. By analyzing this data, a set of weighting coefficients was found that maximizes the correlation between the calculated fitting residual index and the manually evaluated level. Finally, the fitting residual index equals the fluctuation intensity index multiplied by the weighting coefficient A, plus the absolute value of the regression slope multiplied by the weighting coefficient B, where the sum of weighting coefficient A and weighting coefficient B is one.
[0056] In step S17, the current response at the next moment is deduced based on the fitting residual index, and the deduction result is weighted and corrected to obtain the predicted current value.
[0057] In one specific implementation, when the fitting residual index is less than a preset fitting residual threshold, the resistance correction factor and the inductance correction factor are obtained by recursively least squares estimation algorithm based on the fitting residual index. When the fitting residual index is not less than the fitting residual threshold, the preset original resistance correction factor and the preset original inductance correction factor are directly used as the resistance correction factor and the inductance correction factor. Multiply the preset coil reference resistance value by the resistance correction factor to obtain the resistance parameter, and multiply the preset coil reference inductance value by the inductance correction factor to obtain the inductance parameter; Based on the resistance parameters, the inductance parameters, and the adjustment drive signal, the response value of the coil at the next sampling moment is calculated using Ohm's law and the inductance volt-ampere relationship formula, thus obtaining the transient current response value. When the absolute deviation between the transient current response value and the preset target current value is less than the preset allowable error range, the transient current response value is directly used as the predicted current value. When the absolute deviation between the transient current response value and the target current value is not less than the allowable error range, the predicted current value is obtained by weighted averaging the target current value and the transient current response value.
[0058] Specifically, the system compares the fitting residual index with a preset fitting residual threshold. When the fitting residual index is less than the threshold, the system determines that the current coil electrical model matches the actual situation well, but there are slight deviations, requiring parameter fine-tuning based on new data. In this case, the system uses a recursive least squares estimation algorithm for factor recursion. This algorithm maintains two recursive factors: a resistance correction factor and an inductance correction factor, both initially set to one. The algorithm's input consists of the adjustment drive signal, digital current value, and expected current value within the most recent historical data window. The algorithm updates the resistance and inductance correction factors online by minimizing the sum of squared errors between the expected current value and the digital current value. Each time new sampled data arrives, the algorithm uses the old factor estimates, the new data, and a preset forgetting factor to calculate new estimates of the resistance and inductance correction factors using a recursive formula.
[0059] When the fitting residual index is not less than the preset fitting residual threshold, the system determines that the model deviation is large, and online recursion may be unreliable. The system will use preset original resistance correction factors and preset original inductance correction factors. These two original factors are fixed values determined offline based on typical operating condition experimental data during the electromagnetic lock's factory calibration, and are both set to one. In this case, the original resistance correction factor is directly used as the resistance correction factor, and the original inductance correction factor is used as the inductance correction factor.
[0060] After obtaining the resistance correction factor and inductance correction factor, the system performs parameter calculations. The preset coil reference resistance value is multiplied by the resistance correction factor to obtain the resistance parameters used for the current calculation. The preset coil reference inductance value is multiplied by the inductance correction factor to obtain the inductance parameters used for the current calculation.
[0061] Based on the aforementioned resistance and inductance parameters, as well as the current adjustment drive signal, the system calculates the current response value of the coil at the next sampling moment using Ohm's law and the inductance-voltage relationship formula. The calculation process involves taking the digital current value at the current sampling moment as the initial state, combining it with the equivalent voltage, resistance, and inductance parameters at the next moment, solving the first-order differential equation describing the coil current dynamics, and calculating the transient current response value at the next moment.
[0062] A preset allowable error range is used to evaluate the usability of the simulation results. This range is set according to the accuracy requirements of the electromagnetic lock control, for example, ±5% of the target current value. The system calculates the absolute deviation between the transient current response value and the preset target current value. When this absolute deviation is less than the allowable error range, the system considers the simulation results reliable and directly outputs the transient current response value as the final predicted current value.
[0063] When the absolute deviation is not less than the allowable error range, the system considers that the model-based inference may deviate from the target. In this case, the system uses a weighted average calculation to correct the result. Preset weights are used to balance the model-inferred value and the target value. The weight coefficients are determined based on the statistical distribution of model prediction errors in historical data, with the goal of making the final predicted value as close as possible to the actual subsequent sampled value in the long term. Specifically, the target current value is multiplied by the weight coefficient C, and the transient current response value is multiplied by the weight coefficient D, where the sum of weight coefficient C and weight coefficient D is one. The result is the weighted and corrected predicted current value.
[0064] In step S18, based on the absolute value of the difference between the predicted current value and the digital current value, a preset deviation gain mapping table is consulted to obtain the feedback correction amount, which is then superimposed on the adjustment drive signal to obtain the optimized drive signal.
[0065] In one specific implementation, the current deviation is obtained by calculating the difference between the predicted current value and the digital current value; Based on the absolute value of the current deviation, the adjustment gain coefficient is determined by querying a preset deviation gain mapping table; Multiply the current deviation by the adjustment gain coefficient to obtain the feedback correction amount; The feedback correction amount is superimposed onto the adjustment drive signal through an adder to obtain a composite control signal; The composite control signal is compared with the preset upper and lower limits of the drive signal and truncated to the allowable range to obtain the optimized drive signal.
[0066] Specifically, the system first calculates the algebraic difference between the predicted current value and the digital current value, that is, subtracting the digital current value from the predicted current value to obtain the current deviation. This value reflects the instantaneous error between the model prediction and the actual measurement.
[0067] Based on the absolute value of the current deviation, the adjustment gain coefficient is determined by consulting a preset deviation gain mapping table. This preset deviation gain mapping table is a lookup table constructed through system simulation and experimental calibration. Its purpose is to achieve nonlinear gain adjustment to provide appropriate control strength under different error levels. The table is constructed as follows: during the development phase of the electromagnetic lock control system, a series of step or disturbance signals of different amplitudes are applied to the system, and the system's response characteristics under different fixed gains are observed. The gain value that enables a fast and stable system response at each deviation level is selected, ultimately forming a mapping relationship from the absolute value of the deviation to the suggested gain coefficient. The system then finds the gain coefficient corresponding to the closest deviation level in the mapping table based on the calculated absolute value of the current deviation, and uses this as the current adjustment gain coefficient.
[0068] The feedback correction is obtained by multiplying the current deviation by the adjustment gain coefficient. This operation amplifies the current deviation, and the amplification factor is determined by the adjustment gain coefficient.
[0069] The feedback correction is added to the adjustment drive signal via an adder. One input to the adder is the adjustment drive signal, and the other input is the feedback correction. The adder performs algebraic addition, and the output is a composite control signal, which is a new duty cycle value.
[0070] Finally, the composite control signal is amplitude-limited to obtain the optimized drive signal. The system presets an upper and lower limit value for the drive signal, which is determined based on the safe operating area of the electromagnetic lock power device, the maximum allowable current of the coil, and the minimum holding current. The system compares the composite control signal with the upper and lower limits. If the composite control signal is greater than the upper limit value, it is forcibly set to the upper limit value; if the composite control signal is less than the lower limit value, it is forcibly set to the lower limit value; if the composite control signal is between the upper and lower limits, it remains unchanged. The duty cycle value obtained after this truncation process is the optimized drive signal, which will be used to generate the pulse width modulation square wave that ultimately drives the electromagnetic lock coil.
[0071] In step S19, the optimized drive signal is output to the power drive circuit of the electromagnetic lock, and the output of the optimized drive signal is dynamically updated based on the latest coil current feedback to complete the closed-loop constant current control.
[0072] Specifically, the system first inputs the optimized drive signal to the power drive circuit of the electromagnetic lock. Based on the duty cycle represented by the optimized drive signal, the power drive circuit generates a corresponding high-frequency pulse width modulation square wave voltage, which is applied to both ends of the electromagnetic lock coil, thereby generating a controlled current in the coil.
[0073] To implement suction stability monitoring for closed-loop constant current control, the system needs to evaluate the current control effect and may make fine adjustments. Suction stability is indirectly reflected by monitoring the stability of the coil current, as a stable current is the basis for generating a stable electromagnetic suction force. The system acquires the latest coil current signal after the current optimized drive signal in real time and immediately performs the complete processing flow described in steps S12 to S18, but the processing is limited to the latest sampling point and its adjacent historical data window.
[0074] The processing flow includes digitizing the new digital current value, calculating the new voltage disturbance, analyzing the new current disturbance spectrum, generating a new adjustment drive signal, calculating a new fitting residual index, performing a new current prediction, and finally generating a new set of optimized drive signals for the latest state. The system compares this newly generated optimized drive signal with the currently executing optimized drive signal.
[0075] A preset drive signal update threshold is used to determine whether an output update is needed. This threshold is determined by analyzing the statistical distribution of changes in the optimized drive signal between adjacent control cycles during historical control processes. Specifically, the absolute values of these changes are sorted in ascending order, and the 90th percentile value is taken as the drive signal update threshold. The absolute difference between the newly generated optimized drive signal and the current optimized drive signal is calculated.
[0076] If the absolute difference is less than the drive signal update threshold, the system determines that the current control effect is stable and the suction force is within an acceptable range. It then maintains the current optimized drive signal unchanged and continues to output it to the power drive circuit.
[0077] If the absolute difference is not less than the drive signal update threshold, the system determines that the current or suction force is showing signs of instability. At this time, the system uses the newly generated optimized drive signal as the latest optimized drive signal and immediately updates the output to the power drive circuit to quickly correct any possible deviations.
[0078] By continuously and cyclically executing the above-described process of monitoring the suction stability and dynamically updating the drive signal, the system forms a closed-loop constant current control circuit. This circuit can adaptively adjust the drive signal according to the real-time state of the electromagnetic lock coil current, ensuring that the coil current is stable near the target value, thereby indirectly ensuring the stability of the electromagnetic suction force and realizing constant current control of the electromagnetic lock.
[0079] Reference Figure 2 The second embodiment of the present invention provides an electromagnetic lock constant current control device, comprising: The data acquisition module is used to acquire power supply voltage signals and coil current signals; The digital conversion module is used to perform anti-aliasing filtering on the power supply voltage signal and the coil current signal, and obtain a voltage analog sequence and a current analog sequence through synchronous sampling. The voltage analog sequence and the current analog sequence are then converted from analog to digital to obtain digital voltage value and digital current value. The estimation module is used to calculate the difference between the digital voltage value and the preset standard voltage based on the digital voltage value, and to perform a smooth estimation on the calculation result to obtain the voltage disturbance amount; The analysis module is used to extract the current deviation based on the voltage disturbance and the digital current value, and to perform frequency domain feature analysis on the extraction result to obtain the current disturbance spectrum. The adjustment module is used to extract the dominant frequency component and amplitude according to the current disturbance spectrum, calculate the compensation amount of the extraction result according to the preset parameter mapping relationship and superimpose it on the preset reference duty cycle value, and obtain the adjustment drive signal through conversion. The fitting module is used to extract the expected current value based on the adjustment drive signal and the digital current value, perform difference calculation between the extracted result and the digital current value, perform linear fitting and error analysis on the calculation result, and obtain the fitting residual index. The prediction module is used to extrapolate the current response at the next moment based on the fitting residual index, and to perform weighted correction on the extrapolation results to obtain the predicted current value. The optimization module is used to query a preset deviation gain mapping table based on the absolute value of the difference between the predicted current value and the digital current value to obtain a feedback correction amount, which is then added to the adjustment drive signal to obtain an optimized drive signal. The output module is used to output the optimized drive signal to the power drive circuit of the electromagnetic lock, and dynamically update the output of the optimized drive signal based on the latest coil current feedback to complete closed-loop constant current control.
[0080] It should be noted that the electromagnetic lock constant current control device provided in this embodiment of the invention is used to execute all the process steps of the electromagnetic lock constant current control method in the above embodiment. The working principle and beneficial effects of the two are one-to-one, so they will not be described again.
[0081] In summary, this invention achieves precise control of the LCM05-32-396 lock control board, an industrial-grade control module integrating high-precision power management, multi-channel independent lock control, and intelligent communication. The product employs digital signal processing and real-time feedback adjustment mechanisms, operates within a DC 9V–24V voltage range, and can simultaneously drive 32 electromagnetic locks. Each lock supports 9–18V, current less than 3A, and impedance 4–8Ω, with a static current below 35mA, demonstrating excellent energy efficiency. Its built-in anti-interference circuitry and adaptive voltage compensation algorithm ensure stable output and consistent, reliable lock operation even under power fluctuations or external electromagnetic interference. The product features an industrial-grade RS485 communication interface, supporting adjustable baud rates from 2400–115200, with a packet loss rate of less than one in a million. It is suitable for medium- to long-distance, multi-node cascaded networking applications, and a single system can be expanded to a maximum of 130 boards. The onboard digital display shows the status in real time and features multiple protection mechanisms including adjustable address, one-button unlocking, short-circuit protection with self-recovery, and lightning and electrostatic discharge protection. It operates in temperatures ranging from -40℃ to 85℃ and humidity from 0% to 90%RH, with an IPX7 protection rating, making it suitable for various harsh indoor and outdoor environments. This lock control board is used in applications such as express delivery lockers, smart lockers, and filing cabinets, demonstrating high stability and long lifespan in actual operation. Its control strategy, based on real-time current monitoring and dynamic adjustment, significantly reduces the risk of lock failure due to voltage fluctuations or temperature rises, improving the overall system's success rate and response consistency.
[0082] This invention also provides an electronic device. The electronic device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, such as an electromagnetic lock constant current control program. When the processor executes the computer program, it implements the steps described in the various electromagnetic lock constant current control method embodiments above, for example... Figure 1 The step S11 shown. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the above system embodiments, such as the electromagnetic lock constant current control module.
[0083] For example, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device.
[0084] The electronic device may be a desktop computer, laptop, handheld computer, or smart tablet, etc. The electronic device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the above components are merely examples of electronic devices and do not constitute a limitation on the electronic device. It may include more or fewer components than described above, or combine certain components, or different components. For example, the electronic device may also include input / output devices, network access devices, buses, etc.
[0085] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the electronic device, connecting all parts of the electronic device via various interfaces and lines.
[0086] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0087] If the modules / units integrated into the electronic device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or system capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0088] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and 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 modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0089] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A constant current control method for an electromagnetic lock, characterized in that, include: Acquire power supply voltage signal and coil current signal; The power supply voltage signal and the coil current signal are subjected to anti-aliasing filtering and synchronous sampling to obtain a voltage analog sequence and a current analog sequence. The voltage analog sequence and the current analog sequence are then converted from analog to digital to obtain a digital voltage value and a digital current value. Based on the digital voltage value, the difference between the digital voltage value and the preset standard voltage is calculated, and the calculation result is smoothed and estimated to obtain the voltage disturbance amount; Based on the voltage disturbance and the digital current value, the current deviation is extracted, and the extraction result is subjected to frequency domain feature analysis to obtain the current disturbance spectrum; Based on the current disturbance spectrum, the dominant frequency component and amplitude are extracted, and the extraction result is calculated according to the preset parameter mapping relationship and superimposed on the preset reference duty cycle value. The adjustment drive signal is obtained through conversion. Based on the adjusted drive signal and the digital current value, the expected current value is extracted, and the difference between the extracted result and the digital current value is calculated. The calculation result is then subjected to linear fitting and error analysis to obtain the fitting residual index. Based on the fitting residual index, the current response at the next moment is deduced, and the deduction results are weighted and corrected to obtain the predicted current value. Based on the absolute value of the difference between the predicted current value and the digital current value, the feedback correction amount is obtained by querying the preset deviation gain mapping table and superimposed on the adjustment drive signal to obtain the optimized drive signal. The optimized drive signal is output to the power drive circuit of the electromagnetic lock, and the optimized drive signal output is dynamically updated based on the latest coil current feedback to complete closed-loop constant current control.
2. The electromagnetic lock constant current control method according to claim 1, characterized in that, The process of performing anti-aliasing filtering on the power supply voltage signal and the coil current signal, obtaining a voltage analog sequence and a current analog sequence through synchronous sampling, and then performing analog-to-digital conversion on the voltage analog sequence and the current analog sequence to obtain digital voltage values and digital current values includes: Based on the power supply voltage signal and the coil current signal, high-frequency noise is suppressed by an anti-aliasing low-pass filter to obtain voltage waveform signals and current waveform signals. Based on the voltage waveform signal and the current waveform signal, the signal amplitude is maintained at equal time points by a synchronous sample-and-hold circuit to obtain the voltage analog sequence and the current analog sequence. The amplitudes of the voltage analog sequence and the current analog sequence are converted into binary digital values by an analog-to-digital converter to obtain voltage digital data and current digital data. When the fluctuation amplitude of adjacent values in the voltage digital data or the current digital data exceeds the preset noise tolerance threshold, noise smoothing is performed by calculating the arithmetic mean of the corresponding values in the voltage digital data and the current digital data within a preset time window to obtain a smoothed voltage digital sequence and a smoothed current digital sequence. When the fluctuation amplitude of adjacent values in the voltage digital data and the current digital data does not exceed the preset noise tolerance threshold, the voltage digital data is used as the smoothed voltage digital sequence, and the current digital data is used as the smoothed current digital sequence. The digital voltage value and the digital current value are obtained by multiplying each digital value of the smoothed voltage digital sequence and the smoothed current digital sequence by a preset scaling factor and adding a preset constant offset.
3. The electromagnetic lock constant current control method according to claim 1, characterized in that, The step of calculating the difference between the digital voltage value and a preset standard voltage based on the digital voltage value, and smoothing the calculation result to obtain the voltage disturbance, includes: By calculating the algebraic difference between the digital voltage value and the preset standard voltage and taking the absolute value, the instantaneous voltage fluctuation amplitude sequence is obtained; Based on the instantaneous voltage fluctuation amplitude sequence, the changing trend is optimally estimated using the Kalman filter algorithm, and dynamic correction is performed based on the optimal estimation result and the preset observation noise variance to obtain the voltage disturbance.
4. The electromagnetic lock constant current control method according to claim 1, characterized in that, The process involves extracting the current deviation based on the voltage disturbance and the digital current value, and performing frequency domain feature analysis on the extraction result to obtain the current disturbance spectrum, including: Based on the voltage disturbance and the digital current value, the power frequency fundamental component is filtered out by a notch filter to obtain the current deviation time-domain sequence. The current deviation time-domain sequence is transformed from the time domain to the frequency domain using the Fast Fourier Transform algorithm to obtain current deviation spectrum data containing complex values of frequency points. Based on the current deviation spectrum data, the amplitude features are extracted by calculating the magnitude of the complex values at the frequency points to obtain a set of frequency amplitudes; Based on the set of frequency amplitudes, a two-dimensional data table containing frequency points and corresponding amplitudes is established to obtain the current disturbance spectrum.
5. The electromagnetic lock constant current control method according to claim 4, characterized in that, The process involves extracting the dominant frequency component and amplitude based on the current disturbance spectrum, calculating the compensation amount of the extraction result according to a preset parameter mapping relationship, and superimposing it onto a preset reference duty cycle value. The resulting adjustment drive signal is then obtained through conversion. Based on the current disturbance spectrum, the frequency point with the largest amplitude and the corresponding frequency point amplitude are extracted to obtain the maximum spectrum amplitude data; Based on the maximum spectral amplitude data and the preset frequency-control parameter mapping relationship, the voltage compensation amount is obtained by using a PID algorithm to control the compensation amount. The voltage compensation amount is superimposed onto a preset reference duty cycle value using an adder to obtain a corrected duty cycle value; Based on the corrected duty cycle value, the value is converted into a square wave signal by pulse width modulation to obtain the adjustment drive signal.
6. The electromagnetic lock constant current control method according to claim 1, characterized in that, The step involves extracting the expected current value based on the adjusted drive signal and the digital current value, calculating the difference between the extracted result and the digital current value, performing linear fitting and error analysis on the calculation result, and obtaining the fitting residual index, including: The adjustment drive signal is converted into a current value using a pre-built coil electrical model to obtain the expected current value; Based on the expected current value and the digital current value, a discrete residual sequence is obtained by calculating the difference between the values at the same time. Based on the discrete residual sequence, linear regression analysis is performed using the least squares method to obtain the regression slope value; The mean square error of the discrete residual sequence is calculated to obtain the fluctuation intensity index; The weighted sum of the absolute values of the fluctuation intensity index and the regression slope is used to obtain the fitting residual index.
7. The electromagnetic lock constant current control method according to claim 1, characterized in that, The step of extrapolating the current response at the next time step based on the fitted residual index, and then weighting and correcting the extrapolation results to obtain the predicted current value, includes: When the fitting residual index is less than the preset fitting residual threshold, the resistance correction factor and the inductance correction factor are obtained by recursively least squares estimation algorithm based on the fitting residual index. When the fitting residual index is not less than the fitting residual threshold, the preset original resistance correction factor and the preset original inductance correction factor are directly used as the resistance correction factor and the inductance correction factor. Multiply the preset coil reference resistance value by the resistance correction factor to obtain the resistance parameter, and multiply the preset coil reference inductance value by the inductance correction factor to obtain the inductance parameter; Based on the resistance parameters, the inductance parameters, and the adjustment drive signal, the response value of the coil at the next sampling moment is calculated using Ohm's law and the inductance volt-ampere relationship formula, thus obtaining the transient current response value. When the absolute deviation between the transient current response value and the preset target current value is less than the preset allowable error range, the transient current response value is directly used as the predicted current value. When the absolute deviation between the transient current response value and the target current value is not less than the allowable error range, the predicted current value is obtained by weighted averaging the target current value and the transient current response value.
8. The electromagnetic lock constant current control method according to claim 1, characterized in that, The step of obtaining an optimized drive signal by querying a preset deviation gain mapping table based on the absolute value of the difference between the predicted current value and the digital current value, and then adding the feedback correction amount to the adjustment drive signal, includes: The current deviation is obtained by calculating the difference between the predicted current value and the digital current value; Based on the absolute value of the current deviation, the adjustment gain coefficient is determined by querying a preset deviation gain mapping table; Multiply the current deviation by the adjustment gain coefficient to obtain the feedback correction amount; The feedback correction amount is superimposed onto the adjustment drive signal through an adder to obtain a composite control signal; The composite control signal is compared with the preset upper and lower limits of the drive signal and truncated to the allowable range to obtain the optimized drive signal.
9. An electromagnetic lock constant current control device, characterized in that, include: The data acquisition module is used to acquire power supply voltage signals and coil current signals; The digital conversion module is used to perform anti-aliasing filtering on the power supply voltage signal and the coil current signal, and obtain a voltage analog sequence and a current analog sequence through synchronous sampling. The voltage analog sequence and the current analog sequence are then converted from analog to digital to obtain digital voltage value and digital current value. The estimation module is used to calculate the difference between the digital voltage value and the preset standard voltage based on the digital voltage value, and to perform a smooth estimation on the calculation result to obtain the voltage disturbance amount; The analysis module is used to extract the current deviation based on the voltage disturbance and the digital current value, and to perform frequency domain feature analysis on the extraction result to obtain the current disturbance spectrum. The adjustment module is used to extract the dominant frequency component and amplitude according to the current disturbance spectrum, calculate the compensation amount of the extraction result according to the preset parameter mapping relationship and superimpose it on the preset reference duty cycle value, and obtain the adjustment drive signal through conversion. The fitting module is used to extract the expected current value based on the adjustment drive signal and the digital current value, perform difference calculation between the extracted result and the digital current value, perform linear fitting and error analysis on the calculation result, and obtain the fitting residual index. The prediction module is used to extrapolate the current response at the next moment based on the fitting residual index, and to perform weighted correction on the extrapolation results to obtain the predicted current value. The optimization module is used to query a preset deviation gain mapping table based on the absolute value of the difference between the predicted current value and the digital current value to obtain a feedback correction amount, which is then added to the adjustment drive signal to obtain an optimized drive signal. The output module is used to output the optimized drive signal to the power drive circuit of the electromagnetic lock, and dynamically update the output of the optimized drive signal based on the latest coil current feedback to complete closed-loop constant current control.