LIN Stepper Software Description
LIN Stepper Software Implementation
DRM047 — Rev 0
Designer Reference Manual
MOTOROLA
LIN Stepper Software Description
69
UWord16 variable
frequencyActLowHigh.Word
. This will guarantee
the low resolution (necessary to create low steepness frequency ramps).
For the frequency-to-period calculation and comparison with required
frequency frequencyReq, it is sufficient to use 8-bit information. This
allows to use fast calculations like frequency to speed conversion using
udiv16_8to16.
Then the high byte
frequencyActLowHigh.Byte.High
is accessed.
6.3.4 Actual Frequency to Period Conversion
The conversion from frequency to period requires division.
(EQ 19.)
For software execution optimized calculation we wrote a special
arithmetic function:
UWord16 udiv16_8to16(UWord16 x, UByte y)
with UWord16 output and UWord16 x, UByte y inputs. It is written in
assembler and provides the following calculation:
(EQ 20.)
The conversion must take into account the variables scaling:
(EQ 21.)
(EQ 22.)
So the final calculation using the
udiv16_8to16
function is:
(EQ 23.)
where:
Resolution Period [s] is
RESOLUTION_PERIOD_NS
*1000000000.0
Period
1
Frequency
----------------------------
=
UWord16 Variable3
UWord16 Variable1
UByte Variable3
-------------------------------------------------
=
Resolution Period*(UWord16) periodStep
1
Resolution Frequency*(UByte8) Frequency
---------------------------------------------------------------------------------------------------------
=
(UWord16) periodStep
UWord16
(
)
Resolution Frequency/ResolutionPeriod
(
)
(UByte8) Frequency
------------------------------------------------------------------------------------------------------------------------------------
=
(UWord16) periodStep
UWord16
(
)
CONVERSION_CONST_PERIOD_FERQ
(
)
(UByte8) frequencyActLowHigh.Byte.High
--------------------------------------------------------------------------------------------------------------------------------------------
=
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
.
..