← All exercises

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

TagDirectionTypeDefaultDescription
In_0InputBOOL0—
In_1InputBOOL0—
In_2InputBOOL0—
In_3InputBOOL0—
In_4InputBOOL0—
In_5InputBOOL0—
In_6InputBOOL0—
In_7InputBOOL0—
Out_IndexOutputDINT0Number of the highest active input
Sts_ActiveOutputBOOL01 while at least one input is active

Required behavior