Priority Encoder
medium
Encodes eight BOOL inputs into the index of the highest-priority active input.
What it teaches
When several fault or request lines are active together, report the highest-numbered one as a compact index from 0 to 7. Sts_Active distinguishes active In_0 from no request. Unlike Bit Pack, one winning input is reported instead of preserving every active bit.
Parameters
| Tag | Direction | Type | Default | Description |
|---|---|---|---|---|
| In_0 | Input | BOOL | 0 | — |
| In_1 | Input | BOOL | 0 | — |
| In_2 | Input | BOOL | 0 | — |
| In_3 | Input | BOOL | 0 | — |
| In_4 | Input | BOOL | 0 | — |
| In_5 | Input | BOOL | 0 | — |
| In_6 | Input | BOOL | 0 | — |
| In_7 | Input | BOOL | 0 | — |
| Out_Index | Output | DINT | 0 | Number of the highest active input |
| Sts_Active | Output | BOOL | 0 | 1 while at least one input is active |
Required behavior
- Out_Index is the number of the highest active input: with In_5 and In_2 both on, Out_Index is 5.
- Sts_Active is 1 while any input is on.
- With no input active, Out_Index is 0 and Sts_Active is 0 — Sts_Active is what tells In_0 apart from nothing.