PWM signal acquisition methods, microcontrollers, and automotive seat control systems

By using dual compensation of the on-chip bandgap reference voltage and temperature signal of the MCU, combined with resistor voltage divider and RC filter circuit, accurate acquisition of PWM signal is achieved, solving the problems of increased cost of external comparators and temperature drift of built-in comparators, and improving the accuracy and reliability of seat detection.

CN123067280APending Publication Date: 2026-11-10DONGFENG COMML VEHICLE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611337510.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-31
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

In the existing technology, external comparators increase the overall vehicle manufacturing cost and PCB space occupation, while built-in on-chip comparators are affected by voltage and temperature drift and cannot meet the automotive-grade accuracy requirements, leading to misjudgment of seat position detection.

Method used

Dual compensation is achieved using the on-chip bandgap reference voltage and temperature signal of the MCU. The PWM signal is directly acquired through the on-chip comparator, and the signal is conditioned by resistor voltage divider and RC filter circuit. Combined with hardware-level self-diagnostic function, the acquisition accuracy is ensured.

Benefits of technology

It reduces overall vehicle manufacturing costs, saves PCB layout space, improves the accuracy and reliability of seat position detection, and supports platform compatibility and vehicle model adaptation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123067280A_ABST
    Figure CN123067280A_ABST
Patent Text Reader

Abstract

This invention discloses a method for acquiring PWM signals, a microcontroller, and an automotive seat control system, relating to the fields of electronic signal processing and automotive electronic control. The method includes the following steps: calculating voltage compensation and temperature compensation based on the acquired on-chip bandgap reference voltage signal and temperature signal of the microcontroller; compensating the comparison threshold voltage of the on-chip comparator of the microcontroller based on the voltage compensation and temperature compensation; acquiring the PWM signal; comparing the acquired PWM signal with the compensated comparison threshold voltage; and outputting the signal characteristic parameters of the PWM signal based on the comparison result. This invention implements dual compensation for the built-in comparator based on the on-chip bandgap reference voltage and temperature of the MCU to improve detection accuracy. This solution supports direct and accurate acquisition of PWM signals through the on-chip comparator, eliminating the need for an external comparator, thereby reducing overall vehicle manufacturing costs, effectively saving PCB layout space, and improving solution integration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of electronic signal processing and automotive electronic control, specifically to a method for acquiring PWM signals, a microcontroller, and an automotive seat control system. Background Technology

[0002] With the accelerated electrification and intelligentization of automobiles, the demand for state perception of vehicle actuators is increasing significantly. Current-type Hall effect sensors, with their core advantages of non-invasive sampling, high reliability, and strong anti-interference, have been widely deployed in core areas such as powertrain, chassis, and body, serving as a key component supporting closed-loop control of the electronic control system. Their output PWM signal needs to be sent to the MCU to collect and analyze status parameters such as position and speed.

[0003] Due to the limitations of the hardware characteristics of the on-chip comparator built into the MCU, its offset voltage temperature drift is generally... The above is about vehicle-mounted systems. After long-term operation under full-temperature conditions, threshold drift can accumulate to tens of millivolts, which can easily cause misjudgments in functions such as seat position detection and stall detection, failing to meet automotive-grade accuracy requirements. The current industry-standard mature solution is to add an independent automotive-grade comparator outside the MCU, along with a complete signal conditioning module including voltage division, filtering, hysteresis shaping, and level matching. This converts the original Hall output signal into a standard zero-return PWM signal that conforms to the MCU input specifications before sending it to the main control unit for acquisition and processing, ensuring the stability and reliability of seat adjustment signal detection from a hardware perspective.

[0004] However, external comparators increase the overall vehicle manufacturing cost, occupy a large amount of PCB space, and limit the platform compatibility and vehicle model adaptability of the solution. On the other hand, built-in on-chip comparators are affected by voltage and temperature drift and cannot meet the automotive-grade accuracy requirements. Summary of the Invention

[0005] This invention provides a PWM signal acquisition method, a microcontroller, and an automotive seat control system. It can solve the technical problems in the prior art where external comparators increase the overall vehicle manufacturing cost, occupy a large amount of PCB space, and limit the platform compatibility and vehicle model adaptability of the solution, while built-in on-chip comparators are affected by voltage and temperature drift and cannot meet the automotive-grade accuracy requirements.

[0006] In a first aspect, embodiments of the present invention provide a method for acquiring PWM signals, comprising the following steps: Acquire the on-chip bandgap reference voltage and temperature signals of the microcontroller; Calculate the voltage compensation amount and temperature compensation amount based on the on-chip bandgap reference voltage signal and the temperature signal; The comparison threshold voltage of the on-chip comparator of the microcontroller is compensated based on the voltage compensation amount and the temperature compensation amount. A PWM signal is acquired, which is a non-return-to-zero PWM signal. The acquired PWM signal is compared with the compensated comparison threshold voltage, and the signal characteristic parameters of the PWM signal are output based on the comparison result.

[0007] In conjunction with the first aspect, in one implementation, the step of comparing the acquired PWM signal with the compensated comparison threshold voltage, and then outputting the signal characteristic parameters of the PWM signal based on the comparison result, includes the following steps: The PWM signal is modulated into a conditioning signal that adapts to a preset voltage range; The conditioning signal and the comparison threshold voltage are compared, and a digital comparison signal is output based on the comparison result; The signal characteristic parameters of the PWM signal are output based on the digital comparison signal.

[0008] In conjunction with the first aspect, in one implementation, the acquisition of the PWM signal includes the following steps: The PWM signal is converted into a signal within a preset voltage range adapted to the microcontroller using a resistor divider sampling circuit.

[0009] In conjunction with the first aspect, in one embodiment, before acquiring the PWM signal and comparing the acquired PWM signal with the compensated comparison threshold voltage, the following steps are included: A preset test voltage is generated, and the preset test voltage is compared with the compensated comparison threshold voltage. A feedback state sequence is output based on the comparison result. The microcontroller is diagnosed as working properly based on the feedback state sequence.

[0010] In conjunction with the first aspect, in one implementation, after outputting the signal characteristic parameters of the PWM signal based on the comparison result, the following steps are included: Obtain the duty cycle and basic hysteresis of the PWM signal; Calculate the asymmetry coefficient based on the duty cycle; The comparison threshold voltage is adjusted based on the base hysteresis and the asymmetry coefficient for comparison of subsequent PWM signals.

[0011] In conjunction with the first aspect, in one embodiment, after outputting the signal characteristic parameters of the PWM signal based on the comparison result, the method further includes the following steps: Obtain the theoretical amplitude of the PWM signal; Determine whether the difference between the measured amplitude and the theoretical amplitude corresponding to the signal characteristic parameters exceeds a preset amplitude anomaly threshold; If so, it is determined that there is an abnormality in the acquisition of the PWM signal.

[0012] In conjunction with the first aspect, in one embodiment, calculating the voltage compensation amount and the temperature compensation amount includes the following steps: The temperature compensation amount is calculated based on the temperature signal and the preset DAC temperature coefficient.

[0013] In conjunction with the first aspect, in one implementation, the step of outputting the signal characteristic parameters of the PWM signal based on the comparison result includes the following steps: The rising edge timestamp and falling edge timestamp of the PWM signal are captured respectively; The high-level duration is calculated based on the difference between the rising edge timestamp and the falling edge timestamp, and the period of the PWM signal is calculated based on the difference between adjacent rising edge timestamps.

[0014] Secondly, embodiments of the present invention provide a microcontroller, including an analog-to-digital converter, a processor, a digital-to-analog converter, an on-chip comparator, and an input capture unit: The analog-to-digital converter is used to acquire the on-chip bandgap reference voltage signal and temperature signal of the microcontroller; The processor is configured to calculate voltage compensation and temperature compensation based on the on-chip bandgap reference voltage signal and the temperature signal. The digital-to-analog converter is used to output a compensation voltage to compensate the comparison threshold voltage of the on-chip comparator of the microcontroller based on the voltage compensation amount and the temperature compensation amount. The on-chip comparator is used to acquire a PWM signal and compare the acquired PWM signal with the compensated comparison threshold voltage. The input capture unit is used to output the signal characteristic parameters of the PWM signal based on the comparison result.

[0015] Thirdly, embodiments of the present invention provide an automotive seat control system, including the aforementioned microcontroller.

[0016] The beneficial effects of the technical solutions provided by the embodiments of the present invention include: This invention discloses a method for acquiring PWM signals, a microcontroller, and an automotive seat control system. The PWM signal acquisition method includes the following steps: acquiring the on-chip bandgap reference voltage signal and temperature signal of the microcontroller; calculating voltage compensation and temperature compensation based on the on-chip bandgap reference voltage signal and the temperature signal; compensating the comparison threshold voltage of the on-chip comparator of the microcontroller based on the voltage compensation and temperature compensation; acquiring a PWM signal, wherein the PWM signal is a non-return-to-zero PWM signal; comparing the acquired PWM signal with the compensated comparison threshold voltage; and outputting the signal characteristic parameters of the PWM signal based on the comparison result. This invention implements dual compensation for the built-in comparator based on the on-chip bandgap reference voltage and temperature of the MCU to improve detection accuracy. This solution supports direct and accurate acquisition of PWM signals through the on-chip comparator, eliminating the need for an external comparator, thereby reducing the overall vehicle manufacturing cost, effectively saving PCB layout space, and improving the integration of the solution. Attached Figure Description

[0017] Figure 1 This is a flowchart illustrating an embodiment of the PWM signal acquisition method of the present invention; Figure 2 For the present invention Figure 1 A detailed flowchart of step S40; Figure 3 This is a BIST timing diagram of the PWM signal acquisition method of the present invention; Figure 4 This is a schematic diagram of the asymmetric hysteresis of the PWM signal acquisition method of the present invention; Figure 5 This is an ADCCV sampling timing diagram of the PWM signal acquisition method of the present invention. Detailed Implementation

[0018] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. 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.

[0019] MCU stands for Microcontroller; ADC stands for Analog-to-Digital Converter; DAC stands for Digital-to-Analog Converter; CMP stands for On-Chip Comparator; ICU stands for Input Capture Unit; This represents the full-scale digital value of DC; the corresponding value for a 12-bit ADC is 4095. ADCCV represents amplitude-duty cycle cross-validation. BIST represents the hardware-level self-diagnostic program. Indicates the working point; Indicates the release point; Indicates the voltage compensation amount; Indicates the temperature compensation amount; COUT represents the comparator output; This represents the DAC code value after double compensation; Indicates the target output code value of the DAC; Indicates the duty cycle; Indicates the basic hysteresis (fixed value or adjusted according to noise level); This indicates the high-current state current of the Hall sensor (typical value 14mA). This indicates the low-current state current of the Hall sensor (typical value 6mA). Indicates the asymmetric gain coefficient; Indicates the partial pressure ratio; Indicates the smallest unit of quantization; NMOS indicates an N-channel metal-oxide-semiconductor field-effect transistor. Indicates the sampling resistor; This indicates a fault mode where the output is locked at logic 0; This indicates a fault mode where the output is locked at logic 1; Indicates the temperature coefficient of the DAC; This indicates the temperature coefficient of the temperature sensor; Indicates the calibrated temperature; Indicates the duration of the step holding time; Indicates the high-level duration of the current cycle; Indicates the chip junction temperature; Indicates the PWM signal period; Indicates the measured amplitude; Indicates the theoretical amplitude; VBG represents the on-chip bandgap reference voltage; VDD represents the on-chip bandgap reference voltage measurement; VDD represents the MCU power supply voltage. Indicates the actual supply voltage; Indicates the nominal value of the bandgap reference voltage; This represents the high-level voltage of the Hall sensor output signal after voltage division; This represents the low-level voltage after the Hall sensor output signal has been divided. Indicates the external power supply voltage of the Hall sensor ( ); Indicates signal voltage; This indicates that the ADC is sampling a low-level voltage. This indicates the measured output voltage value of the temperature sensor; express The output voltage of the temperature sensor at that time; This indicates the BIST test voltage. Indicates a low-level test voltage; Indicates the midpoint test voltage; Indicates a high-level test voltage; Indicates the center threshold; Indicates the falling edge trigger threshold; Indicates the rising edge trigger threshold; This indicates the preset threshold for abnormal amplitude. This represents the target threshold voltage.

[0020] like Figure 1 As shown in the figure, an embodiment of the present invention discloses a method for acquiring PWM signals, including the following steps: Step S10: Acquire the on-chip bandgap reference voltage signal and temperature signal of the microcontroller; Step S20: Calculate the voltage compensation amount and temperature compensation amount based on the on-chip bandgap reference voltage signal and the temperature signal; Step S30: Compensate the comparison threshold voltage of the on-chip comparator of the microcontroller based on the voltage compensation amount and the temperature compensation amount; Step S40: Acquire a PWM signal, which is a non-return-to-zero PWM signal. Compare the acquired PWM signal with the compensated comparison threshold voltage, and then output the signal characteristic parameters of the PWM signal based on the comparison result.

[0021] Currently, the status sensing requirements of vehicle actuators widely utilize current-type Hall effect sensors. For example, the commonly used electric seat adjustment system in automobiles is a two-wire (ground, power / signal) structure, and its operating logic is as follows: when the magnetic field strength exceeds the operating point (… When ), the device exhibits a high current state. ,in, It is a typical value); when the magnetic field is below the release point ( When ), it exhibits a low current state ( ), output cutoff (high level); in the hysteresis region ( When the position is detected, the output retains the previous state, achieving a latching function and ensuring the stability of seat position detection. That is, a common PWM signal conditioning scheme using an external comparator is characterized by converting the non-zero PWM signal into a standard signal through resistor voltage division and a level conversion chip. The signal is then sent to the MCU's Input Capture Unit (ICU) for edge capture and duty cycle calculation.

[0022] Since the output of the current-type Hall sensor chip is an NMOS open-drain output structure, it requires an external pull-up. Therefore, when the seat moves, the Hall device will output a non-return-to-zero (low-level non-zero) PWM signal. The identification of the seat position needs to be calculated by collecting the number of pulses generated by this PWM signal and combining it with the direction of the seat movement command. Therefore, accurately extracting pulse characteristics (such as the number of pulses and the pulse width) from the non-return-to-zero PWM signal pulses is the core technical requirement for achieving accurate seat position detection.

[0023] by Taking the power supply voltage as an example, the high level of the Hall signal output is: (Formula 1) The low level of the Hall signal is: (Formula 2) In the formula, Indicates the external power supply voltage of the Hall sensor ( ), This indicates the low-current state current (typical value) of the Hall sensor. ), Indicates the sampling resistor. This indicates the high-current state current (typical value) of the Hall sensor. ).

[0024] It can be seen that if this signal is processed by a simple resistor voltage divider, assuming the voltage divider factor is 1 / 3, the voltage after the voltage divider will be low. high level It can be seen that for a PWM signal returning to zero, through a reasonable resistor voltage divider design, the signal amplitude can be made to fall within the recognition range of the ICU module on the MCU chip, and thus be directly acquired through edge triggering. Combining the above voltage divider results, it is evident that in MCUs commonly used in automotive seats... In a power supply system, the low level after voltage division High level The signal was not lower than the MCU's low-level threshold. It was not completely higher than the high-level threshold. This is beyond the direct treatment scope of the ICU.

[0025] The operating voltage range of the automotive power supply system is The amplitude of the Hall sensor's output signal changes with fluctuations in the supply voltage, which in turn causes the voltage after voltage division to differ from the aforementioned... (Low level) The waveform of the (high level) signal is different, and the conventional resistor voltage divider method cannot be adapted to this wide voltage operating range, and cannot stably output a signal that meets the ICU identification requirements.

[0026] The current mainstream solution in the industry is to use an external comparator to condition the non-return-to-zero PWM signal output by the Hall effect sensor. By setting a threshold through the external comparator, the non-return-to-zero signal is converted into a standard low level. High level The PWM signal is then sent to the MCU's ICU for acquisition and processing, ultimately achieving pulse feature extraction. However, the introduction of external comparators and peripheral circuits not only increases the overall vehicle manufacturing cost but also limits the platform compatibility and vehicle model adaptability of the solution due to the large PCB area occupied.

[0027] The MCU has a built-in CMP, but the CMP offset voltage temperature drift is generally high. The above is about vehicle-mounted systems. After long-term operation under full-temperature conditions, the threshold drift can accumulate to tens of millivolts, which can easily cause misjudgments in functions such as seat position detection and stall recognition, and cannot meet the automotive-grade accuracy requirements.

[0028] Traditional external comparator solutions use a precision resistor divider network to set a fixed threshold, the accuracy of which depends on the accuracy of the external resistors (typically...). The output is stable at a specific temperature point, although it cannot be dynamically adjusted. When using the CMP alternative, the comparison threshold voltage is provided by the MCU's on-chip DAC output. Taking the NXP S32K144 as an example, its on-chip DAC has 8-bit resolution, and the reference voltage source is the MCU's VDD (typically...). Therefore, the DAC's When the automotive electrical system causes VDD fluctuations to... At that time, the actual output voltage corresponding to the same DAC digital code changes by approximately Approaching one When the MCU chip temperature is at When the range changes, the DAC generates additional temperature drift error (typically). After the above errors are superimposed, the deviation between the comparison threshold voltage output by the DAC and the set value can reach up to [value missing]. That's all. For the signal amplitude after voltage division, which is only approximately... Non-return-to-zero PWM signal ( Low level when powered High level The difference between high and low levels is approximately This deviation accounts for approximately [a certain percentage] of the signal amplitude. This is sufficient to cause CMP to misjudge near the signal edge. Additionally, when the MCU chip temperature rises from... Change to At this time, the DAC generates additional temperature drift error (typically). ).

[0029] After the two types of errors are combined, the deviation between the comparison threshold voltage output by the DAC and the set value can reach up to [value missing]. That's all. The difference between the high and low levels after voltage division is only approximately... The non-return-to-zero PWM signal, this deviation accounts for approximately [a certain percentage] of the signal amplitude. This is sufficient to cause CMP to misjudge near the signal edge.

[0030] Therefore, this invention configures two dedicated internal channels for the ADC. These are used to acquire the on-chip bandgap reference voltage signal and temperature signal from the MCU. The on-chip bandgap reference voltage signal corresponds to the on-chip bandgap reference voltage (VBG), with a typical value... It has an extremely low temperature coefficient (the absolute value of the temperature drift across the entire temperature range does not exceed...). The on-chip temperature sensor corresponding to the temperature signal outputs a voltage VTEMP that is linearly related to the chip junction temperature.

[0031] The MCU periodically (e.g., every) Perform the following calibration operation once: 1. ADC samples VBG to obtain the measured value. Since the theoretical value of VBG is fixed, The relationship with the actual VDD is as follows: (Formula 3) In the formula, Indicates the actual supply voltage. Indicates the nominal value of the bandgap reference voltage. This represents the full-scale digital value of the DC converter; for a 12-bit ADC, the corresponding value is 4095. This indicates the measured value of the on-chip bandgap reference voltage.

[0032] This allows for the accurate calculation of the actual power supply voltage of the current MCU. No external VDD sampling circuit is required.

[0033] 2. The ADC obtains the temperature sensor. Converted to MCU chip junction temperature .

[0034] The conversion formula for the S32K144 temperature sensor is: (Formula 4) In the formula, Indicates the junction temperature of the MCU chip. This indicates the measured output voltage value of the temperature sensor. express Output voltage of the temperature sensor (typical value) (The exact value needs to be obtained from the S32K144 datasheet). Temperature coefficient of the temperature sensor (typical value) That is, for every increase in temperature Output voltage decreases The above parameters need to be determined through calibration and written into the Flash constant area before the MCU is mass-produced.

[0035] 3. According to and The comparison threshold voltage of the DAC output is double-compensated: (Formula 5) Specific methods of compensation: Voltage compensation amount: due to the DAC's It is directly proportional to VDD, when When the output voltage deviates from the nominal value, the DAC code value needs to be adjusted to maintain a constant output voltage. The compensation formula is as follows: (Formula 6) In the formula, Indicates the voltage compensation amount. Indicates the temperature compensation amount. Indicates the nominal value of the bandgap reference voltage. This indicates the actual power supply voltage.

[0036] Temperature compensation amount: Based on the DAC temperature coefficient provided in the chip datasheet. (typical value) Calculate and compensate for temperature drift. (Formula 7) In the formula, Indicates the amount of temperature compensation. Indicates the target output code value of the DAC. Indicates the temperature coefficient of the DAC. Indicates the chip junction temperature. Indicates the calibration temperature (usually 100°C). ).

[0037] DAC code value after comprehensive compensation: (Formula 8) In the formula, This indicates that the DAC code value after double compensation corresponds to the compensated comparison threshold voltage.

[0038] This invention utilizes the on-chip bandgap reference voltage and temperature of the MCU to implement dual compensation for the built-in comparator, thereby improving detection accuracy. This solution supports direct and accurate acquisition of PWM signals via the on-chip comparator, eliminating the need for an external comparator. This reduces overall vehicle manufacturing costs, effectively saves PCB layout space, and improves solution integration.

[0039] like Figure 2 As shown, in one embodiment, comparing the acquired PWM signal with the compensated comparison threshold voltage, and then outputting the signal characteristic parameters of the PWM signal based on the comparison result, includes the following steps: Step S41: Modulate the PWM signal into a conditioning signal that adapts to a preset voltage range; Step S42: Compare the conditioning signal and the comparison threshold voltage, and output a digital comparison signal based on the comparison result; Step S43: Output the signal characteristic parameters of the PWM signal based on the digital comparison signal.

[0040] For the high-voltage non-return-to-zero PWM signal output by the Hall sensor, a resistor-divided sampling circuit is used to linearly scale the signal, mapping the non-return-to-zero PWM signal voltage amplitude to a preset voltage range that the MCU can process (e.g., to This generates a conditioning signal. Furthermore, an RC filter circuit is used to filter out high-frequency noise, ensuring signal integrity.

[0041] The on-chip comparator inside the MCU receives the conditioning signal and compares it with the comparison threshold voltage in real time. Furthermore, the comparison threshold voltage is set between the high and low levels of the conditioning signal. When the conditioning signal is higher than the comparison threshold voltage, it outputs a high level, and vice versa, thereby reconstructing a standard digital comparison signal.

[0042] The MCU's ICU performs edge detection on the digital comparison signal, calculates its period and duty cycle, and thus solves the signal characteristic parameters of the PWM signal (such as frequency and duty cycle) for subsequent motor position or current closed-loop control.

[0043] This invention enables accurate signal acquisition and processing without the need for an external comparator.

[0044] In one embodiment, the acquisition of the PWM signal includes the following steps: using a resistor divider sampling circuit to convert the PWM signal into a signal within a preset voltage range adapted to the microcontroller.

[0045] The PWM signal is processed by a resistor divider sampling circuit. Assuming the voltage division factor is 1 / 3, the voltage after division is low. high level It can be seen that for a PWM signal returning to zero, a reasonable resistor voltage divider design can ensure that the signal amplitude falls within the recognition range of the ICU module within the MCU, allowing for direct acquisition via edge triggering. However, considering the voltage divider results above, it is evident that in MCUs commonly used in automotive seats... In a power supply system, the low level after voltage division High level The signal was not lower than the MCU's low-level threshold. It was not completely higher than the high-level threshold. This is beyond the direct treatment scope of the ICU.

[0046] An external resistor-based voltage divider sampling circuit can condition the non-return-to-zero PWM signal output from the Hall effect sensor to within the CMP operating voltage range (i.e., the preset voltage range). This signal is then processed by the ICU to ultimately extract pulse characteristics.

[0047] In one embodiment, before acquiring the PWM signal and comparing it with the compensated comparison threshold voltage, the method includes the following steps: generating a preset test voltage, comparing the preset test voltage with the compensated comparison threshold voltage, and outputting a feedback state sequence based on the comparison result; and diagnosing whether the microcontroller is working properly based on the feedback state sequence.

[0048] The CMP (Continuous Voltage Regulator) is a critical component in the signal acquisition chain, and its operating status directly affects the accuracy of PWM signal acquisition. Possible CMP failure modes include: input offset voltage drift exceeding specifications; output... or Response speed degraded.

[0049] External comparator faults can be diagnosed by measuring or replacing them with external instruments, but CMP is integrated inside the MCU and cannot be directly detected.

[0050] Utilizing the programmable output capability of the DAC and the comparison function of the CMP, a hardware-level self-diagnostic program (Built-In Self Test, BIST) is automatically executed during the system power-on initialization phase and idle periods during operation. The specific method is as follows: 1. Diagnostic Mode 1: CMP Basic Function Self-Test (Executed during power-on initialization) First, configure the diagnostic path by switching the positive input of the CMP to the internal test channel (connected to the DAC output), and connecting the negative input to a fixed reference voltage (or a voltage divider version of the DAC output via internal routing). Alternatively, maintain the original CMP connection (positive input = external signal, negative input = DAC output), and indirectly test the CMP by controlling its output of different preset test voltages. Furthermore, prioritize the following circuit setup: CMP positive input: maintain connection to the voltage-divided PWM signal input pin; CMP negative input: connect to the DAC output; during the diagnostic period, the PWM signal is typically stationary (the signal is DC when the seat is not adjusted).

[0051] Then, a three-step voltage test is performed, controlling the DAC to output three specific diagnostic voltage values ​​(i.e., preset test voltages) in sequence: Step 1: (Low-level test voltage); Step 2: (Midpoint test voltage); Step 3: (High-level test voltage).

[0052] Hold time on each step (For example, 1ms), record the output status COUT of CMP. The output status COUT is shown in the table below:

[0053] Furthermore, diagnostics can be performed using sensor characteristics: considering that the PWM signal line has a pull-up resistor connection. When the seat is stationary, the Hall sensor does not consume current, and the signal line voltage is close to... .

[0054] When the seat is stationary and the Hall sensor has no PWM signal output, the signal line is kept at a high level (approximately) through the pull-up resistor. At this point, the DAC outputs three stepped voltages: Step 1 DAC output The voltage is lower than the signal line voltage.

[0055] Expected CMP output: (Positive input > Negative input); If Then the corresponding CMP Fault.

[0056] Step 2 The DAC output gradually approaches the signal line voltage to find the inversion point.

[0057] Record the DAC code value at the CMP flip point and compare it with the normal range: if the flip point is too far off, it corresponds to the CMP input offset voltage drift.

[0058] Step 3 DAC output It is higher than the signal line voltage.

[0059] Expected CMP output: (Positive input < Negative input); If Then the corresponding CMP Fault.

[0060] The above three-step test can be used to diagnose the connection status of the Hall sensor and the circuit simultaneously:

[0061] Rapid diagnosis of open / short circuits (performed periodically during runtime) Open-circuit diagnosis: During the effective high-level pulse of the PWM signal, the CMP output should be high. The MCU briefly boosts the DAC output to near... The high-level value after voltage division. If CMP still outputs high, the signal line is normally connected; if CMP toggles and outputs low, the signal line may be open (the signal is not being correctly transmitted to the CMP input).

[0062] Short circuit diagnosis: During the effective low-level pulse of the PWM signal, the CMP output should be low. The MCU briefly lowers the DAC output to near ground. If the CMP output remains low, there is no short circuit to the power supply; if the CMP toggles high, there may be a short circuit to the power supply.

[0063] This function requires the coordinated operation of three components: DAC (outputting stepped test voltage), CMP (performing comparison and judgment), and ICU (optional: recording the number of CMP toggles and timing). A single DAC can only output voltage and cannot judge the comparison result; a single CMP can only compare an external signal with a fixed threshold and cannot actively change the threshold for testing; only with the coordinated operation of DAC and CMP can the hardware-level self-diagnosis (BIST) function be realized, which actively injects a preset test voltage and observes the comparison result.

[0064] This invention combines DAC and CMP to achieve hardware-level self-diagnostic capabilities.

[0065] In one embodiment, after outputting the signal characteristic parameters of the PWM signal based on the comparison result, the steps include: obtaining the duty cycle and basic hysteresis of the PWM signal; calculating the asymmetry coefficient based on the duty cycle; and adjusting the comparison threshold voltage based on the basic hysteresis and the asymmetry coefficient for use in subsequent PWM signal comparisons.

[0066] During car seat adjustment, the duty cycle of the PWM signal is typically in the range of... The range varies, and the noise distribution near the high and low levels is asymmetrical during motor start-up and shutdown. (Standard symmetrical hysteresis comparator) In this situation, sufficient noise margin cannot be provided for the noisier side. Indicates the rising edge trigger threshold. Indicates the falling edge trigger threshold. This represents the center threshold.

[0067] The CMP is configured to either achieve a hysteresis effect by using window comparison mode or by dynamically outputting two different threshold voltages via a DAC. This invention dynamically adjusts the center position and size of the hysteresis window based on the real-time duty cycle characteristics of the PWM signal.

[0068] The ICU captures N PWM signal cycles (e.g., N=16) and calculates the duty cycle. : (Formula 9) Based on the actual duty cycle and The deviation is used to calculate the asymmetry coefficient. : (Formula 10) In the formula, Asymmetric gain coefficient (typical value) ), determined based on system characteristics calibration.

[0069] The DAC alternately outputs two threshold voltages, corresponding to the rising edge trigger threshold and the falling edge trigger threshold, respectively: (Formula 11) (Formula 12) In the formula, Represented as the center threshold (by external factors) (and the calibration results of module A are used to determine this). This is expressed as the basic hysteresis (a fixed value or adjusted according to the noise level). This indicates the asymmetric offset caused by the duty cycle.

[0070] When duty cycle When (the high level lasts for a relatively long time). The hysteresis window shifts entirely towards the high level, providing a larger noise margin for the high-level side; when the duty cycle hour, The window shifts towards a low level.

[0071] After the MCU detects the rising edge of the CMP output, it will change the DAC output from... Switch to After detecting the falling edge, switch back. The switching operation is achieved through the DAC's double-buffering mechanism to avoid output glitches.

[0072] In one embodiment, after outputting the signal characteristic parameters of the PWM signal based on the comparison result, the method further includes the following step: obtaining the theoretical amplitude of the PWM signal; Determine whether the difference between the measured amplitude and the theoretical amplitude corresponding to the signal characteristic parameter exceeds a preset amplitude abnormality threshold; if so, determine that the acquisition of the PWM signal is abnormal.

[0073] In existing solutions, ADC sampling external... For threshold calculation, the ICU captures PWM signal pulses for position detection, but there is no cross-validation mechanism between the two. If ADC sampling anomalies (such as channel failure or sampling time noise) cause threshold calculation errors, the system cannot detect them. This invention utilizes the actual signal voltage after voltage division sampled by the ADC during the stable high / low level of the PWM signal, and cross-validates it with the duty cycle information captured by the ICU.

[0074] Delay after the rising edge of the CMP output (Avoiding signal edge oscillation), the high-level voltage of the PWM signal after ADC sampling and voltage division. Delay after the falling edge of the CMP output. ADC samples low-level voltage .

[0075] Calculation of measured amplitude: (Formula 13) Compare the measured amplitude with the theoretical amplitude: (Formula 14) like: If the percentage is >10%, the signal is considered abnormal. Possible causes include: sensor aging, increased line impedance, and failure of the voltage divider resistor. Simultaneously, the duty cycle measured in the ICU... It should be consistent with the sensor's nominal duty cycle range. If the deviation is too large, an abnormal alarm will also be triggered.

[0076] The ADC provides signal amplitude information, the ICU provides timing / duty cycle information, and the CMP provides edge trigger signals (as a reference for the ADC sampling time). The three work together to achieve cross-validation of "analog quantity + digital quantity".

[0077] In one embodiment, the calculation of voltage compensation and temperature compensation includes the following steps: calculating the temperature compensation based on the temperature signal and a preset DAC temperature coefficient.

[0078] In one embodiment, the method of outputting the signal characteristic parameters of the PWM signal based on the comparison result includes the following steps: capturing the rising edge timestamp and falling edge timestamp of the PWM signal respectively; calculating the high-level duration based on the difference between the rising edge timestamp and the falling edge timestamp; and calculating the period of the PWM signal based on the difference between adjacent rising edge timestamps.

[0079] This invention also discloses a microcontroller, including an analog-to-digital converter, a processor, a digital-to-analog converter, an on-chip comparator, and an input capture unit. The analog-to-digital converter is used to acquire the on-chip bandgap reference voltage signal and temperature signal of the microcontroller; The processor is configured to calculate voltage compensation and temperature compensation based on the on-chip bandgap reference voltage signal and the temperature signal. The digital-to-analog converter is used to compensate the comparison threshold voltage of the on-chip comparator of the microcontroller based on the voltage compensation amount and the temperature compensation amount. The on-chip comparator is used to acquire a PWM signal and compare the acquired PWM signal with the compensated comparison threshold voltage. The input capture unit is used to output the signal characteristic parameters of the PWM signal based on the comparison result.

[0080] The functions of each unit in the microcontroller correspond to the steps in the above-mentioned PWM signal acquisition method embodiment, and their functions and implementation processes will not be described in detail here.

[0081] This invention also discloses an automotive seat control system, including the aforementioned microcontroller.

[0082] Specifically, the MCU used in the automotive seat control system is the NXP S32K144, and the Hall sensor is the SC25892SO (two-wire). ); pass Battery( (Range) power supply.

[0083] Hall sensor output via Sampling resistor, After the pull-up resistor and the 1 / 3 voltage divider sampling circuit, it is connected to: CMP 0 positive input terminal (IN0); ADC Channel 0, 8 (External signal sampling); ADC0 channel 9 ( sampling).

[0084] The DAC 0 output is connected to the negative input of CMP 0. The CMP 0 output is connected to the ICU input channel.

[0085] Module A (DAC output temperature and power supply voltage dual closed-loop calibration system, hereinafter referred to as Module A), DAC closed-loop calibration initialization Calibration cycle:

[0086] ADC configuration: External channel 8: Acquires the voltage-divided PWM signal (for ADCCV); External Channel 9: Acquisition (Used for threshold calculation); Internal channel 26: Acquires the on-chip bandgap reference voltage signal VBG (for VDD calculation); Internal channel 27: Acquires the temperature signal from the microcontroller (for temperature drift compensation); Resolution precision: 12 bits.

[0087] DAC configuration: 8-bit resolution; Reference voltage: VDD; (nominal) ,when hour) Enable double buffering mode.

[0088] Temperature compensation parameters (must be obtained from the datasheet):

[0089]

[0090] Module A Calibration Procedure (per implement) ADC sampling VBG to obtain (12-digit number); ; ADC samples the temperature sensor to obtain Convert to chip junction temperature using (Formula 4) ; According to external Calculate the target threshold voltage using the voltage divider ratio. The calculation method is as follows: The Hall sensor output signal is divided by a voltage divider, resulting in a high-level voltage. and the low-level voltage after voltage division They are respectively: (Formula 15) (Formula 16) in: External power supply voltage (in V) for sampling ADC channel 9. The typical value for the low current state of the Hall sensor is... , The typical value for the high current state of a Hall sensor is... , The value of the sampling resistor is indicated. , This indicates the partial pressure ratio, set to 1 / 3.

[0091] Target threshold voltage Take the midpoint between the high and low levels after voltage division to ensure that... The threshold value always remains at the center of the signal amplitude during fluctuations.

[0092]

[0093] Simplify by substituting known parameters:

[0094] Verification: When hour, The center value after voltage division of the original signal ( (Same as above)

[0095] Calculate the target DAC code value:

[0096] Calculate the voltage compensation amount:

[0097] in,

[0098] Calculate the temperature compensation amount:

[0099] in, , ; Double-compensated code value

[0100] limit Within the valid range [0, 255]; and written to the DAC register.

[0101] like Figure 3 As shown, Module B (CMP+DAC hardware-level self-diagnostic system, hereinafter referred to as Module B) has the following BIST operation process (executed upon power-on and once every 10 seconds during operation). Prerequisites: The seat is stationary, the Hall sensor has no PWM output, and the signal line is kept high through a pull-up switch.

[0102] DAC output (Below signal line high level), delay Read CMP output and record it as .expect: (Signal line voltage) ).

[0103] DAC output (Higher than the high level of the signal line), delay Read CMP output and record it as .expect: (Signal line voltage) ) like and If so, then the CMP is normal and the sensor wiring connection is normal. like and Then CMP Or the sensor is short-circuited to ground; like and Then CMP Or the sensor is short-circuited to the power supply; like and This would be a logical contradiction, and the ADC sampling channel may be faulty.

[0104] If the result is normal, then perform a flip point detection: DAC from Gradually improve to Step Record the DAC code value at the CMP flip and compare it with the normal range (calibrated value). If the offset exceeds the limit, report CMP misalignment drift.

[0105] Parameter configuration: (Basic hysteresis). (Asymmetric gain coefficient) (Duty cycle calculation cycle number).

[0106] Executes in each PWM cycle: ICU captures the high-level time of the current cycle and cycle ; Calculated after 16 cycles ; Calculate the asymmetric coefficients:

[0107] Calculate two thresholds: , ; After detecting the rising edge, the DAC switches to After detecting the falling edge, the DAC switches to .

[0108] like Figure 4 As shown, module C1 (asymmetric hysteresis dynamic control) – the hysteresis window center dynamically shifts according to the PWM signal duty cycle; as... Figure 5 As shown, module C2 (amplitude-duty cycle cross-validation, ADCV) – cross-validation operation flow (each Execute once.

[0109] Delay after the rising edge of CMP The ADC samples external channel 8 to obtain...

[0110] Delay after the falling edge of CMP ADC; sample external channel 8 to obtain

[0111] Measurement Amplitude The calculation is as follows:

[0112] Theoretical amplitude The calculation is as follows:

[0113] Verification: If If the signal is abnormal, then verify whether the ICU duty cycle is within the nominal range.

[0114] It should be noted that the sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0115] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to such processes, methods, products, or apparatus. The terms "first," "second," and "third," etc., are used to distinguish different objects, etc., and do not indicate a sequence, nor do they limit "first," "second," and "third" to different types.

[0116] In the description of the embodiments of the present invention, terms such as "exemplary," "for example," or "for instance" are used to indicate that they are examples, illustrations, or descriptions. Any embodiment or design that is described as "exemplary," "for example," or "for instance" in the embodiments of the present invention should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a specific manner.

[0117] In the description of the embodiments of the present invention, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. "And / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present invention, "multiple" means two or more.

[0118] In some processes described in the embodiments of the present invention, multiple operations or steps are included in a specific order. However, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of the present invention, or may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.

[0119] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of the present invention.

[0120] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A method for acquiring PWM signals, characterized in that, Includes the following steps: Acquire the on-chip bandgap reference voltage and temperature signals of the microcontroller; Calculate the voltage compensation amount and temperature compensation amount based on the on-chip bandgap reference voltage signal and the temperature signal; The comparison threshold voltage of the on-chip comparator of the microcontroller is compensated based on the voltage compensation amount and the temperature compensation amount. A PWM signal is acquired, which is a non-return-to-zero PWM signal. The acquired PWM signal is compared with the compensated comparison threshold voltage, and the signal characteristic parameters of the PWM signal are output based on the comparison result.

2. The PWM signal acquisition method according to claim 1, characterized in that, The step of comparing the acquired PWM signal with the compensated comparison threshold voltage and then outputting the signal characteristic parameters of the PWM signal based on the comparison result includes the following steps: The PWM signal is modulated into a conditioning signal that adapts to a preset voltage range; The conditioning signal and the comparison threshold voltage are compared, and a digital comparison signal is output based on the comparison result; The signal characteristic parameters of the PWM signal are output based on the digital comparison signal.

3. The PWM signal acquisition method according to claim 1, characterized in that, The acquisition of the PWM signal includes the following steps: The PWM signal is converted into a signal within a preset voltage range adapted to the microcontroller using a resistor divider sampling circuit.

4. The PWM signal acquisition method according to claim 1, characterized in that, Before acquiring the PWM signal and comparing it with the compensated comparison threshold voltage, the following steps are included: A preset test voltage is generated, and the preset test voltage is compared with the compensated comparison threshold voltage. A feedback state sequence is output based on the comparison result. The microcontroller is diagnosed as working properly based on the feedback state sequence.

5. The PWM signal acquisition method according to claim 1, characterized in that, After outputting the signal characteristic parameters of the PWM signal based on the comparison result, the following steps are included: Obtain the duty cycle and basic hysteresis of the PWM signal; Calculate the asymmetry coefficient based on the duty cycle; The comparison threshold voltage is adjusted based on the base hysteresis and the asymmetry coefficient for comparison of subsequent PWM signals.

6. The PWM signal acquisition method according to claim 1, characterized in that, After outputting the signal characteristic parameters of the PWM signal based on the comparison result, the method further includes the following steps: Obtain the theoretical amplitude of the PWM signal; Determine whether the difference between the measured amplitude and the theoretical amplitude corresponding to the signal characteristic parameters exceeds a preset amplitude anomaly threshold; If so, it is determined that there is an abnormality in the acquisition of the PWM signal.

7. The PWM signal acquisition method according to claim 1, characterized in that, The calculation of voltage compensation and temperature compensation includes the following steps: The temperature compensation amount is calculated based on the temperature signal and the preset DAC temperature coefficient.

8. The PWM signal acquisition method according to claim 1, characterized in that, The step of outputting the signal characteristic parameters of the PWM signal based on the comparison result includes the following steps: The rising edge timestamp and falling edge timestamp of the PWM signal are captured respectively; The high-level duration is calculated based on the difference between the rising edge timestamp and the falling edge timestamp, and the period of the PWM signal is calculated based on the difference between adjacent rising edge timestamps.

9. A microcontroller, characterized in that, This includes an analog-to-digital converter, a processor, a digital-to-analog converter, an on-chip comparator, and an input capture unit. The analog-to-digital converter is used to acquire the on-chip bandgap reference voltage signal and temperature signal of the microcontroller; The processor is configured to calculate voltage compensation and temperature compensation based on the on-chip bandgap reference voltage signal and the temperature signal. The digital-to-analog converter is used to output a compensation voltage to compensate the comparison threshold voltage of the on-chip comparator of the microcontroller based on the voltage compensation amount and the temperature compensation amount. The on-chip comparator is used to acquire a PWM signal and compare the acquired PWM signal with the compensated comparison threshold voltage. The input capture unit is used to output the signal characteristic parameters of the PWM signal based on the comparison result.

10. A car seat control system, characterized in that, Including the microcontroller as described in claim 9.