ETPU - Converting TCR1 time to TCR2 angle

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

ETPU - Converting TCR1 time to TCR2 angle

跳至解决方案
1,325 次查看
mertk
Contributor IV

Hello, 

I am working with EngineControl_AN4907 demo. Basically, I am concentrating on the FUEL (etpuc_fuel.c) function and I want to learn how can we get angle from the time by the below calculation. 

mertk_0-1637082634563.png

tmp: the value of the total injection pulse time in TCR1 

Why we are shifting trr right by 6? And then, why we are shifting the result of the divison left by 3?  

Thank you for your help!

Regards, 

Mert KİREMİTCİ

标记 (2)
0 项奖励
回复
1 解答
1,296 次查看
johndiener
Contributor IV

The TRR (tick rate) register has 9 fractional bits, hence the total shift by 9 bits to get the correct units.  The breakdown of the needed 9 bit shift into components of 6 and 3 is an attempt to maximize precision while keeping the calculation simple and preventing any overflow issues, I believe.  I've developed a slightly more complicated algorithm to enhance precision, see below.  Other options exist.

johndiener_0-1637167342497.png

 

John Diener

在原帖中查看解决方案

2 回复数
1,297 次查看
johndiener
Contributor IV

The TRR (tick rate) register has 9 fractional bits, hence the total shift by 9 bits to get the correct units.  The breakdown of the needed 9 bit shift into components of 6 and 3 is an attempt to maximize precision while keeping the calculation simple and preventing any overflow issues, I believe.  I've developed a slightly more complicated algorithm to enhance precision, see below.  Other options exist.

johndiener_0-1637167342497.png

 

John Diener
1,277 次查看
mertk
Contributor IV

Hi John,

Thanks for your answer.

Take care of yourself.

0 项奖励
回复