Documentation Home Page Hardware Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

Knock sensor output simulation

Knock Feature Description

The Knock output pins (KNOCK_OUT, KNOCK_HI_RES) of the RPG card are used to emulate a knock sensor output signal.  Knock sensors mounted on the engine block are used to detect shock waves created when the charge inside the cylinder of the engine detonates due to improper engine timing, worn or defective spark plug, etc. Measurement of the analog knock sensor output signal allows the ECU to control knocking by adjusting the spark timing. 

The knock output signal produced by the RPG typically consists in 1 to 15 knock windows of configurable position and duration. Each window represents a cylinder and is referenced to the engine position, as shown in the figure below. Each window outputs an analog signal. Another signal, called the noise signal, is produced when no knock window is active. The source analog signals may be provided as sampled patterns stored in a MAT-file, as an external signal by the BNC connectors of the front plate of the RPG board, or generated by an internal oscillator.



The electrical circuit of the Knock feature operates in two modes that are high quality and window modes. Two output lines generate the corresponding signals:

This output is used to generate continuously a high-quality sine wave with less than 0,01% harmonic distortion. The user can select the frequency of the sine wave from 4 to 15 kHz with a 0,025% resolution (3,6 Hz). This mode is typically used to characterize a circuit's rejection mode.

Electrical characteristics :

      • Harmonic distortion < 0.01%
      • Frequency : 0 to 150kHz

This output generates a burst within a time window where the user is able to select between the cyclic waveform generator, the knock arbitrary waveform generator, or the signal input through the Knock In BNC. When the knock window is not present the module outputs either 0V, noise from the noise arbitrary waveform generator, or the signal from the Noise Input BNC depending on the user’s selection. In this mode, the sine wave is generated with less than 0,1% harmonic distortion. See below for more details on knock signal and noise signal configuration.

For each cylinder, the user is able to program the delay after TDC and the duration of the knock window. These settings are analyzed by the low-level software and translated into events that signal to the FPGA the beginnings and ends of the windows during which the signal bursts are generated. 

Electrical characteristics :

      • Harmonic distortion < 0.1%
      • Termination impedance : 0, 2, 4, 8 or 100 kΩ

Knock signal configuration

  • Pattern-based waveform generator 

In this mode, the model uses a set of patterns stored in a MAT-file as the signal source. For each cylinder, the user can specify the pattern number, the offset relative to the beginning of the pattern, and a sample rate factor. The pattern can either be played once or repeated continuously until the end of the window.

  • Knock arbitrary waveform generator

When the knock internal generator is selected, the internal oscillator amplitude, frequency, and phase can be configured for each window.

These settings are not made available in the Labview user interface of the standard OP6000V2 workspace. If you need to use this mode, refer to the RT-LAB OpFcnKnockGenerator block help file for more details.

  • External signal input 

This signal is input via the Knock In BNC connector on the front plate of the module.

Noise signal configuration

  • Pattern-based waveform generator 

In this mode, the model uses one of the patterns stored in the Knock patterns MAT-file as the signal source. The user selects the pattern number and specifies whether the pattern should be continuously repeated or played once. The offset relative to the beginning of the pattern and a sample rate factor are also configurable.

  • Noise arbitrary waveform generator

When the noise internal generator is selected, the internal oscillator amplitude, frequency, and phase can be configured for each window.

These settings are not made available in the Labview user interface of the standard OP6000V2 workspace. If you need to use this mode, refer to RT-LAB OpFcnKnockGenerator block help file for more details.

  • External signal input 

This signal is input via the Noise In BNC connector on the front plate of the module.

Knock pattern file 

Knock pattern file definition

The pattern file is a MAT-file. It must contain two variables:

    • The first variable is a one-dimensional cell array where each cell defines one pattern. Each cell contains a one-dimensional array specifying the sequential pattern samples in volts. Any number of patterns may be defined and patterns may be of any lengths. 
    • The second variable is a single cell containing a one-dimensional array containing the sample rate in samples per second for each pattern. The length of this array must be equal to the number of patterns.

Here is an example of Matlab commands used to create a pattern MAT-file :

myPatternArray{1} = [0 0.5 1 0.5 0 -0.5 -1 -0.5] % first pattern, 1 volts triangular wave
myPatternArray{2} = [0 1 2 1 0 -1 -2 -1] % second pattern, 2 volts triangular wave
mySampleRates{1} = [100000, 500000] % the sample rates of each pattern
save MyFile.Mat mySampleRates myPatternArray -V6

NOTE: It is mandatory to save the MAT-File in the V6 format. 

Knock pattern file usage

The file must be transferred to the real-time computer before the simulation.

NOTE: The widgets for the Knock pattern file selection and transfer in the Knock tab of the configuration panel are not yet activated. The pattern file path must be specified in the Files properties tab of the RT-LAB model :




OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323
Follow OPAL-RT: LinkedIn | Facebook | YouTube | X/Twitter