Knock Sensing

BMW M102/M106 engines (similar to M30 + turbo) are factory equipped with two knock sensors. I'm trying to utilize them...

- Unfortunately at the moment there's only support for one sensor at-a-time in firmware. I'd definitely like to utilize both of them in the future, but for now I need to stick with the second one which is located between cyl. 5-6. It is the well-known place of knock, more than the first sensor location, since cyl.6 is the hottest one.


How to set up the characteristic knock frequency?

Bore is 92mm, so r=46mm.

1. Theory

The expected knocking frequency is around 900/(pi*r) = 900/(3.14*46) = 6.2kHz

See TPIC8101 datasheet (using 4 MHz crystal; for reference, 0x29 = decimal 41 = appr 7 kHz)

2. Experience

* record the knock-sensor output with notebook soundcard while knock sensor is connected (with a 50k series resistor) to the microphone input of a laptop.

I couldn't get my resonance frequency in spectral view or freq analysis either.




  • I was going to play high and raised ignition advance gradually on boost to get signals just like real life situations.
A snippet from slight knock:



I think frequency analysis didn't justify expectations rather amplitude changes shows quite a difference!

I've marked the knocking area with gray background. The long "needles" in the waveform view are the "pings".

This is a shot of a bit heavier knock (still couldn't be heard by naked ear):


Unfortunately it is clipped because of excessive volume.

This is a compilation of three records, one with no knock, second with slight knock and third with heavier knock:

After listening to it a few times I can recognize very slight knock (high pitch "pings") even where amplitude or spectral analysis doesn't show.

Interestingly only left channel (knock sensor 2) hears slight knock -it should be a rear cylinder- and it is not reported by sensor 1.

- It is clear that distinguishing sensors with cam-sync is a must for large engine blocks. (BMW uses two sensors even on 4cyl engines)

- Second observation is HUGE amplitude changes over rev-range. I think calibration of noise (in best case by one-time learning) is necessary on several (4-8?) points of revolutions. It seems much more consequent to base sensing on amplitude deviances from a set of tight (noise amplitude) reference values. Even frequency calibration seems unrelevant compared to those big amplitude differences.

I have to point out that all these experiments were slight knock without making any damage to my engine, and were -in fact- undetectable from the cabin.


From TPIC8101 datasheet config value 39 stands for 6.37kHz, which is probably close to current typical knock freqency.

* from global.h: uint8_t knock_conf; // knock, config. bit0 o FF means knock2... ??

o FD means knock1... (DEFAULT!)

# Overall System Settings

# Knock selection

knock_conf = FF # enable knock-detection, will use Channel2!

knock_sampling_window = e2 # ???

# Use knock sensing in this RPM range

# FF for both means no knock sensing/control???

knock_minrpm = 05 # FF=No minimum RPM. 0x01=100rpm

knock_maxrpm = FF # FF=No maximum RPM

knock1_frequency = 27 # dec 39, 6.37kHz

knock1_gain = 40 # ???

knock1_integrator = 14 # ???

knock2_frequency = 27 # dec 39, 6.37kHz

knock2_gain = 40 # ???

knock2_integrator = 14 # ???

# Trigger level

knock_threshold = 50 # ???

knock_noise_scale = 10 # ???

# Ignition effects


# Knock getting louder

knock_max_retard = 50 # 20 degreees, 0x01=0.25 crank degrees. knock_default_retard = 10 # *0.25 crank degrees.

knock_retard_step = 08 # 3.2 degrees

knock_retard_delay = 10 # 0x01=15ms Retard delay.

# Knock getting softer

knock_advance_step = 02 # *0.25 crank degrees.

knock_advance_delay = 10 # 0x01=15ms

I'm totally lost with these config values. Couldn't find any usable info for those ??? values. Any idea?

See lcd_display.c for the displayed knock values.

Most importantly: lcd_knock_diff ("d:...") and you'll see that increasing gain increases this. We like to set gain so above d:100 means knock. There are no sharp limits here.