PLCcheck

S5 AWL Command: S (Set)

S5 AWL instruction S (Set): Sets a bit to TRUE when VKE is TRUE. The bit stays TRUE until explicitly reset with R.

·2 min read
S5AWLSSetSetzenlatchflip-flopbit logic

Diesen Artikel auf Deutsch lesen

S5 AWL Command: S (Set)

The S instruction sets a boolean operand to TRUE when the VKE is TRUE. Unlike the = (assign) instruction, S is a latching operation — the bit stays TRUE even when the VKE becomes FALSE. It can only be turned off with the R (Reset) instruction.

Syntax

S  <operand>

S7 Equivalent

S5 AWLS7 STLS7 SCL
S A 4.0S Q 4.0 (EN) / S A 4.0 (DE)Set via SR/RS flip-flop or IF condition THEN output := TRUE; END_IF;

Code Example — Set/Reset Pair

U  E 0.0       // Start button (momentary)
S  A 4.0       // Set motor ON → stays ON

U  E 0.1       // Stop button (momentary)
R  A 4.0       // Reset motor OFF

Behavior: Pressing Start sets the motor. It stays on. Pressing Stop resets it. This is the classic Set/Reset (SR) flip-flop pattern.

Priority rule: If both S and R are TRUE in the same cycle, the last operation wins. In the example above, R comes after S, so Reset has priority. Swap the order to give Set priority.

Common Errors

Using S without a matching R: The bit stays TRUE forever. Always ensure every S has a corresponding R somewhere in the program.


Part of the S5 AWL Command Reference. Maintained by PLCcheck.ai.


Analyze Your S5 Code Automatically

PLCcheck Pro reads your complete S5 AWL program and explains every instruction — including this one — in plain language. Upload your code and get instant documentation, S7 equivalents, and migration guidance.

Upload S5 code for free analysis → | S5→S7 Migration Guide →

Related Articles

Analyze your PLC code with AI

PLCcheck Pro explains, documents, optimizes, and migrates PLC code — automatically.

Try PLCcheck Pro →
← Back to Blog

Not affiliated with Siemens AG. S5, S7, STEP 5, STEP 7, and TIA Portal are trademarks of Siemens AG.