NXP NTM88 User guide

Type
User guide
UM11363
NTM88 Dual-Axis Location Angle Project – Software
Rev. 1 — 27 March 2020 User manual
1 Introduction
This document describes the Tire Pressure Management System (TPMS) NTM88
Location Angle XZ dual-axis software version 2.0 designed to run on NXP's TPMS part
NTM88H13, which includes dual-axis accelerometers X and Z. The TPMS application
software was developed using the CodeWarrior IDE. The purpose of the software is to
monitor the angular position of a TPMS device attached to a rotating wheel and to start
the transmission of a fixed length RF data packet at a given location so that the end of
the packet arrives at the RF receiver when the TPMS device is at a pre-defined target
angle location on the wheel. User code can specify one, two, three or four target location
angles and, depending on the wheel rotation speed, up to four RF data packets can be
transmitted during one full wheel rotation. Initially, the wheel rotation speed is estimated
based on the accelerometer Z centripetal acceleration reading. All subsequent TPMS
location angle processing is based on accelerometer X data.
This document describes the software that implements the various algorithms used in
the project. The algorithms are documented in the complementary NTM88 Dual-Axis
Location Angle Project – Algorithms user manual.
The NTM88_LocAngle_XZ project was designed as a reference project with limited
performance verification. Users are encouraged to experiment and modify the algorithms
and the project code to suit their application requirements.
2 Software requirements
The NTM88 Dual-Axis Location project requires the following elements:
CodeWarrior v11.0 or higher with the NTM88_LIB patch installed
The NTM88 Application Library in file NTM88_AppLib_v2-2.lib
The library version of NTM88 firmware provided in file ntm88_axis_xz_lib.lib.
10090 bytes of MCU flash memory
325 bytes of MCU RAM
3 Project organization
The NTM88 Dual-Axis Location Angle project was developed using CodeWarrior v11.0
with the NTM88_LIB firmware library patch installed. (The firmware library patch provides
support for NTM88 device family.)
All project components are provided in the zip file NTM88_LocAngle_XZ_vxxx.zip.
This file contains the full CodeWarrior project with all required files in their appropriate
directories. After the project has been unzipped and then imported into a CodeWarrior
workspace and compiled without errors, executable code is ready to be programmed
into the TPMS NTM88 device's flash memory. If a compilation error occurs during this
process, execute the CodeWarrior menu command ‘Project\Clean…’.
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
2 / 19
The organization of project directories and source code files is as follows:
directory Lib:
NTM88_AppLib_v2-2.lib – the file containing TPMS Application Library for NTM88
ntm88_axes_xz_lib.lib – the library file containing all dual-axis TPMS NTM88
firmware functions
NTM88_LIB.c – the CodeWarrior project file, which contains the TPMS NTM88
device register definitions
directory Project_Headers:
derivative.h – the CodeWarrior definition of the project device type
LocAngle.h – the header file associated with the location angle source code in
LocAngle.c
main.h – the header file associated with the project main.c source file
NTM88_AppLib_v2-2.h – the header file with function declarations for the TPMS
Application Library for NTM88
ntm88_axis_xz_lib.h – the header file with library firmware function declarations
NTM88_LIB.h – the CodeWarrior file, which contains declarations of device registers
and their bit fields
directory Sources:
interrupts.c – the TPMS interrupt service routines and interrupt vector table
LocAngle.c – the location angle functions source code
main.c – the TPMS application project main function source code
4 Overview of the TPMS Location Angle algorithm
The purpose of the algorithm is to monitor the angular location of the TPMS device
on a rotating wheel and to start the transmission of RF packets so that each packet's
transmission ends when the TPMS is at a pre-defined location angle selected by the
user. The algorithm's operation is based only on accelerometers X and Z data. The
sequence of events is described below.
Initially, the software determines if the car is parked or moving by comparing the
randomly read accelerometer Z data to a threshold of 5.9 g. An accelerometer Z reading
below the threshold indicates that the car is parked. A reading above the threshold
indicates that the car is moving. The threshold is equivalent to a car with 195/65R15 tires
moving with a speed of approximately 20 km/h.
If the car is moving, function u8fFindWheelDir() can be called, when required, to
determine the wheel rotation direction—either clockwise (CW) or counter-clockwise
(CCW). Function u8fFindWheelDir() is enabled by defining the software compilation
switch DIR_FIND_ENABLE. If finding the wheel rotation direction is not required, the
switch DIR_FIND_ENABLE should be commented out. Wheel rotation direction is found
in function u8fFindWheelDir() using data sequences from both accelerometers X and Z.
The function u8fXGetRotPeriod() is called next and the accelerometer X sampling
sequence is started to determine the wheel rotation period and the ±1 g sine wave 0-
crossing moment to be used as a starting point for TPMS location angle tracking.
When accelerometer X sampling is started, the function determines whether the slope of
the sample sequence sine wave is rising or falling. Depending on the result, execution
then follows one of two paths.
If a rising slope was detected first, the function waits for the sine wave maximum MAX1
count value and then waits for the sine wave count level to fall X_PRD_LVL_CNT below
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
3 / 19
the count at MAX1. At this moment, the time count is recorded by reading the current
Free Running Counter (FRC) value. This value determines the point in time when the
sine wave period measurement begins. Next, the count level at the following sine wave
minimum MIN1 is recorded and the function waits for the next sine wave maximum
MAX2. When the sine wave level count drops by X_PRD_LVL_CNT below MAX2,
the FRC is read again and its count at this time is considered the ending point of the
sine wave period measurement. The difference between the two saved FRC counts
represents the wheel rotation period. The average value of counts at MAX1, MIN1 and
MAX2 is calculated and used as a count level to determine the sine wave positive-to-
negative 0-crossing point, which in this case coincides with 0° of the TPMS location
angle.
If a falling sine wave slope was detected first, a similar procedure is executed, but the
sequence of events is as follows. The sequence begins by waiting for the MIN1 value to
use as the starting point for measuring the rotation period. The program then waits for
the MAX1 value and, after finding the next minimum MIN2, uses this data to calculate the
period. Based on the average of counts MIN1, MAX1 and MIN2, the negative-to-positive
0-crossing level is determined. In this case the 0-crossing level coincides with 180° of the
TPMS location angle.
The RF packet transmission time, the wheel rotation period, the 0-crossing time, and
the fact that the 0-crossing happens when the TPMS device is at the wheel’s 0° or 180°
position are used to determine when the first RF packet transmission must begin.The
time delay from the 0-crossing point to the moment when the first RF packet transmission
should start is calculated so that the packet transmission ends when the TPMS device
reaches the required predefined first location angle on the rotating wheel. User code can
define from one to four location angles in an array of up to four elements. Immediately
after starting the transmission of the first RF packet, the time delay to the next RF packet
transmission start is calculated. After processing all location angle entries defined in the
array, the cycle of rotation period measurement and RF packet transmissions ends and
the MCU enters STOP1 mode. The cycle repeats based on a predefined time period
initiated by the PWU timer.
When the TPMS is mounted on a wheel with a 15" rim diameter, the RF packets are
transmitted in the wheel rotation speed range of 166 RPM to 1200 RPM, which are
equivalent to car speeds of 20 km/h and 144 km/h respectively. The lower limit of 166
RPM is determined by the centripetal acceleration of a 5.9 g Z accelerometer threshold
to decide whether the car is parked or moving. The upper limit is set by the minimum
allowed rotation period of 50 ms.
The maximum time required for successful completion of the period measurement
algorithm and the start of the first RF packet transmission is approximately 1.5 wheel
rotations. All RF packet transmissions are finished during the following single wheel
rotation.
The test equipment used to verify the algorithm's operation consisted of a rotating wheel
simulator with an MCU-controlled motor and an RF packets data receiver. A GPIO output
pin from the receiver signaled the motor-controller MCU when a new RF packet was
received. The motor-controller MCU recorded the angular position of the motor at the
instant the RF packet arrived. This data was then transmitted through a USB port to a PC
and its GUI software was used to create a plot of RF packet arrival angles vs. time.
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
4 / 19
5 Description of project source code
5.1 Code in main.c
The main() function in Sources\main.c initializes the MCU after it comes out of reset. If
MCU code execution was triggered by the first application of power, the PWU timer is
initialized with parameter LOC_ANGLE_RUN_PERIOD, which determines how often the
location angle algorithm will be run.
Next, the program checks if the ending of an RF module packet transmission brought the
MCU out of STOP1 mode. If this is the case, the RF module is disabled and the MCU is
put back into STOP1 mode.
After calibrating the PWU timer with a call to firmware function TPMS_LFOCAL(),
the program checks if the PWU timer brought the MCU out of STOP1 mode. If so,
the loop counter u16LoopCounter is initialized and a do-while() loop is entered. The
loop code decrements the loop counter u16LoopCounter, issues a call to function
vfnProcessLocAngle() and checks the status code returned by the function. The
vfnProcessLocAngle() function does all the processing of the TPMS device's position on
the wheel and the transmission of RF packets at the proper time.
Parameter LOC_ANGLE_RUN_ERR_MAX, which initializes the loop counter
u16LoopCounter, determines the maximum number of times the function
vfnProcessLocAngle() may be called when it keeps returning an error code. The status
codes returned by vfnProcessLocAngle() are defined in the file Project_Headers
\LocAngle.h. The status code is LA_STS_OK=0 if the car is moving, the target angles
were successfully determined by the location angle algorithm and RF packets were
transmitted. If other than LA_STS_OK status code values are returned, then either an
error occurred while monitoring the wheel rotation or the car's speed was determined to
be too low or too high to transmit RF packets. RF packets were transmitted only if the
returned status code is LA_STS_OK.
After exiting the do-while() loop, the program enters STOP1 mode and is brought to RUN
mode again by the PWU timer after its time delay expires.
The file main.c also contains functions to configure the MCU, set up the PWU timer,
define MCU STOP modes and configure GPIO pins.
5.2 Code in interrupts.c
This file contains the source code for the interrupt service routines and the interrupt
vector table.
5.3 Code in LocAngle.c
This file contains the source code for the vfnProcessLocAngle() function called from
main() and all the remaining code implementing the location angle algorithm.
5.3.1 Function vfnProcessLocAngle()
The vfnProcessLocAngle() function first executes a sequence of calls to firmware
functions to calculate the compensated values of voltage, temperature, pressure and
acceleration Z. Next, the calculated acceleration Z is compared to the threshold of
5.9 g to determine if the car is moving or parked. If the car is parked (acceleration Z
≤ 5.9 g), the function exits with status code LA_STS_CAR_NOT_MOVING. If the car
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
5 / 19
is moving (acceleration Z > 5.9 g), the rotation direction finding and location angle
algorithms are executed. In this case, function RF_CreatePacket() is called to fill out
the constant elements of the RF data packet in RFData[] buffer. Next, if enabled, the
wheel rotation direction finding function u8fFindWheelDir() is called. The rotation direction
result is returned in variable u8dWheelDir. Function u8fXGetRotPeriod() is then called
to execute a state sequencer that monitors the accelerometer X samples sequence
to measure the wheel rotation period. The u8fXGetRotPeriod() function returns status
code LA_STS_OK=0 when the rotation period was measured successfully and the
acceleration X sine wave 0-crossing was detected. If so, a call is made to function
Xmit_RF_Packets_Loop(), which transmits RF packets so that each packet ends at a
target location angle defined in array cai16TargetAngle[]. If the status code returned by
u8fXGetRotPeriod() is anything other than LA_STS_OK, no RF packets are transmitted
and function vfnProcessLocAngle() exits immediately.
Figure 1 illustrates the vfnProcessLocAngle() flow.
5.3.2 Function u8fXGetRotPeriod ()
In function u8fXGetRotPeriod(), the accelerometer X data sequence is continuously
read, filtered and processed to determine the wheel rotation period and the sine
wave sequence 0-crossing moment in preparation for calculating the first RF packet
transmission start time.
At the beginning of the function, a call is made to TPMS_E_FRC_CALIB() to calibrate
the FRC frequency. The calibration value, which represents the duration of one LFO
period expressed in microseconds, is returned in variable u16usPerPrd. The function
then measures the wheel rotation period in terms of the FRC period count (in variable
u16FRC_Prd). Using the LFO period duration in variable u16usPerPrd, the wheel
rotation period from the FRC period count (in variable u16FRC_Prd) is converted into
milliseconds and stored in variable u16XPrd_ms.
Next, the function SelectLPF() is called to select which of four possible LPF filters is
to be used for filtering the accelerometer X sample sequence to attenuate noise and
signal distortions. The selection of an LPF is made depending on the car’s speed and is
based on the compensated value of the accelerometer Z reading performed in function
vfnProcessLocAngle() and saved in variables u8AccelOffsetZ and u16CompAccelZ. The
compensated value of acceleration Z represents the Z centripetal acceleration, which is
used as an estimate of the wheel rotation speed.
The NTM88 Dual-Axis Location Angle Project – Algorithms user manual lists the
acceleration Z thresholds and the equivalent car speeds used to decide which LPF to
use.
When a TPMS device with accelerometer X is installed on the wheel such that the X
sensitivity axis is perfectly tangential to the wheel, the sequence of samples should be
a sine wave with an average value equal to 0. In practice, when the accelerometer X
sensitivity axis is not perfectly tangential to the wheel, the resulting sine wave will have
an average value other than 0 representing X centripetal acceleration proportional to
car's speed.
Following the LPF selection in the code and two dummy reads of accelerometer X to
stabilize its ADC input level, the centripetal acceleration of X is estimated by averaging
four consecutive samples of accelerometer X in variable i16AccXCnt_cpt. In the
following while() loop the centripetal offset value in i16AccXCnt_cpt is subtracted from all
accelerometer X samples.
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
6 / 19
After variable initialization, control enters the while() loop. It remains there until the
wheel rotation period and 0-crossing rotation angle 0° or 180° are determined or until an
abnormal conditions occurs that prevents the algorithm from continuing and results in the
function exiting with an error code.
The first operation within the while() loop is to check for a timeout. If a timeout is
detected, control exits the loop with the error code LA_STS_TIMEOUT.
A single pass of the loop has a fixed period of execution time made up of two main
components: 1.35 ms consumed in reading the accelerometer X sample and 1.65
ms consumed in executing the LPF function RunLPF_IIR16x16(). The execution
time of the remaining code instructions in the loop is short and negligible compared
with the above two main components. So, the minimum signal sampling period in
the loop is 1.35 ms + 1.65 ms = 3.00 ms. This is the sampling period used with the
widest bandwidth filter LPF4. For other LPFs, their lower bandwidth is obtained by
proportionally increasing the signal sampling period. For LPF1 the total sampling period
is 13.68 ms, for LPF2 the sampling period is 7.24 ms and for LPF3 it is 4.14 ms. The
additional delay above the minimum 3.00 ms loop delay is implemented by making
dummy calls to the TPMS_E_READ_ACCEL_X() firmware function with a precisely
selected execution time. Implementing the additional required delays in this way allows
execution of temperature stable time delays and saves battery power because the
function TPMS_E_READ_ACCEL_X() spends most of its time in STOP4 mode.
Within the loop code, after checking for a timeout, a sequence of calls is made to the
TPMS_E_READ_ACCEL_X() function with different values of the delay parameter
SAMP_DLY_INIT_xxxxUS depending on the selected LPF and the required total signal
sampling period.
A new accelerometer X sample is then read into the u16UUMA[UUMA_X] array
element. The centripetal offset in i16AccXCnt_cpt is subtracted from the accelerometer
sample and the new sample count in i16XSamp_new is verified to be in the valid
count range between -1023 and +1023. After multiplying the new sample count by 16
to properly scale it, i16XSamp_new becomes the input sample to the low pass filter
function RunLPF_IIR16x16(). The sine wave peak-to-peak amplitude count in variable
i16XSamp_new on LPF input is 3360, which is equivalent to the acceleration change ±1
g. The LPF output sample is returned in variable i16XLPF_out. LPF gain is 1, so at signal
frequencies in the LPF passband, the peak-to-peak sine wave count on the LPF output in
variable i16XLPF_out is also 3360.
Control is then transferred to the main part of the while() loop, which is the state
sequencer implemented with the switch() statement. The state sequencer state number
in the range 0 to 15 is held in variable u8MoveState and the functions performed in each
state are described below.
u8MoveState = 0 – Introduces a delay of 16 samples to fill out internal variables of LPF
and stabilize its output signal.
u8MoveState = 1 – Waits for the sine wave rising or falling slope detection. If the
rising slope is detected first, control proceeds to states 2, 3, 4, 5. If the falling slope is
detected first, control is transferred to states 12, 13, 14, 15.
u8MoveState = 2 – If the sine wave rising slope was detected, waits for sine wave
maximum MAX1. Saves the count at MAX1 in i16XSamp_max1 and waits for the sine
wave LPF output level count to drop X_PRD_LVL_CNT=800 below the maximum.
At this point the FRC counter is saved in u16FRC_PrdStart as the starting time for
measuring the sine wave period. The interpolation is applied between the current and
the previous samples to improve the precision of the period measurement starting time.
Control is transferred to state 3.
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
7 / 19
u8MoveState = 3 – Waits for the sine wave minimum MIN1. Saves the count at
MIN1 in i16XSamp_min1 and waits for the sine wave LPF output level count to rise
X_PRD_LVL_CNT above the minimum. Control is transferred to state 4.
u8MoveState = 4 – Waits for the sine wave maximum MAX2. Saves the count at
MAX2 in i16XSamp_max2 and waits for the sine wave LPF output level count to
drop X_PRD_LVL_CNT below the maximum. When that happens, the peak-to-
peak count of the sine wave is validated to eliminate the possibility of measuring an
invalid period caused by an excessively distorted sine wave. Also, the FRC counter
is saved in u16FRC_PrdEnd as the ending time for measuring the sine wave period.
Interpolation is applied between the last two samples to improve the precision of the
period measurement ending time. Calculates the rotation period as the difference
between u16FRC_PrdEnd and u16FRC_PrdStart and stores the result in terms of the
FRC count in variable u16FRC_Prd. Converts the wheel rotation period from the FRC
count to milliseconds in u16XPrd_ms using the LFO calibrated period in u16usPerPrd.
Checks if the measured period in milliseconds in variable u16XPrd_ms is in a valid
range between ROT_PRD_MAX=400 and ROT_PRD_MIN=50 and if not, function
u8fXGetRotPeriod() exits returning an error code. Calculates the expected LPF output
level at the sine wave 0-crossing in i16XSamp_0crLvl as the average of counts at
MAX1, MIN1 and MAX2. Also, calls function SetLPFDelay() to fill out the variable
u16LPFDlyx10 with the LPF delay, depending on which LPF is selected in u8SelLPF.
The variable u16LPFDlyx10 is used later for target angle delay calculations. Transfers
control to state 5 to wait for 0-crossing level saved in i16XSamp_0crLvl.
u8MoveState = 5 – Waits for the sine wave positive-to-negative 0-crossing level in
variable i16XSamp_0crLvl. Interpolates the FRC count between two consecutive
samples to find the FRC count at the precise 0-crossing level. This is the 0-crossing
point at the top of the wheel top where the rotation angle is 0°, so u8InitAng_0cr is set
to 0. Saves 0-crossing FRC time in variable u16FRC_0cr and transfers control to state
21 in function Xmit_RF_Packtes_Loop(), which handles the RF packets transmission
timing.
If a falling slope is detected first in state 1, control transfers to states 12, 13, 14 and 15,
which are equivalent respectively to states 2, 3, 4 and 5 as described above. In state 15
the 0-crossing happens at the bottom of the wheel where the rotation angle is 180°, so
u8InitAng_0cr is set to 180. After saving the time of 0-crossing in variable u16FRC_0cr,
control transfers to state 21 in function Xmit_RF_Packets_Loop().
Figure 2 and Figure 3 illustrate the u8fXGetRotPeriod () flow.
5.3.3 Function u8fFindWheelDir()
This function determines the wheel rotation direction by analyzing the phase shift
between ±1 g sine waves made up by sequences of samples read from accelerometers
X and Z. The rotation direction result is encoded in bit 0 and bit 1 of variable
u8dWheelDir as follows:
bit 0 = 0 – rotation direction is clockwise (CW)
bit 0 = 1 – rotation direction is counter-clockwise (CCW)
bit 1 = 1 – bit 0 has valid rotation direction information
bit 1 = 0 – it was impossible to determine rotation direction and bit 0 is invalid
The user can configure the project to include or not include the function
u8fFindWheelDir(). If u8fFindWheelDir() is included, the project must be configured to
select whether 2-pole or 4-pole LPFs are used for filtering X and Z sequences. When
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
8 / 19
the software switch DIR_FIND_ENABLE is defined, the function code is included in the
project. If the software switch DIR_LPF_4POLE is defined, 4-pole LPFs are selected. If
DIR_LPF_4POLE is not defined, the default 2-pole LPFs are used.
To make wheel rotation detection more reliable, the algorithm can be configured
to run multiple times. Variable u8dDirCnt is the counter for the number of times the
algorithm runs. In the demo project, u8dDirCnt is initialized with D_REPEAT_CNT=3.
After each run, direction detection is performed and, depending on the result, the
appropriate direction counter is incremented: u8dCWCnt if direction was found to be CW
or u8dCCWCnt if the direction was found as CCW. At the end of the algorithm the two
direction counters are compared and the greater is used as the result of the direction
finding algorithm and that value is stored in the variable u8dWheelDir
In the u8fFindWheelDir() function code, the LFO calibration function
TPMS_E_FRC_CALIB() is called to determine the precise LFO period in u16usPerPrd.
The period in u16usPerPrd is used to calculate a temperature independent timeout
threshold u16FRC_ToutThr.
Next, the readings of accelerometers X and Z are taken to find their offsets (stored in
u8AccelOffsetX and u8AccelOffsetZ) and the estimates of centripetal accelerations X and
Z are found in i16AccXCnt_cpt and i16AccZCnt_cpt.
After initializing variables, the program enters the direction monitoring state sequencer
while() loop. On each pass of the while() loop, the timeout is checked and, if it remains
below the threshold in u16FRC_ToutThr, the function continues by reading samples
of accelerometers X and Z. The new sample X is available in u16UUMA[UUMA_X]
and sample Z is in u16UUMA[UUMA_Z]. The centripetal acceleration components
are then removed and new LPF input samples are stored in i16XSamp_new and
i16ZSamp_new. The X channel LPF can be the 4-pole RunLPF_IIR16x16() or the 2-pole
RunLPF_IIR2P16x16(), depending on DIR_LPF_4POLE switch. Equivalent LPFs for Z
channel are 4-pole RunLPF_IIR16x16Z() and 2-pole RunLPF_IIR2P16x16Z(). The LPFs
return their output samples in variables i16XLPF_out and i16ZLPF_out. Then, one of the
direction state sequencer states is executed with state variable u8MoveState. The states
of the direction state sequencer are described below.
u8MoveState = 0 – Remain in state 0 for the number of loop passes in u8InitCnt to
stabilize the internal variables of the X and Z LPFs.
u8MoveState = 1 – Synchronize the state sequencer with the acceleration X sine wave. If
the sine wave slope is rising, initialize variables and transfer control to state 2 to wait for
the sine wave maximum. If the sine wave slope is falling, initialize variables and transfer
control to state 3 to wait for the sine wave minimum.
u8MoveState = 2 – Decide on the wheel rotation direction at the acceleration X sine
wave maximum. While monitoring the X sine wave values, save the counts of X and
Z sine waves at the X sine wave maximum point: X in variable i16XSamp_max1
and Z in i16ZSamp_Xmax1. When the X sine wave level drops D_X_DIR_CNT=400
count below its peak count saved in i16XSamp_max1, calculate the difference
between i16ZSamp_Xmax1 and the current Z count in i16ZLPF_out and save the
result in i16ZSamp_DirDiff. Then, make the direction decision based on the sign
and count value in i16ZSamp_DirDiff. If the difference value is positive and greater
than D_Z_DIR_CNT=200, increment the CW detection counter in u8dCWCnt. If the
difference value is negative and lower than -D_Z_DIR_CNT=-200, increment the CCW
detection counter in u8dCCWCnt . Then, update the counter of algorithm run repetitions
(u8dDirCnt) and check if the algorithm has already been run the required number of
times. If the algorithm has been repeated the required number of times, set the state
variable u8MoveState to 20 and exit the while() loop.
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
9 / 19
u8MoveState = 3 – Decide on the wheel rotation direction at the acceleration X
sine wave minimum. While monitoring the X sine wave values, save the counts of
X and Z sine waves at X sine wave minimum point: X in variable i16XSamp_min1
and Z in i16ZSamp_Xmin1. When the X sine wave level rises D_X_DIR_CNT=400
count above its minimum count saved in i16XSamp_min1, calculate the difference
between i16ZSamp_Xmin1 and the current Z count in i16ZLPF_out and save the
result in i16ZSamp_DirDiff. Then make the direction decision based on the sign and
count value in i16ZSamp_DirDiff. If the difference value is negative and lower than
-D_Z_DIR_CNT=-200, increment the CW detection counter in u8dCWCnt. If the
difference value is positive and greater than D_Z_DIR_CNT=200, increment the CCW
detection counter in u8dCCWCnt. Then, update the counter of algorithm run repetitions
(u8dDirCnt) and check if the algorithm has already been run the required number of
times. If the algorithm has been repeated the required number of times, set the state
variable u8MoveState to 20 and exit the while() loop.
After exiting the while() loop, if u8dStatus is equal to 0, the direction counters u8dCWCnt
and u8dCCWCnt contain valid data and voting on the most likely rotation direction can
be performed. If u8dStatus is not 0, an error occurred while reading a sensor and the
direction variable u8dWheelDir is cleared to 0x00, indicating that u8fFindWheelDir()
function was not able to determine the direction. Voting is done simply by comparing the
number of times that one direction was detected against the other direction. If u8dCWCnt
> u8dCCWCnt, the lowest two flag bits in u8dWheelDir are set to 0x02, indicating a valid
CW direction. If u8dCCWCnt > u8dCWCnt, the lowest two flag bits in u8dWheelDir are
set to 0x03, indicating a valid CCW direction. If u8dCWCnt=u8dCCWCnt, the return value
in u8dWheelDir is 0x00, indicating that the rotation direction was impossible to determine.
5.3.4 Function Xmit_RF_Packets_Loop()
The Xmit_RF_Packets_Loop() function calculates RF packets transmission start
times so that each packet transmission ends at the required target angle. The number
of target angles at which the software attempts to transmit RF packet is defined as
TARGET_ANG_MAX and values of the angles in degrees are defined by the user in
the array cai16TargetAngle[]. The valid range of TARGET_ANG_MAX is between one
and four. In the demonstration project, TARGET_ANG_MAX=1. Angle values should be
listed in the cai16TargetAngle[] array in ascending order from 0° to 359°. All angles listed
in the array cai16TargetAngle[] are processed in sequence in a circular buffer manner.
After starting the current RF packet transmission, a delay to the next packet transmission
start time is calculated for the next target angle in the list. The calculation is based on
the wheel rotation period determined in function u8fXGetRotPeriod(). If the calculated
delay to start the next packet transmission is shorter than the packet transmission time,
the next packet will not be transmitted. Instead, a delay is calculated for the next listed
target angle. The code in Xmit_RF_Packets_Loop() is made up of two states which are
the continuation of the state sequencer started in function u8fXGetRptPeriod().
u8MoveState = 21 – Control is transferred here from state 5 or 15. At the moment
state 21 executes, the TPMS device is at the bottom or top point of the rotating wheel,
depending on the value in u8InitAng_0cr. The delay to the start of the next RF packet is
calculated and control transfers to state 22 to wait for the transmission to start.
u8MoveState = 22 – Control waits until the designated start time for the next RF packet
transmission, then begins the packet transmission. Based on the target angles list in
the cai16TargetAngle[] array, a delay to the next packet transmission start is calculated.
Control remains in state 22 until all TARGET_ANG_MAX target angles are processed.
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
10 / 19
After all RF packets are processed, function Xmit_RF_Packets_Loop() exits, control is
returned to the main() function and the MCU is put into STOP1 mode, where it remains
until the next PWU timer wakeup interrupt.
Figure 4 illustrates the Xmit_RF_Packets_Loop() flow.
5.3.5 Other functions in LocAngle.c
RF_Init() – Initializes the RF module to make it ready for transmitting the next RF packet.
The transmission rate is 9600 baud, with a carrier frequency of 434.000 MHz and the
frequency deviation ±50 kHz.
RF_CreatePacket() – Fills the RFData[] buffer with data packet elements which remain
constant for all packets transmitted during the current run
RF_UpdatePacket() – Fills the RFData[] buffer with data packet elements specific to the
next packet to be transmitted
RF_CreatePacket_DBG1() – Creates a debug version of the RF packet. Transmitted
packet length is 32 bytes and different variables can be transmitted in the packet to
debug/verify program operation
Calculate_CRC8_CCITT() – Calculates the 8-bit checksum of the packet used in the
demo version
ComputeCrc8Byte() – Used by Calculate_CRC8_CCITT() to calculate the 8-bit packet
checksum
Calculate_CRC_MKW01() – Calculates the 16-bit checksum of the debug version of the
RF packet
ComputeCrc_MKW01() – Used by Calculate_CRC_MKW01() to calculate the 16-bit
packet checksum
i16fnMlts16xs16() – Implements the multiplication of two signed 16-bit fixed-point
numbers and returns a 16-bit signed result. Used in the LPF function RunLPF_IIR16x16()
RunLPF_IIR16x16() – Implements a 4-pole LPF filtering the accelerometer X signal. LPF
coefficients and input/output variables are 16-bit fixed-point numbers
SelectLPF() – Uses the last read compensated acceleration Z value as the wheel
rotation speed estimator and selects the correct LPF to be used for filtering the
accelerometer X signal. The thresholds for LPF selection are shown below. Wheel
rotation speeds in RPM and equivalent car speeds are given for tire size 205/65R16.
LPF1 – for Z acceleration greater than 5.9 g and lower than 13.6 g, car speed greater
than 20.5 km/h and lower than 31 km/h,
LPF2 – for Z acceleration greater than 13.6 g and lower than 51 g, car speed greater
than 31 km/h and lower than 60 km/h,
LPF3 – for Z acceleration greater than 51 g and lower than 155 g, car speed greater
than 60 km/h and lower than 105 km/h,
LPF4 – for Z acceleration greater than 155 g, car speed greater than 105 km/h and
lower than 152 km/h.
SetLPFDelay() – Calculates signal delay through LPF into variable u16LPFDlyx10 to
be used in calculating the starting time of RF packet transmissions. The delay value
returned in u16LPFDlyx10 is in ms multiplied by 10. The delay value is calculated by
straight line approximation of the signal delay vs. the signal period characteristic of the
LPF selected in u8SelLPF.
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
11 / 19
RunLPF_IIR16x16Z() – Implements a 4-pole LPF filtering accelerometer Z signal. Used
in rotation direction finding function
RunLPF_IIR2P16x16X() – Implements a 2-pole LPF filtering accelerometer X signal.
Used in the rotation direction finding function
RunLPF_IIR2P16x16Z() – Implements a 2-pole LPF filtering accelerometer Z signal.
Used in rotation direction finding function
6 RF data packet format
The RF data packet is made up of three sections. These are:
– preamble,
– data section,
– checksum byte or word.
The software can be configured to transmit one of two RF packet types. The packet
type is selected by defining one of two switches in file LocAngle.h used for conditional
compilation:
#define PACKET_NXP_WSIM – Used in the demo version where the program attempts
to transmit TARGET_ANG_MAX 16-byte long packets at target angles defined in the
array cai16TargetAngle[],
or
#define PACKET_DEBUG1 – Used only for debugging purposes. The program transmits
one 32-byte long packet after a rotation period was measured. The data part can be
filled with different variables to verify their values while executing the state sequencer in
function u8fXGetRotPeriod().
Format of demo RF packet enabled by PACKET_NXP_WSIM switch:
byte 0: 0xFF - preamble byte 1
byte 1: 0xAA - preamble byte 2
byte 2: 0x9B - preamble byte 3
byte 3: 0xA1 - preamble byte 4
byte 4: 0x?? - TPMS device ID byte 1
byte 5: 0x?? - TPMS device ID byte 2
byte 6: 0x?? - TPMS device ID byte 3
byte 7: 0x?? - TPMS device ID byte 4
byte 8: 0x?? - tire pressure, high byte
byte 9: 0x?? - tire pressure, low byte
byte 10: 0x?? - tire temperature
byte 11: 0x?? - target angle in degrees divided by 2
byte 12: 0x?? - rotation period in milliseconds, high byte
byte 13: 0x?? - rotation period in milliseconds, low byte
byte 14: 0x?? - packet counter byte
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
12 / 19
byte 15: 0x?? - CRC8 byte
Bytes 0 through 10 are filled out in function RF_CreatePacket() and bytes 11 through 15
are filled out in function RF_UpdatePacket().
Format of debug RF packet enabled by PACKET_DEBUG1 switch:
byte 0: 0x55 - preamble byte 1
byte 1: 0x55 - preamble byte 2
byte 2: 0x02 - preamble byte 3
byte 3: 0x02 - preamble byte 4
byte 4: 0x19 - length of packet data section, 25 bytes
byte 5: 0x?? - 1-st data byte
.
.
.
byte 29: 0x?? - 25-th data byte
byte 30: 0x?? - CRC16, high byte
byte 31: 0x?? - CRC16, low byte
The debug packet is created in function RF_CreatePacket_DBG1(). Using this packet,
any program variables can be monitored by transmitting them in byte positions 5 through
29.
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
13 / 19
7 TPMS NTM88 Location Angle flowcharts
aaa-036734
READ VOLTAGE, TEMPERATURE AND PRESSURE
RUN FUNCTION u8fFindWheelDir()
- FIND WHEEL ROTATION DIRECTION
RUN FUNCTION Xmit_RF_Packets_Loop()
- TRANSMIT RF PACKETS
RUN FUNCTION u8fXGetRotPeriod()
- MEASURE ROTATION PERIOD
- FIND STARTING REFERENCE ANGLE
READ COMPENSATED ACCEL Z
START
YesNo
IS COMPENSATED ACCEL Z > 5.9 g?
CREATE RF PACKET
RETURN
Figure 1. Function vfnProcessLocAngle()
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
14 / 19
aaa-036735
CALIBRATE FRC (LFO) PERIOD
READ ACCEL X CENTRIPETAL OFFSET
ESTIMATE INTO i16AccXCnt_cpt
RUN TIME DELAY APPROPRIATE
FOR SELECTED LPF
RUN LPF - NEW OUTPUT SAMPLE
IS IN i16XLPF_out
- READ NEXT ACCEL X RAW SAMPLE,
- SUBTRACT i16AccXCnt_cpt FROM THE RAW SAMPLE
- NEW X SAMPLE IS IN i16XSamp_new
SELECT LPF
INITIALIZE VARIABLES
CHECK TIMEOUT
START
Yes No
SINE WAVE RISING SLOPE DETECTED?
No Yes
SINE WAVE FALLING SLOPE DETECTED?
SINE WAVE RISING SLOPE 1st
SINE WAVE FALLING SLOPE 1st
Figure 2. Function u8fXGetRotPeriod() - 1
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
15 / 19
aaa-036736
WAIT FOR MINIMUM MIN1
SINE WAVE RISING SLOPE 1st
- WAIT FOR MAXIMUM MAX1
- START PERIOD MEASUREMENT
WAIT FOR SINE WAVE
0-CROSSING MOMENT AT
ANGLE 0º (WHEEL TOP)
- WAIT FOR MAXIMUM MAX2
- END PERIOD MEASUREMENT
- CALCULATE PERIOD
go to state 21
RETURN
WAIT FOR MAXIMUM MAX1
SINE WAVE FALLING SLOPE 1st
- WAIT FOR MINIMUM MIN1
- START PERIOD MEASUREMENT
WAIT FOR SINE WAVE
0-CROSSING MOMENT AT
ANGLE 180º (WHEEL BOTTOM)
- WAIT FOR MINIMUM MIN2
- END PERIOD MEASUREMENT
- CALCULATE PERIOD
go to state 21
RETURN
Figure 3. Function u8fxGetRotPeriod() - 2
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
16 / 19
aaa-036737
- FIND NEXT TARGET ANGLE IN cai16TargetAngle[]
- CALCULATE DELAY TO START OF PACKET XMIT
WAIT UNTIL IT IS TIME TO
START NEXT PACKET XMIT
FIND NEXT TARGET ANGLE IN cai16TargetAngle[],
CALCULATE DELAY TO START OF NEXT PACKET XMIT
START NEXT PACKET XMIT
CHECK TIMEOUT
START
STATE 21
STATE 22
ALL TARGET ANGLES
IN cai16TargetAngle[]
PROCESSED?
No Yes
RETURN
Figure 4. Function Xmit_RF-Packets_Loop()
8 Revision history
Table 1. Revision history
Document ID Release
date
Description
UM11363 v.1 20200327 Initial release
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
17 / 19
9 Legal information
9.1 Definitions
Draft — The document is a draft version only. The content is still under
internal review and subject to formal approval, which may result in
modifications or additions. NXP Semiconductors does not give any
representations or warranties as to the accuracy or completeness of
information included herein and shall have no liability for the consequences
of use of such information.
9.2 Disclaimers
Limited warranty and liability — Information in this document is believed
to be accurate and reliable. However, NXP Semiconductors does not
give any representations or warranties, expressed or implied, as to the
accuracy or completeness of such information and shall have no liability
for the consequences of use of such information. NXP Semiconductors
takes no responsibility for the content in this document if provided by an
information source outside of NXP Semiconductors. In no event shall NXP
Semiconductors be liable for any indirect, incidental, punitive, special or
consequential damages (including - without limitation - lost profits, lost
savings, business interruption, costs related to the removal or replacement
of any products or rework charges) whether or not such damages are based
on tort (including negligence), warranty, breach of contract or any other
legal theory. Notwithstanding any damages that customer might incur for
any reason whatsoever, NXP Semiconductors’ aggregate and cumulative
liability towards customer for the products described herein shall be limited
in accordance with the Terms and conditions of commercial sale of NXP
Semiconductors.
Right to make changes — NXP Semiconductors reserves the right to
make changes to information published in this document, including without
limitation specifications and product descriptions, at any time and without
notice. This document supersedes and replaces all information supplied prior
to the publication hereof.
Applications — Applications that are described herein for any of these
products are for illustrative purposes only. NXP Semiconductors makes
no representation or warranty that such applications will be suitable
for the specified use without further testing or modification. Customers
are responsible for the design and operation of their applications and
products using NXP Semiconductors products, and NXP Semiconductors
accepts no liability for any assistance with applications or customer product
design. It is customer’s sole responsibility to determine whether the NXP
Semiconductors product is suitable and fit for the customer’s applications
and products planned, as well as for the planned application and use of
customer’s third party customer(s). Customers should provide appropriate
design and operating safeguards to minimize the risks associated with
their applications and products. NXP Semiconductors does not accept any
liability related to any default, damage, costs or problem which is based
on any weakness or default in the customer’s applications or products, or
the application or use by customer’s third party customer(s). Customer is
responsible for doing all necessary testing for the customer’s applications
and products using NXP Semiconductors products in order to avoid a
default of the applications and the products or of the application or use by
customer’s third party customer(s). NXP does not accept any liability in this
respect.
Limiting values — Stress above one or more limiting values (as defined in
the Absolute Maximum Ratings System of IEC 60134) will cause permanent
damage to the device. Limiting values are stress ratings only and (proper)
operation of the device at these or any other conditions above those
given in the Recommended operating conditions section (if present) or the
Characteristics sections of this document is not warranted. Constant or
repeated exposure to limiting values will permanently and irreversibly affect
the quality and reliability of the device.
Terms and conditions of commercial sale — NXP Semiconductors
products are sold subject to the general terms and conditions of commercial
sale, as published at http://www.nxp.com/profile/terms, unless otherwise
agreed in a valid written individual agreement. In case an individual
agreement is concluded only the terms and conditions of the respective
agreement shall apply. NXP Semiconductors hereby expressly objects to
applying the customer’s general terms and conditions with regard to the
purchase of NXP Semiconductors products by customer.
Suitability for use in automotive applications — This NXP
Semiconductors product has been qualified for use in automotive
applications. Unless otherwise agreed in writing, the product is not designed,
authorized or warranted to be suitable for use in life support, life-critical or
safety-critical systems or equipment, nor in applications where failure or
malfunction of an NXP Semiconductors product can reasonably be expected
to result in personal injury, death or severe property or environmental
damage. NXP Semiconductors and its suppliers accept no liability for
inclusion and/or use of NXP Semiconductors products in such equipment or
applications and therefore such inclusion and/or use is at the customer's own
risk.
Export control — This document as well as the item(s) described herein
may be subject to export control regulations. Export might require a prior
authorization from competent authorities.
Translations — A non-English (translated) version of a document is for
reference only. The English version shall prevail in case of any discrepancy
between the translated and English versions.
9.3 Trademarks
Notice: All referenced brands, product names, service names and
trademarks are the property of their respective owners.
NXP — is a trademark of NXP B.V.
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
UM11363 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2020. All rights reserved.
User manual Rev. 1 — 27 March 2020
18 / 19
Tables
Tab. 1. Revision history ...............................................16
Figures
Fig. 1. Function vfnProcessLocAngle() .......................13
Fig. 2. Function u8fXGetRotPeriod() - 1 .....................14
Fig. 3. Function u8fxGetRotPeriod() - 2 ..................... 15
Fig. 4. Function Xmit_RF-Packets_Loop() ................. 16
NXP Semiconductors
UM11363
NTM88 Dual-Axis Location Angle Project – Software
Please be aware that important notices concerning this document and the product(s)
described herein, have been included in section 'Legal information'.
© NXP B.V. 2020. All rights reserved.
For more information, please visit: http://www.nxp.com
For sales office addresses, please send an email to: [email protected]
Date of release: 27 March 2020
Document identifier: UM11363
Contents
1 Introduction ......................................................... 1
2 Software requirements ....................................... 1
3 Project organization ............................................1
4 Overview of the TPMS Location Angle
algorithm .............................................................. 2
5 Description of project source code ...................4
5.1 Code in main.c .................................................. 4
5.2 Code in interrupts.c ........................................... 4
5.3 Code in LocAngle.c ........................................... 4
5.3.1 Function vfnProcessLocAngle() .........................4
5.3.2 Function u8fXGetRotPeriod () ........................... 5
5.3.3 Function u8fFindWheelDir() ............................... 7
5.3.4 Function Xmit_RF_Packets_Loop() ................... 9
5.3.5 Other functions in LocAngle.c ..........................10
6 RF data packet format ......................................11
7 TPMS NTM88 Location Angle flowcharts ........13
8 Revision history ................................................ 16
9 Legal information ..............................................17
  • Page 1 1
  • Page 2 2
  • Page 3 3
  • Page 4 4
  • Page 5 5
  • Page 6 6
  • Page 7 7
  • Page 8 8
  • Page 9 9
  • Page 10 10
  • Page 11 11
  • Page 12 12
  • Page 13 13
  • Page 14 14
  • Page 15 15
  • Page 16 16
  • Page 17 17
  • Page 18 18
  • Page 19 19

NXP NTM88 User guide

Type
User guide

Ask a question and I''ll find the answer in the document

Finding information in a document is now easier with AI