Overview of the S5 :AS Instruction
The Siemens SIMATIC S5 Anweisungsliste (AWL) statement :AS is a CPU-level control instruction that disables the process alarm (interrupt) path of the S5-135U and S5-155U operating system. The mnemonic AS is the German abbreviation for Alarme Sperren (disable alarms). Its direct counterpart is :AF (Alarme Freigeben, enable alarms). The instruction was originally defined for the S5-135U and S5-155U family where the IP (Interrupt-Processor) and IA (Interrupt-Acknowledge) signal modules in the central rack can raise a hardware process alarm to OB2. When the CPU has executed :AS, the alarm-enable bit is cleared and OB2 will not be entered on the next process alarm from the IP/IA module.
In an S5-95U, S5-100U, or S5-115U, the same token may appear but the underlying mechanism differs. S5-95U and S5-100U do not have the S5-135U/155U interrupt-module infrastructure; the :AS opcode, when present in the S5-95U instruction set, masks a different class of interrupts. S5-115U from CPU 941B / 942 / 943 / 944 upwards uses the S5-135U alarm model and :AS/:AF behave as described here.
:AS instruction has no textual equivalent in the S7 STL language. The S7 STL grammar uses ABS for absolute-value computation, and an AS substring can appear in the programming-device (PG) display layer that converts FBD or LAD into STL for printout, as described in the SIMATIC S7-300/400 Anweisungsliste (AWL) Programming Manual. The S5 CPU control instruction and the S7 PG display marker are unrelated. During a STEP 5 to S7-1500 migration, treat any bare :AS token as a CPU control instruction and replace it with SFC 39 "DIS_IRT".Reference Code from a STEP 5 Migration
The following S5 AWL segment was extracted from a real STEP 5 to S7-1500 migration. The code latches a start condition into M71.1, mirrors it to M80.0, and then calls FB31. The :AS line sits between the latch logic and the conditional block call, which is the standard S5 idiom for protecting a critical FB against process-alarm pre-emption.
NETWORK 1
:U E 32.7 // AND input 32.7 (start command)
:UN M 71.1 // AND NOT flag 71.1 (latch state)
:UN T 15 // AND NOT timer 15 (timeout)
:S M 71.1 // SET flag 71.1 (latch)
:= M 80.0 // assign result to M 80.0
NETWORK 2
:UN E 32.6 // AND NOT input 32.6 (stop)
:U M 80.0 // AND M 80.0
:= M 80.0 // result back to M 80.0 (self-hold)
NETWORK 3
:AS // DISABLE process alarm (Alarme Sperren)
:SPB FB 31 // conditional jump to FB31
The :AS opcode is one network by itself and consumes no operand. The next line, :SPB FB 31, is the conditional block call (Springe bedingt to FB31 if RLO = 1). The CPU enters FB31 with the alarm-enable bit cleared. Inside FB31, the user program can read/write IP/IA modules, manipulate timers, or perform sequential control without the risk of an OB2 pre-emption. The alarm-enable bit is set again only when the program reaches a corresponding :AF opcode, or when the CPU performs a cold restart.
S5 Process Alarm Architecture
To map :AS correctly, you must understand the S5-135U/155U interrupt model. The CPU services several event classes through dedicated organization blocks.
| Event class | Trigger source | OB number | Acknowledged by |
|---|---|---|---|
| Cyclic execution | CPU scan | OB1 | — |
| Process alarm | IP/IA module edge, INT signal | OB2 | OB2 body, :IRA opcode |
| Battery / power-down | Battery low, power loss | OB3 | System |
| Restart / stop | Mode switch, programmer command | OB4 / OB21 / OB22 | System |
| Time-of-day interrupt | Real-time clock | OB10 – OB13 (135U/155U only) | OB body |
| Time-delay interrupt (Weckalarm) | Timer 0 | OB6 (135U/155U CPU 928/948) | OB body |
| Module error / diagnostic | Signal module failure | OB19, OB20, OB34-OB38 | System / OB body |
The :AS / :AF pair controls the alarm-enable flag in the CPU system data area (SZD). When the bit is 0, OB2 is suppressed. When the bit is 1, OB2 is called on the next process alarm. The default after COLD RESTART is enabled. After WARM RESTART, the state from before the stop is preserved.
Operation: :AS versus :AF
| Instruction | Mnemonic meaning | English | Effect on OB2 | State after instruction |
|---|---|---|---|---|
:AS |
Alarme Sperren | Disable process alarm | OB2 not entered on next process alarm | Alarm-enable bit = 0 |
:AF |
Alarme Freigeben | Enable process alarm | OB2 entered on next process alarm | Alarm-enable bit = 1 |
:IRA |
Interrupt-Rücksetzen | Acknowledge processed alarm | Re-arms the IP/IA module so it can fire again | IP/IA module status cleared |
:IA |
Interrupt Annehmen | Take / accept interrupt | Equivalent to :AF in some CPU variants |
Alarm-enable bit = 1 |
The :IRA opcode is the matching acknowledge. It is typically placed at the end of OB2 to re-arm the IP/IA module. Without :IRA, the IP/IA module fires one interrupt and then holds its alarm line asserted until acknowledged, regardless of :AS/:AF state.
S5 CPU Family Compatibility
Not every S5 CPU implements the :AS / :AF pair.
| CPU family | :AS / :AF supported | OB2 supported | Notes |
|---|---|---|---|
| S5-90U | No | No | Limited AWL; no process-alarm OBs |
| S5-95U | Partial | Limited | Onboard I/O has its own interrupt model; verify against the S5-95U manual |
| S5-100U / 101U / 110U | No | No | No IP/IA modules in this family |
| S5-115U (CPU 941B / 942 / 943 / 944) | Yes | Yes | Uses the S5-135U alarm model |
| S5-135U (CPU 928 / 928B / 948) | Yes | Yes | Full IP/IA, IT, IA, IRA support |
| S5-155U (CPU 946 / 947) | Yes | Yes | Full support, multi-CPU configurations possible |
If the source listing contains :AS, the original CPU is almost certainly an S5-115U, S5-135U, or S5-155U. S5-95U programs occasionally carry the same mnemonic but the semantics differ; always cross-check the OB2 body and the signal-module list before migration.
Alarm Enable State Machine
The S5-135U/155U alarm-enable state machine is a 1-bit toggle with a counter for nested calls.
Two consecutive :AS calls require two :AF calls before OB2 is re-enabled. This counter behaviour also exists in the S7 SFC 39 / SFC 40 implementation; treat the SFC pair as balanced calls in your code review.
Interaction with Block Calls (FB / PB / SB)
The :AS opcode modifies a CPU-level flag, not a block-local variable. Its effect persists across block calls. The migration source code demonstrates the canonical pattern:
:AS
:SPB FB 31
Inside FB31, OB2 will not be entered on a process alarm. The IP/IA module holds the alarm asserted (single-shot queue depth) until either the user program executes :AF or the IP/IA module's alarm buffer overflows. In S5-135U/155U the IP/IA module typically queues one alarm; a second alarm arriving while :AS is active is lost unless the module is configured for interrupt accumulation via the COM 135U parameterisation tool.
This persistence is a common bug source. If the developer forgets to execute :AF on every code path, the system stays alarm-disabled. Code-review checklist for S5 programs that contain :AS:
- List every
:ASin the program (cross-reference). - Verify a matching
:AFexists on every code path that does not end inBEorBEA. - Verify the matching
:AFis reachable when:ASis taken (consider conditional jumps). - Verify FB31 and any other block called under
:ASdo not assume OB2 is running.
Migration to S7-1500
The S7-1500 (and S7-300/400) CPUs do not have a textual :AS instruction. The S7 replacement uses System Function Calls (SFCs) from the standard library.
| S5 opcode | S7-300/400 SFC | S7-1500 SFC | Function |
|---|---|---|---|
:AS |
SFC 39 "DIS_IRT" | SFC 39 "DIS_IRT" | Disable interrupt OBs (OB40-OB47, OB82, etc.) |
:AF |
SFC 40 "EN_IRT" | SFC 40 "EN_IRT" | Enable interrupt OBs |
| (no direct S5 equivalent) | SFC 41 "DIS_AIRT" | SFC 41 "DIS_AIRT" | Delay interrupt handling; nested counter |
| (no direct S5 equivalent) | SFC 42 "EN_AIRT" | SFC 42 "EN_AIRT" | Enable delayed interrupt handling |
The standard replacement for the S5 :AS opcode is a call to SFC 39 "DIS_IRT" with MODE = 0 (disable all interrupt OBs). For the S5 :AF opcode, call SFC 40 "EN_IRT" with MODE = 0 (enable all). If only one interrupt class must be disabled, MODE = 1 with OB = 40 disables only OB40.
S7-1500 STL / SCL Replacement Code
The S7-1500 replacement for the S5 source segment is shown below in STL and in SCL. In TIA Portal the call sites are inserted as standard FBs from the "Standard library → System function blocks" folder.
// S7-1500 SCL replacement for the S5 source segment
// Network 1: start-latch logic
IF "E32_7" AND NOT "M71_1" AND NOT "Timer15".Q THEN
"M71_1" := TRUE;
"M80_0" := TRUE;
END_IF;
// Network 2: stop-self-hold
IF NOT "E32_6" AND "M80_0" THEN
"M80_0" := TRUE;
END_IF;
// Network 3: replace :AS with SFC 39
"DIS_IRT_DB"(MODE := 0, OB := 0); // SFC 39 disable all
// Network 4: replace :SPB FB 31 with conditional call
IF "M80_0" THEN
"FB31_DB"(Start := TRUE);
END_IF;
// Network 5: replace :AF with SFC 40
"EN_IRT_DB"(MODE := 0, OB := 0); // SFC 40 enable all
STL version (kept close to the S5 source):
// S7-1500 STL replacement for the S5 source segment
U "E32_7"
UN "M71_1"
UN "Timer15".Q
S "M71_1"
= "M80_0"
UN "E32_6"
U "M80_0"
= "M80_0"
CALL "DIS_IRT" // SFC 39
MODE := 0
OB := 0
A "M80_0"
SPB FB31
CALL "EN_IRT" // SFC 40
MODE := 0
OB := 0
The SFC instance DBs are created automatically by TIA Portal on first compile. Verify the instance DBs are present in the project tree under "Program blocks → System blocks".
S5 versus S7-1500 Alarm Architecture
The structural differences between the S5 and S7-1500 alarm models are summarised in the table below.
| Aspect | S5-135U/155U | S7-1500 |
|---|---|---|
| Process alarm OB | OB2 | OB40 – OB47 (per hardware interrupt) |
| Diagnostic interrupt OB | OB19 / OB20 / OB34-OB38 | OB82 |
| Time-of-day interrupt | OB10 – OB13 | OB10 – OB17 |
| Time-delay interrupt | OB6 | OB20 – OB23 |
| Disable instruction | :AS |
SFC 39 "DIS_IRT" |
| Enable instruction | :AF |
SFC 40 "EN_IRT" |
| Per-OB disable | No (one bit, all process alarms) | Yes (MODE = 1, OB number) |
| Nested counter | Yes | Yes (SFC 39/40 + SFC 41/42) |
| State on warm restart | Preserved | Reset (interrupt enable re-armed on STOP→RUN) |
| Acknowledge |
:IRA in OB2 |
OB returns automatically; SFC 6 "RD_SINFO" to read OB start info |
Note the difference in the warm-restart behaviour. In S5 the alarm-enable state is preserved across a warm restart, so an S5 program that left :AS active at STOP will resume with alarms disabled. In S7, SFC 39 is re-armed on STOP→RUN. Migrated code that depends on persistent alarm disable must call SFC 39 in OB100 (warm restart) as well.
TIA Portal Implementation Procedure
- Open the migrated S7-1500 project in TIA Portal.
- Add the SFC 39 call site. From "Instructions → System function blocks" drag "DIS_IRT" into the FB that contains the equivalent of the S5
:AS. - Set MODE = 0 (disable all) or MODE = 1 with the target OB number.
- Compile the project. TIA Portal creates the instance DBs for SFC 39 and SFC 40.
- Download to the S7-1500 CPU.
- Go online and open the watch table for the alarm-disable flag. Force the disable call and verify OB40 is not entered on a forced hardware interrupt.
- Force the enable call and verify OB40 is entered on the next hardware interrupt.
The S7-1500 hardware-interrupt source is configured in the device configuration: select the DI module → Properties → "Hardware interrupt" → assign a process tag to OB40. Common S7-1500 / ET 200SP signal modules that raise OB40 include the ET 200SP digital-input modules (e.g. 6ES7131-6BF00-0BA0, 8DI 24V DC) and the S7-1500 central DI modules (e.g. 6ES7521-1BH00-0AB0, DI 16x24V DC).
Edge Cases and Field Notes
-
Nested disable: two
:AScalls require two:AFcalls. The same counter rule applies to SFC 39 / SFC 40. Code review must count pairs. -
Cold-restart state: in S5,
:ASstate is reset on COLD RESTART (OB20) but PRESERVED on WARM RESTART (OB21). In S7, SFC 39 state is reset on every STOP→RUN transition. -
OB82 diagnostic alarm: S5
:ASsuppresses only OB2 (process alarm). S7 SFC 39 with MODE = 0 suppresses OB82 as well. If the S5 program relied on OB19-OB22 to fire even when process alarms were disabled, S7 must use MODE = 1 with OB = 40 to disable only OB40. -
Time-of-day interrupt: S5
:ASdoes NOT affect OB10-OB13. S7 SFC 39 with MODE = 0 affects OB10-OB17 in some S7-1500 firmware versions. Confirm with the target CPU's system manual. - OB priority: in S5, OB2 has a fixed priority. In S7-1500, OB40-OB47 each have a configurable priority. The priority of OB40 must be set higher than the calling block's priority, otherwise OB40 will not pre-empt the block that called SFC 39.
- Calling SFC 39 from OB1: if SFC 39 is called unconditionally in OB1 and SFC 40 is missing, the entire program will run alarm-suppressed. Migrated code that does this in a control loop will never service OB40. Review all SFC 39 call sites for matching SFC 40.
- Calling SFC 39 from OB100: acceptable for setting initial alarm state, but the matching SFC 40 must be reachable from the same restart class.
Safety Considerations
:AS instruction suppresses a safety-relevant alarm class (process alarm). An S5 program that disables process alarms must not depend on OB2 for safety functions. Migrated S7-1500 code that replaces :AS with SFC 39 must be reviewed for the same property. S7-1500 safety-related alarms (PROFIsafe, F-CPU) use a different OB family (OB82, OB121, OB122) and are NOT suppressed by SFC 39; verify the safety matrix separately.If the original S5 program is part of a safety chain (e.g. a burner control or a chemical-reaction sequence), the migration must preserve the equivalence between :AS suppression and S7-1500 SFC 39 suppression. Add a code-review entry: "Verify SFC 39 / SFC 40 do not break PROFIsafe / F-CPU alarm path".
Troubleshooting Matrix
| Symptom | Likely cause | Verification step | Fix |
|---|---|---|---|
| OB2 never called on S5-135U/155U | Stray :AS not matched by :AF
|
Cross-reference :AS in the program; look for missing :AF before BE / BEA |
Insert :AF on the missing path |
| OB40 never called on S7-1500 after migration | SFC 39 called without matching SFC 40 | Cross-reference SFC 39 / SFC 40 in the project | Insert SFC 40 call |
| OB2 fires during FB31 (interrupts FB31) | Missing :AS in S5 source |
Check the network sequence; look for SPB FB 31 preceded by a control instruction |
Insert :AS before SPB FB 31
|
| Process alarm lost (not queued, not serviced) | IP/IA module configured for single-shot | Check DIP switches / COM 135U configuration | Reconfigure for accumulation, or re-arm via :IRA in OB2 |
| S7-1500 goes STOP with SF after migration | SFC 39 called in OB1 / OB100, blocking OB82 indefinitely | Check OB82 priority and SFC 39 call site | Move SFC 39 to a sequence-controlled FB; do not call from OB100 unconditionally |
Migration tool flags :AS as unknown instruction |
Migration tool does not have a S5-135U rule for :AS
|
Open the migration report; check the Unmapped instructions section | Manually insert SFC 39 / SFC 40 calls; mark :AS as remove and replace |
| Hardware interrupt fires but OB40 priority is too low | OB40 priority set below calling block's priority in TIA Portal | Open OB40 properties → Priority; compare with calling FB priority | Raise OB40 priority above the calling block's priority |
| OB2 entered inside a CALL that is supposed to suppress | Nested :AS / :AF mismatch |
Count :AS and :AF in the called block |
Insert missing :AF
|
Verification Procedure After Migration
- Open the S7-1500 project in TIA Portal.
- Mark the location where
:ASwas in the S5 source. Confirm SFC 39 is present with MODE = 0 (or MODE = 1 with the specific OB). - Mark the location where
:AFwas. Confirm SFC 40 is present with the same MODE / OB setting. - Go online with the S7-1500 CPU.
- Force a hardware interrupt on a digital-input module that is mapped to OB40.
- Confirm OB40 is NOT entered while the SFC 39 call site is enabled (online → watch table → DIS_IRT_DB.OK = TRUE).
- Confirm OB40 IS entered after the SFC 40 call site is reached (online → watch table → EN_IRT_DB.OK = TRUE).
- Remove a module to trigger a diagnostic alarm. Confirm OB82 is suppressed (if MODE = 0) or fired (if MODE = 1 with OB = 40).
- Check the diagnostic buffer of the S7-1500 CPU for any SFC 39 / SFC 40 event entries.
- Document the test in the migration report; attach the watch-table screenshot.
Cross-Reference Strategy for S5 to S7-1500 Conversion Tools
The STEP 5 to S7-1500 migration path is not natively supported by TIA Portal. The common route uses the S5 converter in STEP 7 (Classic) to produce an S7-300/400 STL project, then a TIA Portal migration to S7-1500 STL/SCL. The :AS / :AF opcodes are flagged as unmappable by every mainstream converter because they are CPU-control instructions, not logic operations. The post-migration manual step is:
- Open the S7-300/400 project after the STEP 5 import.
- Search for the literal token "AS" in the AWL source.
- For each occurrence, replace with an SFC 39 call block (call to FB0 / FC0 wrapper that calls SFC 39 with the right MODE).
- For each "AF" occurrence, replace with an SFC 40 call block.
- Compile the S7-300/400 project; resolve any type errors in the wrapper blocks.
- Migrate the S7-300/400 project to S7-1500 in TIA Portal.
- Verify the wrapper blocks are still present in the S7-1500 project (TIA Portal may move or rename them).
An alternative is to use the Siemens SIMATIC Migration Tool add-on for TIA Portal, which maps a wider set of S5 opcodes; check the tool's manual for the current :AS coverage.
Frequently Asked Questions
What does the S5 AWL instruction :AS do?
The :AS instruction (Alarme Sperren) disables process alarm handling in the S5-135U and S5-155U CPUs. While the alarm-enable flag is cleared, OB2 is not entered on a process alarm from the IP/IA modules. The matching :AF instruction (Alarme Freigeben) re-enables the alarm path. The S5 :IRA opcode acknowledges the alarm and re-arms the IP/IA module.
Is :AS the same as the S7 STL AS token?
No. The S5 :AS is a CPU control instruction. In S7 STL, the AS substring may appear as part of ABS (absolute value) or in the programming-device (PG) display layer that converts FBD or LAD to STL for printout, as documented in the SIMATIC S7-300/400 AWL Programming Manual. The S5 CPU control instruction and the S7 PG display marker are unrelated. For S7-1500 migration, replace S5 :AS with SFC 39 "DIS_IRT".
How do I disable only one interrupt OB in S7-1500?
Call SFC 39 "DIS_IRT" with MODE = 1 and OB = 40 (or whichever OB). The S7-1500 SFC 39 supports per-OB disable and per-OB enable. To re-enable, call SFC 40 "EN_IRT" with MODE = 1 and the same OB number. The SFC 41 / SFC 42 pair adds a delayed-disable model with a counter.
Does :AS affect OB82 diagnostic interrupts in S5?
In S5-135U/155U, :AS affects only the OB2 process alarm path. Diagnostic events are handled by OB19-OB22 and are not suppressed by :AS. In S7-1500, SFC 39 with MODE = 0 suppresses OB82 as well; use MODE = 1 to disable only specific OBs. Check the device configuration for the per-OB event mask if a graphical alternative is preferred.
What happens if I call :AS twice and :AF once in S5?
The S5-135U/155U uses a counter for the alarm-enable state. Two :AS calls require two :AF calls to fully re-enable. The same counter model applies to S7 SFC 39 / SFC 40. If process alarms never fire on the S7-1500 after migration, count the SFC 39 / SFC 40 pairs and verify balance.