Flexible Encoder System Definition

The flexible encoder system definition block provides the mechanism to group together a number of Absolute Sources into a system. This block also allows the application to select at runtime which of those sources is the active source. The pseudo encoder can also be selected (when supported) using this mechanism. System level aspects of the system (like TDC angles for example) are also specified by this block.

The motohawk_flexencoder_project script can be used to create a sample flexible encoder application. Different types of system can be created with this script.

Block ID

Encoder System




Some blocks may display the name of the Encoder System as 'CNK'. The Encoder System name is assumed to be 'CNK' for reasons of backward compatibility with some crank synchronous MotoHawk blocks. Consequently the name of some system attributes that support calibration will be prefixed with 'CNK' like 'CNK_NumCylinders' or 'CNK_TDCAngles'.

Block Parameters

Parameter Field Values Comments/Description Calibration Name
Name Alpha-numeric text, quote enclosed The name of the encoder system. Must be C-legal and unique. This field may be greyed out and have a value of 'CNK'. This is to ensure capability with older crank synchronous behaviors that are not able to select a specific encoder system.
Resource Drop down list The list of encoder system resources that are capable of supporting a flexible encoder system. Not all modules have sufficient hardware capability and/or have note been wired in a manner that allows support for this complex functionality and so the list may be empty.
Crank Angle Degrees in one cycle Drop down list The number of crank angle degrees in an engine cycle. Can be 360 or 720.
Crank Position Source Alpha-numeric text, quote enclosed, cell array Each entry should reference the name of an Absolute Source block that exists in the model. Each of these sources can be switched to become the active source.
Zero Speed Timeout (ms) Integer greater than zero Defines the time without any encoder activity before an encoder source considers that it has observed a zero speed condition. So a value of 1000 implies that an encoder source that does not observe any teeth in 1000ms will be considered to have observed a zero speed condition. The Encoder State will report ZERO_SPEED if this source is the active source. CNK_ZeroSpeedTimeout
TDC Angles (degAfTDC#1) Integer Defines the TDC Angles that will be used by some crank synchronous blocks. Ensure there is a definition for each possible cylinder. CNK_TDCAngles
Num Cylinders Integer greater than zero Defines how many cylinders the application shall use. Must be smaller or equal to the number of elements in the TDC Angles. CNK_NumCylinders
Use Calibration Check Box In general, parameters with a value in the Calibration Name column of this table will support calibration when this checkbox is ticked.
Read Access Level 0-8 Sets security level 1 lowest, 8 highest, for user access to read value. A setting of zero indicates unsecured access is allowed.
Write Access Level 0-8 Sets security level 1 lowest, 8 highest, for user access to write value. A setting of zero indicates unsecured access is allowed.
Instrumentation Group Alpha-numeric text, single-quote enclosed Determines folder name and hierarchy that is applied to calibration parameters defined by this table.

Use "|" character between folder names to delineate subgroup structure.



This unsigned integer signal defines what source the model wants to be the active source. The value will correspond to the Crank Position Source instance or be zero if the pseudo encoder is to be requested.

Active Source

This signed integer signal defines what source is currently considered to be the active source. The value will correspond to the Crank Position Source instance that is considered to be the active source, or to zero when the pseudo encoder is in use, or a negative number if no source is active. An encoder system without an active source can't detect crank angle position and thus prevents the support of crank synchronous behaviors.


When to Switch

The encoder system will likely want to switch encoder sources when it supports redundancy and the active source is issuing faults. While the application model ultimately controls what Absolute Source the encoder system will use for its crank synchronous behaviors, when to switch should be considered based upon the desired performance. For example, observing a Loss Fault will nearly always result in switching to an alternate source. A Synchronization Fault may also constitute a need to switch because the signal should never result in synchronization faults if it is operating correctly. However a Halfcycle Fault or an Inversion Fault may not force a switch. A Halfcycle Fault can result because of setup problems and/or because of problems with the companion sensor. The inversion fault implies a setup problem.

Consequences of Switching

The encoder system aims to make a switch between encoder sources as seemless as possible, but it is not instantaneous.

A switch will result in all crank synchronous pulses (like injection and ignition) terminating before the switch is made. The effective encoder relative timings will need to change when the source is switched and consequently the existing timings can't be trusted. Therefore the pulses must be turned off. Furthermore the internal tracking system must achieve a lock with the new encoder source. A lock can only be achieved after two teeth have been observed by the new active encoder source. Consequently there will be a delay between applying the switch and that new source allowing crank synchronous pulse generation to occur.

The Source Lock Trigger block can be used by the application to determine when a lock has been achieved.

Internal Pseudo Encoder

Many modules support an internal pseudo encoder. The Flexible Encoder treats the internal pseudo encoder as another absolute source option. The mechanism to switch to this source is thus treated in the same manner. The condition of the legacy pseudo encoder's enable port is ignored when it is used with the Flexible Encoder. The pseudo encoder is always source zero. The active source port will not report a zero if a pseudo encoder source switch is requested on hardware that does not support a pseudo encoder.

Pseudo Encoder Only System

It is possible to specify an encoder system that only supports a pseudo encoder by not supplying the names of any absolute sources. Specifying such a system may still consume some internal resources that would be used even if no absolute sources are defined. This is hardware dependent. A build will issue a conflict error if the internal resources necessary to support a pseudo encoder are not available for use.