Skip to main content

RESETBIT

Resets a specific bit in a data field.

Ladder Representation

RESETBIT Ladder block representation

Block Structure

Variable TypeNameData TypeDescription
VAR_IN_OUTDataBYTE USINT SINT WORD UINT INT DWORD UDINT DINTVariable whose bit is changed.
VAR_INPUTENBOOLBlock enable.
VAR_INPUTPositionBYTE USINTPosition of the bit to be changed.
VAR_OUTPUTDoneBOOLOperation success.

Operation

When EN is TRUE, the block resets the bit indicated by Position in Data and returns Data with the updated value.

When EN is FALSE, Data remains unchanged.

DONE receives the EN value, except when a bit reset error occurs. In that case, DONE receives FALSE.

Position Range

Make sure Position is within the valid bit range for the Data type. For example, BYTE has 8 bits, so Position must be between 0 and 7.

Execution Flowchart

RESETBIT execution flowchart

Examples

RESETBIT Ladder example 1

Example 1 resets bit position 0 of AUX, whose initial value is 200, or 1100 1000 in binary. Because this bit is already FALSE, the value is not changed.

RESETBIT Ladder example 2

Example 2 resets bit position 3 of AUX, changing its binary value and decimal representation.

RESETBIT Ladder example 3

Example 3 resets bit position 9 of AUX. Because AUX is a BYTE variable with only 8 bits, the block generates an execution error and the output is not enabled.