how to do arithmetic operation using tFrac16 and tS16

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how to do arithmetic operation using tFrac16 and tS16

2,974件の閲覧回数
kelimagna
Contributor I

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

0 件の賞賛
返信
3 返答(返信)

2,746件の閲覧回数
petrz_
NXP Employee
NXP Employee

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.

0 件の賞賛
返信

2,745件の閲覧回数
kelimagna
Contributor I

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>

0 件の賞賛
返信

2,745件の閲覧回数
petrz_
NXP Employee
NXP Employee

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.

0 件の賞賛
返信