Sensor clock calibration method based on synchronization pulse
By using a clock calibration method based on synchronization pulses to adjust the frequency ratio between the sensor clock and the main control unit clock, the problems of data frame conflicts and Manchester code distortion caused by sensor clock deviation are solved, thereby improving the communication success rate and decoding fault tolerance.
Patent Information
- Application Number
- CN202610004228.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-05
- Publication Date
- 2026-04-10
AI Technical Summary
In the PSI5 protocol, the deviation between the sensor clock and the main control unit clock causes data frame conflicts and Manchester code distortion, affecting the communication success rate.
By using a clock calibration method based on synchronization pulses, the frequency ratio between the sensor clock and the main control unit clock is calculated, and the data frame return time and baud rate of the sensor are adjusted to achieve clock synchronization.
It improves communication success rate, avoids data frame collisions and Manchester code distortion, and enhances the decoding fault tolerance of the main control unit.
Smart Images

Figure CN121841532A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of automotive electronics technology, and in particular to a sensor clock calibration method based on synchronization pulses. Background Technology
[0002] PSI5 is a two-wire synchronous serial communication protocol for automotive sensors. It simultaneously performs data communication and power supply through a single line and is widely used in accelerometers, pressure sensors, and position sensors. With its high reliability, strong anti-interference capabilities, and low cost, this protocol has become an ideal replacement for traditional analog interfaces and is now a key standard in the automotive electronics industry. The PSI5 protocol uses a master-slave communication model, connecting one master control unit and up to six sensors on the bus. The master control unit sends a synchronization pulse of a specific width by pulling up the bus voltage to pinpoint the synchronization communication time for the sensors. Subsequently, within their respective designated time slots, the sensors assemble their data into frames using Manchester encoding and modulate them onto the bus current for transmission. The master control unit decodes the Manchester encoding to obtain the sensor information.
[0003] Due to manufacturing processes and temperature drift, the sensor's clock may be faster or slower than the main control unit's clock during actual operation. If this is not corrected, it could lead to transmission failures, data loss, or even interference with the operation of other sensors.
[0004] Without any correction measures for the timer clock, the following may occur: Scenario 1: There is a clock discrepancy between sensor A and sensor B. The time of the frame returned by sensor A is squeezed out by sensor B. The timeslot of sensor B collides with the frame sent by sensor B. For example... Figure 1 The diagram illustrates the correct and abnormal timeslot conditions. Generally, the master control unit can correct frames that only partially exceed the timeslot boundaries through analysis. However, if the contents of two frames overlap, it will severely violate protocol requirements, making data recovery impossible.
[0005] Scenario 2: There is a clock discrepancy between the sensor and the main control unit. The frame baud rate returned by the sensor is not displayed correctly by the main control unit. If the value is too large or too small, decoding will fail.
[0006] In real networking, there are electrical parameters such as resistance, parasitic capacitance, parasitic inductance and the like on the master unit, the sensor and the cable. When the parameters are substituted into simulation, it can be seen that the Manchester code emitted by the sensor side is severely deformed when received at the master unit side. The deformation is reflected as delay, no longer sharp edges, duty cycle distortion, burr and the like after demodulation, which greatly reduces the decoding fault tolerance of the master unit. If the baud rate deviation of the sensor end is superimposed at this time, it will undoubtedly further increase the decoding pressure and even lead to decoding failure.
[0007] As can be seen from the above, how to avoid such a scenario and improve the communication success rate is a problem that needs to be solved. SUMMARY
[0008] In view of the above problems, the present application provides a sensor clock calibration method based on a synchronization pulse.
[0009] In order to achieve the purpose of the present application, a sensor clock calibration method based on a synchronization pulse is provided, comprising the following steps: S1: the sensor receives a first synchronization pulse sent by the master unit, records the data frame return time of the sensor as T2, and records the baud rate of the sensor when starting to return the data frame at T2 as B0; S2: the sensor receives a second synchronization pulse sent by the master unit, records the theoretical count value in the synchronization pulse interval as M0, and records the actual count value in the synchronization pulse interval as M1; based on the theoretical count value M0 and the actual count value M1 in the synchronization pulse interval, the frequency ratio D1 of the sensor clock to the master unit clock is calculated and obtained; S3: based on the data frame return time T2 of the sensor and the frequency ratio D1 of the sensor clock to the master unit clock, the calibrated data frame return time T2' of the sensor is calculated and obtained; S4: based on the baud rate B0 of the sensor when starting to return the data frame at T2 and the frequency ratio D1 of the sensor clock to the master unit clock, the calibrated baud rate B0' of the sensor when starting to return the data frame at the calibrated T2' is calculated and obtained; S5: the sensor returns the data frame at the calibrated T2' with the calibrated baud rate B0', and the calibration is ended.
[0010] Further, in the step S2, the specific process of calculating and obtaining the frequency ratio D1 of the sensor clock to the master unit clock based on the theoretical count value M0 and the actual count value M1 in the synchronization pulse interval includes: D1=M0 / M1.
[0011] Further, based on the frequency ratio D1 of the sensor clock and the master unit clock and the data frame return time T2 of the sensor, the specific process of calculating and obtaining the calibrated data frame return time T2' of the sensor in step S3 comprises: T2'=T2 / D1.
[0012] Further, based on the baud rate B0 of the sensor at T2 when starting to return data frames and the frequency ratio D1 of the sensor clock and the master unit clock, the specific process of calculating and obtaining the calibrated baud rate B0' of the sensor at T2' when starting to return data frames in step S4 comprises: B0'=B0 / D1.
[0013] Further, in step S2, the actual count value M1 in the synchronization pulse interval is obtained by the sensor returning data through the PSI5 frame in the debugging mode.
[0014] Further, the absolute value of the difference between the actual count value M1 in the synchronization pulse interval and the theoretical count value M0 in the synchronization pulse interval is less than or equal to 20% of M0.
[0015] The application also provides an electronic device comprising a memory, a processor and a computer program. The computer program is stored in the memory and can run on the processor. The processor implements the steps of any one of the above-mentioned synchronization pulse-based sensor clock calibration methods when running the computer program.
[0016] Compared with the prior art, the application has the following beneficial technical effects: The present application corrects the clock deviation of the sensor based on the synchronization pulse, synchronizes the clock of the sensor with the clock of its master unit, avoids the problem that the data cannot be restored due to the serious deviation of the clocks of the sensor A and the sensor B, and avoids the problem that when there are resistance, parasitic capacitance, parasitic inductance and other electrical parameters on the master unit, the sensor and the cable in the real networking, the Manchester code will be severely deformed when received on the master unit side, thereby greatly reducing the decoding fault tolerance rate of the master unit. The implementation of the present application not only reduces the decoding pressure, but also increases the success rate of decoding. BRIEF DESCRIPTION OF DRAWINGS
[0017] Figure 1 is a schematic diagram of data conflict caused by sensor clock deviation; Figure 2 is a flowchart of a synchronization pulse-based sensor clock calibration method according to an embodiment. DETAILED DESCRIPTION
[0018] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not used to limit the present application.
[0019] Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are they necessarily mutually exclusive or alternative embodiments. It is expressly understood that the embodiments described herein are combinable with each other.
[0020] Reference Figure 2 shown, Figure 2 A flowchart of a sensor clock calibration method based on a synchronization pulse for an embodiment. A sensor clock calibration method based on a synchronization pulse, comprising the following steps: S1: The sensor accepts the first synchronization pulse sent by the master unit, records the data frame return time of the sensor as T2, and records the baud rate of the sensor starting to return the data frame at T2 as B0; S2: The sensor accepts the second synchronization pulse sent by the master unit, records the theoretical count value in the synchronization pulse interval as M0, and records the actual count value in the synchronization pulse interval as M1; based on the theoretical count value M0 and the actual count value M1 in the synchronization pulse interval, the frequency ratio D1 of the sensor clock to the master unit clock is calculated and obtained; the synchronization pulse interval refers to the interval between the newly accepted synchronization pulse and the last accepted synchronization pulse, and M1 refers to the actual count value occurring in this interval.
[0021] S3: Based on the data frame return time T2 of the sensor and the frequency ratio D1 of the sensor clock to the master unit clock, the calibrated data frame return time T2' of the sensor is calculated and obtained; S4: Based on the baud rate B0 of the sensor starting to return the data frame at T2 and the frequency ratio D1 of the sensor clock to the master unit clock, the calibrated baud rate B0' of the sensor starting to return the data frame at the calibrated T2' is calculated and obtained; S5: The sensor returns the data frame at the calibrated T2' with the calibrated baud rate B0', and the calibration is completed.
[0022] In one embodiment, the actual count value M1 in each synchronization pulse interval can not be consistent, so theoretically, the calculation calibration needs to be permanently cycled. When the first synchronization pulse is received, only data is taken, and no processing is performed; when the second synchronization pulse is received, the actual count value M1 in the first-second synchronization pulse interval is obtained, and the actual count value M1 is used to calculate the new return data frame time and baud rate. When the third synchronization pulse is received, the actual count value M1 in the second-third synchronization pulse interval is obtained, and it is determined whether the actual count value M1 is reasonable. If it is reasonable, the actual count value M1 is used to continue to calculate the new return frame time and baud rate. When the fourth synchronization pulse is received, the actual count value M1 in the fourth synchronization pulse and the third synchronization pulse interval is obtained, and the above calibration operation is repeated, and the following is cycled in this way.
[0023] In one embodiment, in the step S2, based on the theoretical count value M0 and the actual count value M1 in the synchronization pulse interval, the specific process of calculating and obtaining the frequency ratio D1 of the sensor clock to the master unit clock includes: D1=M0 / M1.
[0024] In one embodiment, in the step S3, based on the data frame return time T2 of the sensor and the frequency ratio D1 of the sensor clock to the master unit clock, the specific process of calculating and obtaining the calibrated data frame return time T2' of the sensor includes: T2'=T2 / D1.
[0025] In one embodiment, in the step S4, based on the baud rate B0 of the sensor starting to return the data frame at the T2 time and the frequency ratio D1 of the sensor clock to the master unit clock, the specific process of calculating and obtaining the calibrated baud rate B0' of the sensor starting to return the data frame at the calibrated T2' time includes: B0'=B0 / D1.
[0026] In one embodiment, in the step S2, the actual count value M1 in the synchronization pulse interval is obtained in the debugging mode through the PSI5 frame data return.
[0027] In one embodiment, the absolute value of the difference between the actual count value M1 in the synchronization pulse interval and the theoretical count value M0 in the synchronization pulse interval is less than or equal to 20% of M0.
[0028] In one embodiment, an electronic device is provided, including a memory, a processor and a computer program. The computer program is stored in the memory and can run on the processor. The processor realizes the steps of any one of the synchronization pulse based sensor clock calibration methods when running the computer program.
[0029] In one embodiment, according to the PSI5 protocol specification, in the synchronization mode, the master unit will agree with the sensors to periodically send synchronization pulses on the bus at fixed intervals. All sensors take the received synchronization pulse as the starting moment of a transmission period, and each sensor returns the frame data when timing to the timeslot belonging to itself.
[0030] After analyzing the rules, it can be found that the synchronization pulse, in addition to realizing the basic functions specified in the protocol, also implies information about the clock condition of the master unit itself.
[0031] This information is the deviation of the master unit clock relative to the accurate clock. If the agreed standard synchronization pulse interval is T0, and the actual interval on the bus is T1, it can be concluded that the frequency ratio D0 = T0 / T1 of the master clock relative to the accurate clock.
[0032] Example: Assuming T0 = 1000us, T1 = 1031us, D0 = T0 / T1 ≈ 97.0%, the master unit clock is 3% slower than the accurate clock.
[0033] The sensor can directly obtain how long the interval between two synchronization pulses is, that is, the synchronization pulse interval T0. If the sensor clock counts the T0 length in theory, the theoretical count value is M0; when facing the actual T1 length synchronization pulse interval on the bus, the actual count value is M1; it can be concluded that the frequency ratio D1 = M0 / M1 of the sensor clock relative to the master unit clock, and further the frequency ratio D2 = D1*D0 of the sensor clock relative to the accurate clock.
[0034] Example: Assuming M0 = 10000, M1 = 9434, D1 = M0 / M1 ≈ 106%, the sensor clock is 6% faster than the master unit clock; if T0 = 1000us, T1 = 1031us in the above example, D2 = D1*D0 ≈ 102.8%, the sensor clock is 2.8% faster than the accurate clock.
[0035] Through the above reasoning, we can obtain the deviation of the master unit and the sensor unit relative to the accurate clock by measuring the actual synchronization pulse interval T1 on the bus and obtaining the actual count value M1 of the sensor, combined with the known agreed standard synchronization pulse interval T0 and the theoretical count value M0 of the sensor clock in the synchronization interval T0. M1 can make the sensor return the PSI5 frame data in the test mode, so as to obtain the actual frequency values of the sensor clock and the master unit clock without affecting the networking and introducing additional debugging pins.
[0036] And, the sensor can internally calculate D1 and align the data frame return time and baud rate with the master unit, where the data frame return time refers to the interval between the time of receiving the synchronization pulse and the time of returning the frame in the timeslot.
[0037] Note that here the alignment is not with the accurate clock, but with the master unit clock. Because the judgment of timeslot, frame receiving, and decoding is based on the master unit's own clock reference. Only when the sensor clock is close to the master unit clock, the sensor's clock is accurate in the eyes of the master unit.
[0038] In an embodiment, assume that the sensor's original frame return time is T2 and the baud rate is B0. Upon receiving the first synchronization pulse sent by the master unit, return the data frame at T2 with B0 baud rate.
[0039] Upon receiving the second and subsequent synchronization pulses sent by the master unit, assume that the theoretical synchronization pulse interval count value is M0 and the actual count value is M1. Calculate the sensor clock frequency ratio D1 = M0 / M1 relative to the master unit clock.
[0040] The master unit will send synchronization pulses in a fixed time interval in an infinite loop, which is the background of the synchronization mode transmission of the PSI5 communication protocol. Clock calibration is automatically started from the reception of the second synchronization pulse. From the second, every time a new synchronization pulse is received, the actual count value M1 in the synchronization pulse interval is used to calculate a new D1 in order to re-perform the subsequent calibration operation.
[0041] After calculating D1, calculate the new data frame return time T2' = T2 / D1 and the new baud rate B0' = B0 / D1. And return the data frame at T2' with B0' baud rate.
[0042] In an embodiment, when calculating D1, the reasonableness of M1 is also considered. The upper and lower limits of M1 are constrained to avoid the master unit from failing to send synchronization pulse intervals as planned due to abnormalities, resulting in abnormal judgment by the sensor. For example, M1 can be set not to exceed ±20% of M0, update D1 within the range, discard outside the range, and when M1 exceeds ±20% of M0, consider it an abnormal synchronization pulse interval and do not calculate the frame return time, baud rate, etc.
[0043] The upper and lower limits of the variation of the adjacent two wheels M1 are restricted, and the clock frequency drift caused by temperature change is slow and stable, and will not cause a large amount of change of M1 at a moment. For example, the difference between two adjacent M1 can be set to not more than ±5%, and the D1 is updated within the range, and at most ±5% is updated outside the range. That is, when a new synchronization pulse is received, it is judged whether the difference between this time synchronization pulse interval and the last synchronization pulse interval exceeds ±5%. If it exceeds the range, do not use this data, and do not update the frame return time and baud rate. If it does not exceed the range, use this data to calculate and update the frame return time and baud rate.
[0044] Analyze the solution of the two scenarios at the beginning after the timing calibration is completed: Scenario 1: When all sensors start timing calibration, at this time, no matter how much the sensor's own clock deviates from the actual clock, it will be aligned with the clock of the master unit, which is equivalent to the clock of all components on the entire PSI5 bus being unified. All sensors can be set to default to start timing calibration by burning OTP or other methods before networking, and automatically start after networking. In this scenario, unless the data frame return time set by the software is unreasonable, the data frames returned by each sensor will not fundamentally cause the event of occupying timeslot or collision.
[0045] Scenario 2: The sensor starts timing calibration, and the baud rate of the returned data frame is adjusted according to the master unit clock. If the master unit clock is 3% faster than the real clock, the baud rate of the frame returned by the sensor on the bus will also be 3% faster. In this scenario, the baud rate in the eyes of the master unit is the standard value and is neither fast nor slow. It has the best decoding success rate on the factor of baud rate.
[0046] The technical features of the above embodiments can be combined in any way. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the description.
[0047] It should be noted that the terms "first", "second", "third" involved in the embodiments of the present application are only to distinguish similar objects, and do not represent a specific order of the objects. Understandably, "first", "second", "third" can be interchanged in a specific order or sequence as allowed. It should be understood that the objects distinguished by "first", "second", "third" can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein.
[0048] The terms "comprise", "comprising", "have", "having", "include", "including" and "contains", "containing" as used herein are intended to be open-ended and allow for the possibility that there are other steps or elements which are not listed, optionally present, or inherent to such process, method, article, or apparatus. Throughout this specification, unless otherwise indicated, the terms "or", as well as "consisting essentially of" and "consisting of", are used in their inclusive sense (and not in their exclusive sense), that is, unless specified otherwise, the word "or" is used in the sense that it is used to mean "and / or" as well as "either / or" - that is, the word "or" can mean either "and / or" or "either / or".
[0049] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be noted that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the patent protection scope of the present application should be subject to the appended claims.
Claims
1. A method for sensor clock calibration based on synchronization pulses, characterized by, The method comprises the following steps: S1: the sensor receives a first synchronization pulse sent by the master control unit, records a data frame return time of the sensor as T2, and records a baud rate of the sensor for returning the data frame at the time T2 as B0; S2: the sensor receives a second synchronization pulse sent by the master control unit, records a theoretical count value in a synchronization pulse interval as M0, records an actual count value in the synchronization pulse interval as M1, and calculates a frequency ratio D1 of the sensor clock to the master control unit clock based on the theoretical count value M0 and the actual count value M1 in the synchronization pulse interval; S3: based on the data frame return time T2 of the sensor and the frequency ratio D1 of the sensor clock to the master control unit clock, a calibrated data frame return time T2' of the sensor is calculated and obtained; S4: based on the baud rate B0 of the sensor for returning the data frame at the time T2 and the frequency ratio D1 of the sensor clock to the master control unit clock, a calibrated baud rate B0' of the sensor for returning the data frame at the calibrated time T2' is calculated and obtained; S5: the sensor returns the data frame at the calibrated time T2' with the calibrated baud rate B0', and the calibration is completed.
2. The method of claim 1, wherein, In the step S2, the specific process of calculating and obtaining the frequency ratio D1 of the sensor clock to the master control unit clock based on the theoretical count value M0 and the actual count value M1 in the synchronization pulse interval comprises: D1=M0 / M1.
3. The method of claim 2, wherein, In the step S3, the specific process of calculating and obtaining the calibrated data frame return time T2' of the sensor based on the data frame return time T2 of the sensor and the frequency ratio D1 of the sensor clock to the master control unit clock comprises: T2'=T2 / D1.
4. The method of claim 3, wherein, In the step S4, the specific process of calculating and obtaining the calibrated baud rate B0' of the sensor for returning the data frame at the calibrated time T2' based on the baud rate B0 of the sensor for returning the data frame at the time T2 and the frequency ratio D1 of the sensor clock to the master control unit clock comprises: B0'=B0 / D1.
5. The method of claim 4, wherein, In the step S2, the actual count value M1 in the synchronization pulse interval is obtained by the sensor in a debugging mode through PSI5 frame data return.
6. The method of claim 5, wherein, The absolute value of the difference between the actual count value M1 in the synchronization pulse interval and the theoretical count value M0 in the synchronization pulse interval is less than or equal to 20% of M0.
7. An electronic device, comprising: The method comprises a memory, a processor and a computer program; The computer program is stored in the memory and can run on the processor; The processor runs the computer program to implement the steps of the synchronization pulse-based sensor clock calibration method in any one of claims 1-6.
