NXP NTM88 User guide

Type
User guide
UM11361
NTM88 Single-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 software version 2.0 designed to run on NXP's TPMS part NTM88H05,
which includes a single-axis accelerometer X. 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 such 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. One, two, three or four target location angles can be specified in
the user code and, depending on the wheel rotation speed, up to four RF data packets
can be transmitted during one full wheel rotation. All TPMS location angle processing is
based on accelerometer X data.
The NTM88 Single-Axis project is closely related to the NTM88 Dual-Axis project. The
only differences between the two projects are:
Wheel rotation detection – In the Dual-Axis project, the compensated value of
accelerometer Z and the centripetal acceleration are used to determine if the car is
moving. In the Single-Axis project, function u8fWheelRotDet() determines if the car is
moving by analyzing the compensated acceleration readings of accelerometer X.
Low Pass Filters (LPF) implementation – In the Dual-Axis project there are four
LPFs: LPF1, LPF2, LPF3 and LPF4. In the Single-Axis project there are three LPFs:
LPF_4HZ, LPF_9HZ and LPF_20HZ. The bandwidths of the LPFs used in the two
projects are similar but slightly different.
LPF selection – For optimal performance when measuring the rotation period, LPF
selection must be based on the wheel rotation speed. In the Dual-Axis project,
accelerometer Z centripetal acceleration is used to estimate the rotation speed and
select the LPF. In the Single-Axis project, a sequence of calls must be made to the
period measurement function u8fXGetRotPeriod(LPFSel), with parameter LFPSel
selecting one of the three LPFs. The sequence of calls is described in Section 5.
The processing of accelerometer X sine waves to measure the rotation period and to
calculate target angles is the same in both projects. The description of accelerometer
X sine wave processing presented in the Dual-Axis project document NTM88 Dual-
Axis Location Angle Project – Algorithms User Manual can be used as a reference for
analyzing NTM88 Single-Axis project functions.
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
2 Software Requirements
The NTM88 Single-Axis Location Angle 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_x_lib.lib.
8558 bytes of MCU flash memory
293 bytes of MCU RAM
3 Project Organization
The NTM88 Single_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 the NTM88 device family.)
The project components are provided in the zip file NTM88_LocAngle_vxxx.zip. This file
contains the full CodeWarrior project with all required files in their appropriate directories.
After the project has been unzipped and imported to a CodeWarrior workspace and
compiled without errors, executable code is ready to be programmed into a TPMS
NTM88 device's flash memory. If a compilation error occurs during this process, execute
the CodeWarrior menu command ‘Project\Clean…’.
The organization of project directories and source code files is as follows:
directory Lib:
NTM88_AppLib_v2-2.lib – the file containing theTPMS Application Library for NTM88
ntm88_axis_x_lib.lib – the library file containing all TPMS NTM88 firmware functions
NTM88_LIB.c – the CodeWarrior project file. In this project, the NTM88_LIB.c file is
modified as a workaround for the CodeWarrior default project file. It contains TPMS
NTM88 device register definitions.
directory Project_Headers:
derivative.h – the CodeWarrior definition of project device type
LocAngle.h – the header file associated with 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 NTM88
TPMS Application Library
ntm88_axis_x_lib.h – the header file with library firmware function declarations
NTM88_LIB.h – the CodeWarrior project file with the NTM88_LIB.h file modified
as a workaround for the CodeWarrior default project file. NTM88_LIB.h 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 function source code
main.c – the TPMS application project main function source code
4 Overview of the TPMS Location Angle algorithm
The purpose of the Location Angle 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
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
each packet's transmission ends when the TPMS is at pre-defined location angle
selected by the user. The algorithm's operation is based only on the accelerometer's X
data.The sequence of events is described below.
The program is designed to run periodically every LOC_ANGLE_RUN_PERIOD seconds
(default = 4), as defined in main.c. Between runs, the TPMS MCU remains in STOP1
mode. After starting each run, the program determines if the wheel is rotating and, if
so, measures the rotation period. Then an RF data packet is transmitted such that its
transmission ends at one of the predefined location angles.
Initially, the software determines if the car is parked or moving by comparing the
accelerometer X compensated value saved during the previous run with compensated
accelerometer X readings taken in this run. The number of acceleration X readings and
the time delays between them can be configured by the user in the source code. If all
acceleration X data points read during this run are within a narrow window around the
acceleration saved in the previous run, acceleration X is assumed to remain constant,
which means the wheel is not rotating. In such cases, program execution ends and the
MCU enters STOP1 mode. If, on the other hand, any of the newly read acceleration X
data points is outside the window, the wheel is assumed to be rotating. In this case the
program starts monitoring the sequence of raw accelerometer X sine wave samples
to measure the rotation period. Detection of wheel rotation is performed in function
u8fWheelRotDet(), which returns the status byte that indicates whether or not the wheel
is rotating.
The function u8fXGetRotPeriod() measures the wheel rotation period and returns a
status byte which is used to decide whether or not the RF packets should be transmitted.
If the rotation period was determined successfully and the car's speed is within the
predefined speed range, the RF packets are transmitted. In this case, the program
generates the appropriate time delays and transmits the predefined number of RF
packets, and then exits to STOP1 mode. If the car's speed is too slow or too fast or if the
program was not able to determine the rotation period (for example, due to a high level
of noise in the accelerometer X samples sequence), the program exits to STOP1 mode
without transmitting any RF packets.
To help the higher level user application program cope with noise and distortions in
the accelerometer X signal, the function measuring the wheel rotation period accepts a
parameter selecting the bandwidth of the low-pass filter (LPF) to be used for processing
accelerometer X signals.
5 Low Pass Filter filtering accelerometer X signal
The LPF implemented in function RunLPF_IIR16x16() is used to filter noise out of the
accelerometer X signal. One set of digital LPF coefficients is used, and by adjusting
the signal sampling frequency, different LPF filter bandwidths can be selected (which is
equivalent to having different LPFs). Three possible LPFs are available: 4Hz, 9Hz and
20Hz, each of which can be selected by passing the appropriate parameter to function
vfnProcessLocAngle(…): LPF_4HZ, LPF_9HZ or LPF_20HZ. The bandwidth of each
LPF determines the maximum car speed at which it can be used and the parameters
of the three LPFs, including the maximum wheel RPM and car speed for test tire size
P205/65R16, are shown in Table 1. The digital LPF is IIR 4-pole type.
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
Table 1. LPF parameters – data for tire size 205/65R16
LPF bandwidth in LPFSel
LPF_4HZ LPF_9HZ LPF_20HZ
Sampling frequency
[Hz]
73 153 333
Sampling period [ms] 13.7 6.55 3.0
Maximum RPM [RPM] 260 550 1200
Maximum car speed
[km/h]
33 70 152
When the MCU comes out of STOP1 mode, the program starts running and function
u8fWheelRotDet() returns the status indicating that the car is moving and the car speed
is unknown. The user program should call the u8fXGetRotPeriod() function up to three
times with parameters increasing the LPF bandwidth in the following sequence:
1. Call status=u8fXGetRotPeriod(LPF_4HZ) with the narrow bandwidth 4 Hz LPF.
2. If the returned status is LA_STS_MOVING_TOO_SLOW=3, the car is moving too
slowly. Go to exit.
3. If the returned status is LA_STS_OK=0, the narrow bandwidth LPF is usable. Go to
transmit RF packets, then go to exit.
4. If the returned status is LA_STS_NO_OK=1, then call status= u8fXGetRotPeriod
(LPF_9HZ) with the medium bandwidth 9 Hz LPF.
5. If the returned status is LA_STS_OK=0, the medium bandwidth LPF is useable. Go to
transmit RF packets, then go to exit.
6. if the returned status is LA_STS_NO_OK=1, then call status= u8fXGetRotPeriod
(LPF_20HZ) with the wide bandwidth 20 Hz LPF.
7. if the returned status is LA_STS_OK=0, the wide bandwidth LPF is useable. Go to
transmit RF packets, then go to exit.
8. if the returned status is LA_STS_NO_OK=1 then exit with error – wheel rotation
period cannot be determined.
6 Project source code
6.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.
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
LPF_20HZ is the default LPF used for demonstration purposes and passed in variable
u8LPF_BW as a parameter to function vfnProcessLocAngle(u8LPF_BW). The user must
modify the code of this function as required and implement the sequence presented in
Section 5 for optimal performance in the full range of car speeds.
Parameter LOC_ANGLE_RUN_ERR_MAX, which initializes the loop counter
u16LoopCounter, determines the maximum number of times that 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, 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.
6.2 Code in interrupts.c
This file contains the source code for the interrupt service routines (ISR) and the interrupt
vector table.
6.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.
6.3.1 Function FRC_COMP_DLY(UINT16 FRCCmpCnt)
This function executes the delay passed as a parameter in FRCCmpCnt. The value of
the requested delay is in milliseconds and the valid range of delays is 4ms to 65535ms.
This function uses Free Running Counter (FRC) to execute the delay. After configuring
the FRC registers, the MCU enters STOP4 mode to save power during the delay. Before
this function is called, the MCU STOP mode must be configured to be STOP4. The
MCU resumes code execution when the FRC compare interrupt is generated at the end
of the delay time. The code in this function works together with the FRC compare ISR
vfnFRCIsr() function in the file interrupts.c.
6.3.2 Function u8fWheelRotDet()
Code in this function detects if the wheel is rotating based on compensated
accelerometer X readings. First, the compensated X value u16CompAccelXPrev
saved in the previous program run is used to calculate the window's low and high
thresholds in variables i16ThrLow and i16ThrHi. Next, up to ROT_DET_POINTS=3
readings of acceleration X are taken and checked to see if the readings are within the
window's i16ThrLow and i16ThrHi thresholds. If any of the readings is outside of the
window, it means that the wheel is rotating and the function exits returning status 0. If
all the acceleration X readings were within the window, the status returned is 1, which
means the wheel is not rotating. Time delays between the readings are defined in array
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
cau16RotDetDly[]. The delays are specified in milliseconds. The delays are executed by
calling function FRC_COMP_DLY(…) with MCU in STOP4 mode during the delay.
It is highly unlikely but possible that this function might return the incorrect status. This
could happen at one wheel rotation speed if acceleration X data points are taken at
the moment their values fall within the window between i16ThrLow and i16ThrHi. If, in
addition, the sum of both delays in cau16RotDetDly[] array happens to be equal to the
wheel rotation period, the function would return status 1 (wheel is not rotating).
Depending on application software requirements the user can customize this function
operation by modifying these parameters:
ROT_DET_POINTS – The number of acceleration X data points to consider. With the
value 1, the function executes the fastest but the probability of returning incorrect status
is the highest. With the value 4 and properly selected time delays, wheel rotation is
always detected correctly.
ACCEL_X_MOVE_THR – The width of the window around u16CompAccelXPrev used
to calculate thresholds i16ThrLow and i16ThrHi.
UINT16 cau16RotDetDly[] – The array with time delays between reading acceleration X
data points.
The values of these parameters used in the demo project are a reasonable compromise
between rotation detection reliability and MCU power consumption.
6.3.3 Function vfnProcessLocAngle(UINT8 LPFSel)
The vfnProcessLocAngle() function first executes a sequence of calls to firmware
functions to read the values of voltage, temperature, pressure and acceleration
X. Next, a call is made to function u8fWheelRotDet(), which detects whether the
wheel is rotating. When the status returned by u8fWheelRotDet() is 0, the car is
moving and if the status is 1, the car is not moving. If the car is not moving, the
vfnProcessLocAngle() function exits with status code LA_STS_CAR_NOT_MOVING.
If the car is moving, the location angle algorithm is executed. In this case, function
RF_CreatePacket() is called to fill out the constant elements of the RF data packet in the
RFData[] buffer. Function u8fXGetRotPeriod(LPFSel) is then called, which executes the
state sequencer monitoring accelerometer X samples sequence to measure the wheel
rotation period. The LPF to be used is passed as a parameter in the LPFSel variable.
The u8fXGetRotPeriod(LPFSel) function returns the status code LA_STS_OK=0 when
the rotation period was measured successfully and the acceleration X sine wave 0-
crossing was detected. If status returned by u8fXGetRotPeriod(LPFSel) is anything other
than LA_STS_OK=0, no RF packets are transmitted and the function exits immediately
returning the status value to main(). The possible reasons that the status could be
different than LA_STS_OK=0 are:
LA_STS_NO_OK=1 – An LPF with too narrow a bandwidth for the given car speed
was selected or the accelerometer X sine wave is so distorted that it was impossible to
measure its period.
LA_STS_MOVING_TOO_FAST=2 – The car is moving too fast to transmit RF packets.
LA_STS_MOVING_TOO_SLOW=3 – The car is moving too slowly.
LA_STS_TIMEOUT=4 – A timeout occurred because the car is moving very slowly.
If the status returned by u8fXGetRotPeriod(LPFSel) is LA_STS_OK=0, the function
Xmit_RF_Packets_Loop() is executed, transmitting RF packets at proper times
such that packet transmissions end at the target location angles defined in array
cai16TargetAngle[]. Control is then returned to main().
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
6.3.4 Function u8fXGetRotPeriod(UINT8 LPFSel)
The u8fXGetRotPeriod(LPFSel) function is the main function where 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.
The function accepts parameter LPFSel, which selects one of the three LPF filters
used for filtering the accelerometer X samples sequence to attenuate noise and
signal distortions. A method of selecting the appropriate LPF filter for optimal software
performance is described in Section 5.
At the beginning of the function, a call is made to TPMS_E_FRC_CALIB() to calibrate the
FRC frequency. The calibration value, returned in the variable u16usPerPrd, represents
the duration of one LFO period expressed in microseconds. The code that follows
measures the wheel rotation period in terms of the FRC period count and uses the value
in u16usPerPrd to convert the wheel rotation period from the FRC count in variable
u16FRC_Prd to milliseconds in variable u16XPrd_ms.
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 the
car's speed.
Following the 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.
After variable initialization, the 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 condition 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 is consumed in reading the accelerometer X sample and 1.65
ms is consumbed 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 LPF_20HZ. For other LPFs, their lower bandwidth is obtained by
proportionally increasing the signal sampling period. For LPF_4HZ the total sampling
period is 13.65 ms and for LPF_9HZ the sampling period is 6.55 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. This way of implementing the additional required delays allows execution
of temperature stable time delays and saves battery power because the function
TPMS_E_READ_ACCEL_X() spends most of the time in STOP4 mode.
In 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
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
SAMP_DLY_INIT_xxxxUS depending on the selected LPF and the required total signal
sampling period.
Then a new accelerometer X sample is read into the u16UUMA[UUMA_X] array element.
Next, the centripetal offset in i16AccXCnt_cpt is subtracted from the new 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 3456, 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 3456.
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 detection of the sine wave rising or falling slope. 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=812 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.
u8MoveState = 3 – Waits for 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 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, function SetLPFDelay() is called 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. Control is
transferred to state 5 to wait for the 0-crossing level saved in i16XSamp_0crLvl.
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
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 where the rotation angle is 0°, so u8InitAng_0cr is set to 0.
Saves the 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().
6.3.5 Function Xmit_RF_Packets_Loop()
The Xmit_RF_Packets_Loop() function calculates RF packet 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 packets 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 arrival of the designated start time for
the next RF packet transmission and then begins the packet transmission. Next,
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.
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.
6.3.6 Other functions in LocAngle.c
RF_Init() – Initializes the RF module to prepare 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 out the RFData[] buffer with data packet elements that remain
constant for all packets transmitted during the current run
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
RF_UpdatePacket() – Fills out 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. The 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 packet used in the
debug version of the project
ComputeCrc_MKW01() – Used by Calculate_CRC_MKW01() to calculate the 16-bit
packet checksum
i16fnMlts16xs16() – Implements multiplication of two signed 16-bit fixed-point numbers
and returns a 16-bit signed result. Used in LPF function RunLPF_IIR16x16().
RunLPF_IIR16x16() – Implements a 4-pole low pass filter filtering the accelerometer X
signal. LPF coefficients and input/output variables are 16-bit fixed-point numbers.
SetLPFDelay() – Calculates the 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 milliseconds multiplied by 10.
7 RF Data Packet Format
The RF data packet is made up of three sections:
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 array
cai16TargetAngle[],
or
#define PACKET_DEBUG1 – used only for debugging purposes, the program transmits
one 32-byte long packet after measuring a rotation period. 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
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
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 bytebyte 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
Debug packet is created in function RF_CreatePacket_DBG1(). Using this packet, any
program variable can be monitored by transmitting it in byte positions 5 through 29.
8 Revision History
Document ID Release
date
Descriptions
UM11361 v.1 20200327 Initial release
NXP Semiconductors
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
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
UM11361
NTM88 Single-Axis Location Angle Project − Software
UM11361 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 / 14
Tables
Tab. 1. LPF parameters data for tire size
205/65R16 .........................................................4
NXP Semiconductors
UM11361
NTM88 Single-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: UM11361
Contents
1 Introduction ......................................................... 1
2 Software Requirements ...................................... 2
3 Project Organization ........................................... 2
4 Overview of the TPMS Location Angle
algorithm .............................................................. 2
5 Low Pass Filter filtering accelerometer X
signal .................................................................... 3
6 Project source code ........................................... 4
6.1 Code in Main.c .................................................. 4
6.2 Code in interrupts.c ........................................... 5
6.3 Code in LocAngle.c ........................................... 5
6.3.1 Function FRC_COMP_DLY(UINT16
FRCCmpCnt) ..................................................... 5
6.3.2 Function u8fWheelRotDet() ............................... 5
6.3.3 Function vfnProcessLocAngle(UINT8
LPFSel) .............................................................. 6
6.3.4 Function u8fXGetRotPeriod(UINT8 LPFSel) ......7
6.3.5 Function Xmit_RF_Packets_Loop() ................... 9
6.3.6 Other functions in LocAngle.c ............................9
7 RF Data Packet Format .................................... 10
8 Revision History ................................................11
9 Legal information ..............................................12
  • 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

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