Skip to content

impulse-generator

Description

The impulse-generator block generates a sequence of timed impulses consisting of alternating working and sleeping phases. It can be started by a command sent from the command block, by an edge, by a logical level, or automatically after project initialization if its input is not connected to anything.

While running, the block provides separate outputs that indicate the working phase, the sleeping phase, and whether the generator is currently active. If the “Impulse count” parameter is 0, the generator keeps running until it receives the reset command from the command block. For a finite number of impulses, the generator also goes through the sleeping phase after every impulse and returns to the idle state only after the final sleeping phase ends.

Configuration parameters

Parameter name Value
Name (name) Name displayed on the block in the editor. If left empty, impulse-generator is displayed.
Trigger input mode (input_edge) Required parameter that defines the trigger condition for working modes that react to input events. Available values: rising, falling, both, true, false, null. In practice, rising, falling, and both are used most often.
Impulse count (impulses) Required parameter that defines the number of impulses to generate. The available range is 0 to 1000000 impulses. The value 0 means continuous operation without automatic stop.
Working time (working_time) Required parameter that defines the duration of the working phase of a single impulse in milliseconds. Allowed range: from 100 ms to 1209600000 ms (14 days). Set the time using days, hours, minutes, seconds, and milliseconds; when saving, the form sums these components into a total number of milliseconds.
Sleep time (sleeping_time) Required parameter that defines the duration of the pause between consecutive impulses in milliseconds. Allowed range: from 100 ms to 1209600000 ms (14 days). Set the time using days, hours, minutes, seconds, and milliseconds; when saving, the form sums these components into a total number of milliseconds.
Working mode (working_mode) Optional parameter that defines the input control mode. Supported values: dlatch, oneshot, edgereset, leveldriven.

Input handling

The block supports two commands from the command block regardless of the configured “Working mode”:

  • The set command from the command block starts the generator. If the generator is already running, the sequence restarts from the working phase and the impulse counter is initialized from the beginning.
  • The reset command from the command block stops the generator and switches it to the idle state.

If no other block is connected to the block input, the generator starts automatically after project initialization is complete.

In the dlatch, oneshot, and edgereset modes, the input reaction depends on the “Trigger input mode” parameter:

  • rising: react to a false -> true change
  • falling: react to a true -> false change
  • both: react to every logical value change
  • true: react to every message whose new value is logical true
  • false: react to every message whose new value is logical false
  • null: react to every message whose new value is null

Input values other than those supported by the selected trigger condition are ignored. In particular, for rising, falling, both, true, and false, the block requires values that can be interpreted logically, while for null it reacts only to the null value.

Other input signals are handled according to the “Working mode” parameter:

Working mode Description
Edge started and stopped (dlatch) Every event matching the “Trigger input mode” condition toggles the generator between start and stop. When the generator is stopped, such an event starts it. When the generator is already running, the same event stops it.
Edge triggered (oneshot) An event matching the “Trigger input mode” condition starts the generator only when it is idle. Input events received while the generator is running are ignored.
Extended by the edge (edgereset) An event matching the “Trigger input mode” condition starts the generator if it is stopped. If the generator is already running, the next event does not restart the current phase and does not reset the current timer, but it restores the remaining impulse counter to the value from the configuration, so the generator runs longer.
State driven (leveldriven) Logical true starts the generator if it is not already active. Logical false stops the generator. In this mode, the “Trigger input mode” parameter does not affect the start and stop decision, and non-logical values are ignored.

The block does not require the use of inputs labeled using the tag block.

Block outputs

Output number and name Output description
1. Working phase. Returns true only when the generator is in the working phase of an impulse. In all other states it returns false.
2. Sleeping phase. Returns true only when the generator is in the sleeping phase between impulses. In all other states it returns false.
3. Generator active. Returns true when the generator is active, meaning it is either in the working phase or in the sleeping phase. In the idle state it returns false.

The relationship between the outputs is as follows:

  • in the idle state all three outputs are false
  • in the working phase the outputs are: true, false, true
  • in the sleeping phase the outputs are: false, true, true

Block status description

The description visible below the block has one of two values:

  • idle means that the generator is stopped
  • active means that the generator is currently in the working phase or in the sleeping phase

The active status does not distinguish between the working phase and the sleeping phase. Use the block outputs to tell them apart.

Errors visible to the user

The block can display the following error messages:

Error code Error description
Invalid edge configuration. The “Trigger input mode” parameter is invalid or was not provided.
Invalid impulses number configuration. The “Impulse count” parameter has an invalid value.
Invalid working_time configuration. The “Working time” parameter is outside the allowed range from 100 ms to 14 days.
Invalid sleeping_time configuration. The “Sleep time” parameter is outside the allowed range from 100 ms to 14 days.
Invalid working_mode configuration. The “Working mode” parameter has a value other than dlatch, oneshot, edgereset, or leveldriven.
Failed to create timer. Time measurement could not be prepared for the generator.
Failed to start timer. Time measurement could not be started when starting the generator or switching between the working and sleeping phases.
Failed to stop timer. Time measurement could not be stopped when turning the generator off.

If a message starting with Failed to ... keeps appearing, record its full text and contact technical support.

Examples

  • With “Impulse count” set to 1, “Working time” to 1 s, and “Sleep time” to 500 ms, after being started the generator will go through a working phase lasting about 1 s, then a sleeping phase lasting about 0.5 s, and then return to the idle state.
  • With “Impulse count” set to 3, the generator will execute three working phases separated by three sleeping phases and will stop only after the final sleeping phase ends.
  • With “Impulse count” set to 0, the generator will alternate between the working phase and the sleeping phase indefinitely until it receives the reset command from the command block or a stop signal consistent with the selected working mode.
  • In dlatch mode with “Trigger input mode” set to rising, the first rising edge will start the generator and the next rising edge will stop it.
  • In oneshot mode with “Trigger input mode” set to rising, a rising edge will start the generator only when it is in the idle state. Further rising edges received while it is running will be ignored.
  • In edgereset mode with “Impulse count” set to 5 and “Trigger input mode” set to rising, the next rising edge received while the generator is already running will not restart the current phase, but it will extend the total run time by restoring the remaining impulse counter.
  • In leveldriven mode, true starts the generator and false stops it. Values other than logical values are ignored in this mode.
  • If nothing is connected to the block input, the generator starts automatically after project initialization is complete.