Hi, I am using the standard ETPU engine control library (AN4907SW or NXP etpu function generator site) decoding a 35-1 teeth with **no** CAM function and therefore engine cycle is 36 teeth (1 revolution). The engine is 2-stroke engine and no need for CAM function. I have changed macros in MCU application as below. I couldn't understand the tooth period (TCR1) and RPM conversion. Can you express where does it come from?

#define SYS_FREQ_HZ 150E6

#define TCR1_FREQ_HZ (SYS_FREQ_HZ/2)

#define TEETH_TILL_GAP **35 **

#define TEETH_IN_GAP **1**

#define TEETH_PER_CYCLE **36**

#define TCR2_TICKS_PER_TOOTH 1000

#define TCR2_TICKS_PER_CYCLE ((TEETH_PER_CYCLE)*(TCR2_TICKS_PER_TOOTH))

#define MSEC2TCR1(x) (TCR1_FREQ_HZ/1E3*(x)/1E0)

#define USEC2TCR1(x) (TCR1_FREQ_HZ/1E3*(x)/1E3)

#define DEG2TCR2(x) ((x)*TCR2_TICKS_PER_CYCLE/**360**)

#define UFRACT24(x) ((x)*0xFFFFFF)

#define TCR12USEC(x) (x / ( TCR1_FREQ_HZ / 1E6 ))

#define TCR2DEG(x) (**360***(x)/TCR2_TICKS_PER_CYCLE)

/* Tooth Period [TCR1] and RPM */

#define RPM2TP(x) (TCR1_FREQ_HZ/(x)*60/(**TEETH_PER_CYCLE**))

#define TP2RPM(x) (TCR1_FREQ_HZ/(x)*60/(**TEETH_PER_CYCLE**))

-------------------------------------------------------------------------------------------------------------------------------------------------

In NXP AN4908 Engine control demo application document page 6, the conversion is below for a 4-stroke engine;

Regards,

It's algebra. The CRANK routine gives you a log of the number of TCR1 cycles (documented in AN4907 as "• The measured tooth periods can optionally be logged to an array.") that were observed during the previous tooth. You are inferring the engine speed by figuring out how long it took for a single tooth to fly by your crank wheel detector. The slower the engine, the more time, the faster the engine, the faster the teeth fly by.

TCR1 is a free running clock, so you get TCR1_FREQ_HZ or in your case 1,000,000 pulses per second.

x is your measured number of pulses during the previous tooth in pulses per tooth.

60 is the number of seconds in a minute.

TEETH_PER_CYCLE relates to your tone wheel with 36 teeth. Since you are using a 2-cycle, this gives you 36 teeth per revolution.

So, as each tooth gets detected, CRANK will sample TCR1 to figure out what time it is and subtract that number from the time of the previous tooth. That tells you how many TCR1 counts went by for that tooth. Now that you know how much time it took for a tooth to go by, work the math backwards to figure out what engine speed gives you that time.

so:

(TCR1_FREQ_HZ /(x)*60/(TEETH_PER_CYCLE))

Substituting the stuff above:

(1,000,000 pulses/second / (

xpulses/tooth) * 60 seconds/minute / (36 tooth/rotation))1,000,000 pulses * tooth * 60 seconds * rotation

= _____________________________________________

second *

xpulses * minute * 36 tooth= 1,000,000 * 60

________________ rotations/minute

x* 36So if your tooth log[0] gives you a number like 850, plop 850 into the x term of the equation and that would be 1960 RPM.

A log value of 1666 would give you 1000 RPM, a nice idle.

Is this what you were looking for?

Andrei