PLCcheck

S5 AWL Command: SPB (Conditional Jump)

S5 AWL instruction SPB: Jump to label if VKE is TRUE. The primary conditional branching instruction — equivalent to IF in high-level languages.

·4 min read
S5AWLSPBconditionaljumpIFbranch

Diesen Artikel auf Deutsch lesen

S5 AWL Command: SPB (Conditional Jump if TRUE)

SPB jumps to a label only if the VKE is TRUE. If VKE is FALSE, execution continues with the next instruction. SPB is the primary conditional branching mechanism in AWL — it implements IF/THEN logic.

Syntax

U   E 0.0          // Condition
SPB =M001          // Jump to M001 if E 0.0 is TRUE

S7 Equivalent

S5 AWLS7 STLS7 SCL
SPB =M001JC M001 (EN) / SPB M001 (DE)IF condition THEN ...

Code Example — IF/THEN

U   E 0.0          // IF E 0.0
SPB =M001          // THEN jump to M001
SPA =M002          // ELSE jump to M002 (skip THEN block)

M001: L KF +100    // THEN: load 100
T   MW 20
SPA =M099          // Jump to end

M002: L KF +0      // ELSE: load 0
T   MW 20

M099: NOP 0        // Continue

SCL equivalent: IF E0_0 THEN MW20 := 100; ELSE MW20 := 0; END_IF;

VKE After SPB

Common Patterns

PatternAWLSCL Equivalent
IF/THENSPB =MxxxIF cond THEN ... END_IF
IF/THEN/ELSESPB =Mthen / SPA =MelseIF cond THEN ... ELSE ... END_IF
CASE (multi-branch)Multiple L/==F/SPBCASE var OF ... END_CASE

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.