Skip to content

sequence-detector

The sequence-detector block is used to detect a sequence of rising edges occurring one after another on inputs labeled using tag blocks. After the full sequence is detected successfully, the block becomes active for 1 second and outputs the value true. The block can be used, for example, to detect the direction of movement of a person passing by several sensors one after another.

Configuration parameters

Parameter name Value
Maximum sequence duration (time_limit) Numeric field specifying the maximum time within which the full tag1, tag2, ..., tagN sequence must be detected. The minimum value is 0.1 seconds and the maximum value is 64800 seconds (that is, 18 hours). Step: 0.1 seconds.

Input handling

The sequence-detector block supports only inputs labeled using tag blocks. The inputs must be configured as a sequence of consecutive tags starting from tag1. At least two tags and at most twenty tags must be connected to the block.

Valid input configuration examples:

  • tag1, tag2
  • tag1, tag2, tag3
  • tag1, tag2, ..., tag20

Invalid input configuration examples:

  • only tag1
  • tag2, tag3
  • tag1, tag3
  • at least one block other than tag is connected to the block

The block reacts only to rising edges. In the idle state, it waits for a rising edge on tag1. After detecting it, the block starts counting the time specified by the time_limit parameter and then waits for rising edges on tag2, tag3, and so on up to the last configured tag.

Operating rules:

  • A rising edge on tag1 always starts a new sequence and restarts the sequence timer.
  • Repeating the most recently accepted tag is ignored.
  • If a rising edge appears on a tag other than the expected next tag, the current sequence detection attempt is canceled.
  • If the full sequence is not detected within the time specified by time_limit, the block returns to the idle state.
  • After the full sequence is detected, the block becomes active for 1 second.
  • In the active state, a rising edge on tag1 interrupts the activation and immediately starts counting a new sequence.
  • In the active state, all rising edges on inputs other than tag1 are ignored.

The table below describes the meaning of the inputs:

Input number and name Description
tag1: First element of the sequence. A rising edge on the tag1 input starts a new sequence and starts counting the time specified by the time_limit parameter. If the block is currently in the active state, such an event interrupts the activation and immediately starts a new sequence.
tag2 ... tagN: Subsequent elements of the sequence. Rising edges on subsequent inputs must occur in the correct order. Repeating the most recently accepted tag is ignored. If a tag other than the expected next tag appears, the current sequence detection attempt is canceled.

Block outputs

The block has one logical output:

  • false in the idle state
  • true for 1 second after a full valid sequence has been detected

The description visible below the block reflects its current state:

  • false (waiting for tagX) means waiting for the next tag in the sequence
  • true (sequence active) means the active state after a full valid sequence has been detected

Errors returned by the block

The sequence-detector block can return the following errors:

Error code Error description
Invalid time_limit configuration. The time_limit parameter is invalid. Set a positive numeric value with a 0.1 second step, not greater than 64800 seconds.
Too many tagX connections. More than one tag block with the same number X has been connected to the block.
Missing required tag connections. Fewer than two consecutive tags starting from tag1 have been connected to the block.
Non-tag block connected. A block of a type other than tag has been connected to the block input.
Missing tagX connection. There is a gap in the tag numbering in the input configuration and the next expected tag X is missing.
Invalid project. An internal problem occurred while accessing the logic project during block initialization.

Examples

Assuming that tag1, tag2, and tag3 are connected to the block:

  • The sequence tag1, tag2, tag3 detected in less time than time_limit activates the output for 1 second.
  • The sequence tag1, tag3 does not activate the output because tag2 was skipped.
  • The sequence tag1, tag2, tag2, tag3 activates the output because repeating the most recently accepted tag is ignored.
  • The sequence tag1, tag2, tag1, tag3 does not activate the output because a new tag1 starts a new sequence and cancels the previous attempt.