Bit Toggle
medium
Flips the masked bits of a retained word on each rising edge of the toggle command.
What it teaches
Unlike Stateful Masked Move, this does not copy source values. Each command edge flips the selected destination bits to their opposites, while a one-shot ensures a held command acts only once. The everyday shape is one button toggling a chosen group of outputs at once — zone lights, annunciator lamp groups.
Inputs and outputs
| Tag | Type | Default | Description |
|---|---|---|---|
| In_Toggle | BOOL | — | Toggle command; the rising edge flips the masked bits |
| Cfg_Mask | DINT | 5 | 1 bits select which bits flip on each command |
| Out_Word | DINT | — | Retained word whose masked bits flip on each command |
Required behavior
- On each 0 to 1 transition of In_Toggle, every bit of Out_Word selected by a 1 bit in Cfg_Mask flips; bits under a 0 mask bit keep their value.
- Holding In_Toggle at 1 flips nothing further — only the rising edge acts.
- A command already high when the block first runs is not a transition: nothing flips until it drops and rises again.
- With the default mask 5 (101), each press flips bits 0 and 2.
- Toggling twice with the same mask returns Out_Word to its original value.