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

OpFcn Engine Sync Pattern Gen

Block

Mask

Description

The functionality is used to simulate an engine rotation and produce pulse patterns synchronized on angular engine positions. This feature is called Engine Synchronous Pulse Generation (ESPG).

Pulses may be defined either as:

  • rise and fall engine positions or
  • a start position combined with a pair of time duration specific to each engine direction.

The maximum number of pulses that may be generated on a channel is limited by these factors:

  • The angular resolution. For instance, if the cycle duration is 720° and the angular resolution is 0.1, the maximum possible number of pulses is 7200°.
  • The firmware capacity of 256 events per calculation steps.
  • The engine speed. A faster engine will require more pulses per step.
  • Computation time. Sorting pulses and transfering them to the firmware requires computation time, which may lead to overruns. This is the factor which is the most likelly to cause limitations.Guidelines are provided below for minimizing the computation load.



Important note: Negative speeds, Slow-To-Stop sequences, Pattern Position Switching sequences and time based pulses are supported only by RPG module bitstreams with minor ID 6 or later.


Parameters

Controller NameEach functionality block such as the OpFcnAnalogIn block must refer to an OpCtrl block such as the OP5130 Ctrl block, that will manage the data transfer with the IO board. The binding between OpFcn and OpCtrl blocks is performed via the use of the Controller name that each OpCtrl block uniquely defines. This binding is checked during the initialization phase of the model. If no OpCtrl block is found that defines the same Controller Name as this OpFcnAnalogIn block, the OpFcnAnalogIn block is simply disabled and returns 0s.
Selection of functionalitiesSelection of ESPG channels to be used. The possible values are dependent on the controller block and hardware.
Cycle durationDuration of an engine rotation cycle. Many applications use 720°, which is actually two engine rotations.
Max speed

The maximum speed, in RPM, at which the engine is expected to run. The maximum possible speed is limited by the model sample time. An engine cycle must last at least four calculation steps. Use the following formula to validate the maximum speed:

4 < (Cycle duration) / (6 * Max speed * Model Sample time)

ResolutionResolution in degrees required for the pulse generation. Most applications use 0.1 degrees. This parameter affects the maximum speed. For example, if the resolution is set to 0.001 degrees, the maximum speed (before losing pulses)is 2600 rpm, but if the resolution is set to 0.1 degrees, the maximum speed without losing pulses is 7000 rpm.
Number of PatternsNumber of patterns that will be used for the simulation. This number is required to set the size of the different data buses for the Slow-To-Stop and Pattern Position Switching functionalities.
Maximum pulses per channels

Number of pulses that will be used for a specific channel or all channels of each pattern.

This field can be set with two different possible inputs :

  • a single number X : all channels of each pattern will have X pulses
  • an array of 13 numbers. For example, the following array [1 2 3 4 5 6 7 8 9 10 11 12 13] will set the channel 1 of each pattern to have 1 pulse, the channel 2 of each pattern to have 2 pulses, etc ...
Activity StateActive high or active low pulses may be produced.
Use Slow-to-Stop feature

Create the block inports/outports required for Slow-to-Stop sequences.

A Slow-to-Stop sequence is composed of the following phases:

  • The engine rotation slows down
  • The engine keeps on turning slowly, switching direction at selected positions
  • The engine finally stops once a chosen position is reached
Use Pattern Position Switching featureCreate the block inports/outports required for Pattern Position Switching sequences. A Pattern Position Switching is to occur on the ordered positions set in the "Pattern Switch Angles" input of the block.
Maximum number of pattern position switch points

Maximum number of pattern position switch points that will be used during the Pattern Position Switching sequence.

Slow-to-Stop and Pattern Position Switching are supported only by RPG module bitstreams with minor ID 6 and later. These options and their related settings are disregarded by earlier bitstream revisions.

Inputs

SpeedRotation speed in RPM. A positive value indicates forward rotation (from 0° to Cycle duration) and a negative value indicates backward rotation (from Cycle duration to 0°). Any value between ±Max Speed may be used. For bitstreams that do not support backward rotation, negative values are handled the same as 0.
Pattern SelectNumber that specifies which pattern is to be used at the current model step. This input is disregarded when a STS and/or RPPPS sequence is active.
Pulse Counts NA vector specifying the number of pulses for each channel of the pattern N.
Pattern N

An input (array) is created for each pattern. These are used to describe the pulses to be generated. Each pulse may be described either as start and stop positions or a start position and a time duration.

Each input is a vector whose width is equal to twice the sum of the maximum number of pulses to be generated on each channel. Each pulse has two entries in each channel vector. The content of the pattern vector is ordered based on the sizes set in the Maximum pulses per channels vector.
For example, if the Maximum pulses per channels vector is [150 150 30 30 30 30 30 30 30 30 30 30 30], the total width of Pattern N is 1260, with the first 300 signals reserved for the first channel, and so on.

  • For positional pulses
The first entry is the active edge position and the other inactive edge position. The pulses are always defined for the forward duration and the ESPG block will automatically mirror the pulse around its start position in when to rotation is backward. For instance, a [485° 490°] pulse in the forward direction will become [485° 480°] in the backward direction.
  • For temporal pulses
The first entry is the position of the active edge and the second value indicates the duration for each direction as follows:

[StartPosition 100000000+BackwardDuration*10000+ForwardDuration]

where BackwardDuration is the duration of the pulse in tenths of microseconds when the engine is running backward and ForwardDuration is the duration of the pulse in tenths of microseconds when the engine is running Forward.

The following rules, though not essential, are heavily recommended in order to minimize the required computation time:

  • The pulses must be entered in the correct order and start with the pulse that begins the closest to 0° and finish with the pulse that starts the farthest.
  • Prefer defining a pulse that overpasses 0° as the last pulse
  • Avoid overlapping pulses
  • Avoid mixing time-based pulses with position based pulses on the same channel.
For a given channel, some example of valid patterns would be:

  • [100 200 300 400 500 600 0 0 0 0] with pulse number set to 3.This means three pulses at 100° to 200°, 300° to 400°and 500° to 600°.
  • [100 200 500 50 0 0] with pulse number set to 2. This means two pulses at 100° to 200°, 500° to 50°.
  • [100 200 500 770 0 0] with pulse number set to 2. This means two pulses at 100° to 200°, 500° to 770° (equivalent to 500° to 50° if cycle duration is set to 720°).
  • [250 145679638] describes a pulse with a time-based duration starting at 250°. When the engine speed is positive, the pulse will last 963.8 microseconds. When the engine speed is negative, the pulse will last 456.7 microseconds.
PhasingA vector specifying an angular offset in degrees to be applied to each channel. This is useful to shift individual patterns. Any positive or negative values are supported. This value is considered at every step independently of the Latch input.
Latch

If the input is higher than 0.5, the patterns described on the pattern inputs are to be reloaded.

This mechanism is used to:

  • reduce computation overhead by avoiding unnecessary pattern processing
  • provide the model with the possibility to take several steps to compute the requested pulse patterns and specify when the patterns are finally valid.
Sequence Enable

When this input goes higher than 0.5, a Slow-To-Stop and/or Pattern Position Switching sequence is initiated under the following circumstances:

  • A Slow-To-Stop sequence can only be activated if STS Enable is set to 1 and if all Pattern Switch Warnings are equal to 0.
  • A Pattern Position Switching sequence can only be activated if Pattern Switch Enable is set to 1 and if all Pattern Switch Warnings are equal to 0.

Aborting a STS and/or RPPPS sequence is possible by setting Sequence Enable to 0.When a STS sequence is aborted, the engine will return to its normal mode and will keep the last STS speed as its nominal speed. When an RPPPS sequence is aborted, the engine will return to its normal mode and will keep the last RPPPS pattern as its current pattern.

The following inputs are available when the Slow-to-Stop option is used:

STS EnableWhen this input goes higher than 0.5, a Slow-to-Stop (STS) sequence will be initiated when the Sequence Enable is triggered. Once started, the STS sequence may be interrupted in any STS region.
Important

Once a slow to stop sequence is started, the following signals are saved internally and further changes are disregarded until the end of the Slow-to-Stop sequence:

  • Speed
  • STS Enable
  • STS Speed
  • STS Gradient
  • STS Stabilization Position
  • STS Position Counts
  • STS Positions
  • STS Stop Duration
  • Phasing
  • Pulse counts
  • Pulse positions and durations

Pulse positions and phasing remain configurable for all patterns.

STS Speed

The speed, in RPM, at which the engine is expected to run during the STS sequence. May be either positive or negative. Any engine speed exceeding Max speed will be saturated. The minimum possible speed is:

Minimum speed (RPM) = 1.24176 * Resolution

Any speed entered below this threshold will be interpreted as a stop (0 RPM)

STS GradientThe rate at which the speed will go from the current speed to the STS Speed once the STS sequence is started. The unit is RPM/s. Positive and negative values are accepted but only the absolute value is considered. The application will determine automatically the direction of the speed change.
STS Stabilization PositionThe angular position in degrees around which the engine will be once the slow down is completed. This is useful to position the engine near points of interests (such as the first STS position) since a full engine rotation may last minutes at low speeds.
STS Position CountsNumber of valid positions in the STS Positions inport. The maximum number of STS Positions is 16.
STS PositionsAngular positions in degrees at which the engine will switch the direction during the STS sequence. The last valid value in the signal is the stop position. The consecutive STS positions values must be separated by at least 2 resolution units. Used in conjunction with the STS Position Count input.
STS Stop DurationThe engine will stay stopped until the STS Stop Duration (in seconds) elapses. If this value is 0, the engine will stay stopped until the user changes the engine speed input.
The following inputs are available when the Pattern Position Switching option is used:
Pattern Switch EnableWhen this input goes higher than 0.5, a Pattern Position Switching (RPPPS) sequence will be initiated when the Sequence Enable is triggered. Once started, the RPPPS sequence may be interrupted at any step of the sequence.
Important

 Once a Pattern Position Switching sequence is started, the following signals are saved internally and further changes are disregarded until the end of the sequence:

  • Pattern Switch Enable
  • Pulse Counts
  • Parameters of each switch point (angular position, STS Region Location, engine cycle offset and pattern index)
  • Phasing
Pattern Switch CountsNumber of valid positions in the Pattern Switch Angles inport. This number is not limited.
Pattern Switch AnglesAngular positions in degrees at which the engine will switch pattern during the Pattern Position Switching sequence. The last valid value will be the active pattern once the Pattern Position Switching sequence is completed. Used in conjunction with the Pattern Switch Counts input.
Pattern Switch OffsetsNumber of engine cycles to be reached for each Pattern Switch Angle before switching pattern. Offsets must be set to 0 if the related STS Region is different from -3, -2 or the Pattern Switch Counts value.
Pattern Switch STS RegionsSTS Region that contains the related Pattern Switch Angle. Must be set to 0 if STS Enable is set to 0 or if STS Position Counts is set to 0.

The following describes the different STS Regions and if the user can set an engine cycle offset in the related STS region:

STS Region NumberDescriptionEngine Cycle Offset Allowed
0Region value to specify when STS functionality is deactivated.Yes
-3Region where a pattern will switch before the STS Gradient begins.Yes
-2Region between the STS Gradient starting point and the STS Stabilization Position.Yes
-1Region between the STS Stabilization Position and the first direction switch.No
1 to N - 1 (N = STS Position Counts)Regions where a pattern switch will occur during a STS event.No
10Region where the pattern switch will occur after the STS event has completed.Yes

Pattern Switch Patterns: Pattern to be switched to when the engine meets the related Pattern Switch Angle.

Outputs

Position: Angular position of the engine at the beginning of the current step in degrees.

Status: The possible values are:

ValueDescription
0No errors
-1FIFO accumulation detected. This usually means that an execution overrun occurred (model computation time exceeded the specified sample time).
-2Invalid pulse pattern. One of the pulse patterns did not respect the set of rules described above.
-3Invalid time. Obsolete code that can only be reported by old firmware revisions.
-4FIFO overrun. In this condition, the firmware event FIFO has been cleared. This could result from a model overrun or an engine that is running to fast for the model sample time.
-5FIFO underrun. Obsolete code that can only be reported by old firmware revisions.
-6Number of events exceeds hardware limitation. The hardware is limited to a maximum of 16 events per sample time.
-7STS Position count error. Due to a difference between the vector size for the STS Reverse and Stop Positions input and the STS Position Count input value.
-8Activity State vector has been disabled. Due to incompatible size, the polarity cannot be set for each channel separately. Only global polarity (low/high) will be available.

Current Pattern Set: Displays the number of the current Pattern.

STS Status: Available only if the Slow-to-Stop option is used. Allows monitoring the evolution of a Slow-to-Stop sequence. The possible values are:

ValueDescription
0No STS sequence is in progress and the engine is allowed to rotate freely.
-3The system is waiting for the appropriate moment to start slowing down in order to reach STS Speed near the STS Stabilization Position. 
-2The engine speed is changing from the current speed to the STS Speed value at the rate specified by STS Gradient. This corresponds to the engine slowing down.
-1The engine speed has reached the STS Speed value and the engine position is currently between the STS Stabilization position and the first STS Position.
1 to N - 1 (N = STS Position Counts)The engine is now progressing between specified STS positions, one after the other.
N (N = STS Position Counts)The engine is now stopped, the Slow-To-Stop sequence has reached its end.

Pattern Switch Status: Available only if the Pattern Position Switching option is used. Allows monitoring the evolution of a Pattern Position Switching sequence. The possible values are:

ValueDescription
0No Pattern Position Switching sequence is in progress and the engine is allowed to rotate freely.
1 to N (N = Maximum number of pattern position switch points)A Pattern Position Switching sequence is in progress, the Pattern Position Switch Point index to be reached is displayed.

Pattern Switch Warnings: Allows to monitor the validity of the parameters of each switch point.If at least one warning value is different from 0, the user will not be able to launch a Slow-To-Stop and/or Pattern Position Switching sequence. The possible values are:

ValueDescription
0The parameters of the corresponding switch point are valid.
-10In this STS Region, the use of the engine cycle offset is forbidden. It must be set to 0.
-11The corresponding engine cycle offset is inferior to 0 or is superior to the internally calculated number of rotation required for the STS Slow Down region. This internal calculation is based on different parameters: current speed, STS speed, and STS Stabilization Position
-12The corresponding Pattern Switch Position does not fit, based on the previous Position Switch Angle and the boundaries of the related STS region.
-13The corresponding STS Region is forbidden. The possible values are -3, -2, -1 and 1 to N (N = STS Position Counts value). The transition point between the two STS Regions belongs to the previous STS region.
-14The corresponding Pattern number is forbidden. The possibles values are 1 to N (N = Number of Patterns).

Characteristics and Limitations



Note: The active pattern state is always applied to the ESPG outputs at the beginning of each calculation step. For instance, this means that if the current position is 150° and the block is requested 100° to 200° pulse, the pulse will be active starting at150° rather than waiting for the next passage through 100°.



Direct FeedthroughYes
Discrete sample timeYes
XHP supportYes
Work offlineYes

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323