ETPU - Converting TCR1 time to TCR2 angle

cancel
Showing results for 
Search instead for 
Did you mean: 

ETPU - Converting TCR1 time to TCR2 angle

Jump to solution
510 Views
mertk
Contributor III

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İ

Tags (2)
0 Kudos
1 Solution
481 Views
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

View solution in original post

2 Replies
482 Views
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
462 Views
mertk
Contributor III

Hi John,

Thanks for your answer.

Take care of yourself.

0 Kudos