Hi, there,
I am using AMMCLIB on S12ZVML micro. I will need to the calculation as below:
(tU16 - tU16) * tFrac16 / tS16
I have tried convert tU16 to tS16, tFrac16 to tS16, do the math and convert the result back to tFrac16. It didn't work. Please advise how to do it or if there is a walk around.
Thanks, Ke
Hi,
AMMCLib does not support mixed integer/fractional arithmetic. If you scale all your values into the fractional range, you will be able to use the fractional arithmetic functions from the MLIB library.
P.
Petrz,
Thanks for your response. I have tried converting the tS16 to tFrac16. It didn’t work. I guess it was because of the overflow. So I tried to convert tS16 and tFrac16 to tS32. Didn’t work either. Any suggestions?
Thanks,
Ke Li
Electrical Engineering, Software Engineer
Magna Closures
521 Newpark Blvd
Newmarket, Ontario L3Y 4X7 Canada
OFFICE: +1 905-898-6744 x2329
ke.li@magna.com<mailto:ke.li@magna.com>
You can't convert an integer value to a fractional value without rescaling. A properly scaled fixed-point model of a physical system will not overflow. I assume you are familiar with the concept of scaling of physical quantities into a normalized fixed-point range.
P.