Resolving S7-GRAPH S_NO Not Matching Active Step Number in TIA Portal
The S_NO output of an S7-GRAPH function block is the most commonly used tag for tracking the active step in a sequencer. Engineers routinely connect S_NO to external HMI displays, condition-handling logic, interlock routines, and downstream equipment. When S_NO no longer matches the step that the operator sees in the GRAPH editor or in the watch table, the entire process visualization breaks. The typical symptom is that toggling the mode switch from Automatic to Manual and back to Automatic leaves S_NO stuck on a step that is no longer active, and only a CPU restart or program reset returns the sequencer to a coherent state.
This article consolidates the Siemens support information, the GRAPH FB interface specification, and field diagnostics into a single troubleshooting reference. It explains why the S_NO appears to drift, how to determine which of the three documented causes is responsible, and how to correct the display without resetting the working memory.
1. Problem Description and Observed Symptoms
Engineers running S7-GRAPH in TIA Portal V16, V17, V18, V19, or V20 on S7-300, S7-400, or S7-1500 CPUs report the following behaviour pattern:
- The GRAPH function block runs in Automatic mode (mode switch
SW_AUTOactive). - The
S_NOoutput reports a step number that does not correspond to the step highlighted in the GRAPH online view. - The output parameter
S_MOREisTRUE, indicating that the FB has more than one active step internally. - The output parameter
S_ACTIVEisFALSE, meaning the step currently shown inS_NOis not flagged as the canonical "active" step of the sequencer. - When the operator toggles the mode from Automatic to Manual and back to Automatic in the GRAPH Testing > Sequence Control > Mode panel, the
S_NOremains stuck on the wrong value. - A CPU restart, a PG online re-download of the FB, or a memory reset of the instance DB restores correct behaviour, but this is unacceptable in a running plant.
The issue is reproducible only under specific conditions, and the symptoms look identical to a programming bug, which makes the root cause elusive without consulting the GRAPH interface specification.
2. Root Cause Analysis
Siemens documents three independent mechanisms that cause S_NO to display a step number that does not match the visual "active step" the engineer expects:
2.1 Multiple Active Steps Inside the FB
According to the official Siemens Knowledge Base article Step number display in S7-Graph (ID 10103460), the S_NO parameter always reports the currently active step regardless of which sequence it belongs to. When the GRAPH function block contains more than one sequence, or when the block contains a simultaneous (parallel) branch, the FB can have multiple active steps at the same time. S_NO then displays only one of them; which one is displayed depends on the internal sorting order. This is the most common root cause and the one that produces the S_MORE = TRUE signal in the status display.
2.2 Manual Mode Selection of a Non-Active Step
The S_NO output can be commanded to a different step number when the FB is in Manual or Step mode. The user uses the input parameter S_SEL (INT) to select a step number, then pulses S_ON or S_OFF to enable or disable it. Per the official Input parameters (S7-300, S7-400, S7-1500) reference, S_SEL is specifically the STEP_SELECT input for the S_NO output parameter in manual mode. If S_SEL is wired to a non-zero value when the FB returns to Automatic mode, the FB may continue to display that commanded step number rather than the step that is actually executing.
2.3 Display Mode Configuration of the FB
The GRAPH FB exposes three static parameters in the instance DB that govern what S_NO shows:
| Static Parameter | Type | Function |
|---|---|---|
MOP.SACT_DISP |
BOOL | Display only the active step in S_NO. When TRUE, the FB filters out inactive steps and the rightmost active step is always shown. |
MOP.SEF_DISP |
BOOL | Display only the active step whose transition has fired. Used in combination with SACT_DISP to produce a stable step display in Automatic mode. |
MOP.SALL_DISP |
BOOL | Display all active steps cyclically. The FB rotates through every active step on each call; useful in test mode but the cause of the apparent drift in production. |
If SALL_DISP is inadvertently set to TRUE, the value of S_NO cycles through the active steps on every OB1 scan. An engineer observing the tag in the watch table sees a "stuck on the wrong step" symptom; in fact the FB is rotating through multiple legitimate active steps.
3. Diagnostic Procedure
Before applying any fix, isolate which of the three causes is in effect. The watch table below is the minimum set of tags to monitor online.
- Open the GRAPH instance DB in Monitor / Modify and force the visibility of all instance tags.
- Add the following tags to a watch table:
-
iDB.S_NO— the step number output. -
iDB.S_MORE— BOOL, more than one step is active. -
iDB.S_ACTIVE— BOOL, the step displayed inS_NOis flagged active. iDB.MOP.SACT_DISPiDB.MOP.SEF_DISPiDB.MOP.SALL_DISP-
iDB.S_SEL— INT, manual step selection input. -
iDB.S_SELOK— BOOL, manual selection acknowledged.
-
- Toggle the GRAPH FB to Manual, then back to Automatic, and observe which of the three values flips:
- If
S_MOREgoesTRUEat the moment of mismatch, the cause is Section 2.1 (multiple active steps or parallel branch). - If
S_SELis non-zero at the moment of mismatch, the cause is Section 2.2 (manual selection left active). - If
S_NOcycles between several values on every PLC scan, the cause is Section 2.3 (display mode).
- If
- Cross-check against the GRAPH online view. The rightmost step in any simultaneous branch is the one GRAPH displays first; use
S_PREVandS_NEXToutput toggles in the instance DB to step through all active steps.
4. Static Parameter Configuration
The static parameters in the MOP (Mode Of Operation) structure are the canonical lever for correcting the step display. They are read once at FB initialization and at the transition between Automatic and Manual mode. The following matrix maps the symptom to the required parameter state.
| Symptom | SACT_DISP | SEF_DISP | SALL_DISP | Effect |
|---|---|---|---|---|
| Stable single-step display in Automatic mode | TRUE | FALSE | FALSE | Only the canonical active step is shown; matches the GRAPH editor highlight. |
| Display the step whose transition has just fired | FALSE | TRUE | FALSE | Step that just transitioned is shown; useful for HMI animated transitions. |
| Rotate through all active steps (test mode) | FALSE | FALSE | TRUE |
S_NO cycles through every active step; do not use in production. |
| Show only the rightmost active step in a parallel branch | TRUE | FALSE | FALSE | Standard production setting; if S_MORE still TRUE, see Section 5. |
To set the static parameters in TIA Portal:
- Right-click the GRAPH instance DB in the project tree and select Open in editor.
- Navigate to the
MOPstructure. By default TIA Portal hides the structure; enable Show all tags in the toolbar. - Expand
MOP>SACT_DISP,SEF_DISP,SALL_DISP. - Set the values according to the matrix above. Initial values defined in the DB take effect on the next OB1 scan; values modified online via the watch table take effect immediately.
- Compile and download the project. A consistent download is acceptable; a full memory reset is not required.
5. Parallel Branches and Multiple Sequences
If the diagnostic procedure identifies S_MORE = TRUE but the program source visibly has no simultaneous branch, the FB likely contains more than one sequence. Each sequence is a separate sequencer state machine sharing the same FB and the same S_NO output. The Siemens Knowledge Base ID 10103460 states that when several steps are active across multiple sequences, the S_NO output cycles through them and the calling program must filter by the sequence index. The S_PREV and S_NEXT outputs (BOOL) are the standard Siemens mechanism to step through the active steps one at a time.
Sample STL code that walks every active step in a multi-sequence GRAPH FB:
// Determine the count of active steps and step through them
// iDB = instance DB of the GRAPH FB
// FirstStep = BOOL output, TRUE for one cycle when the first active step is at S_NO
// LastStep = BOOL output, TRUE for one cycle when the last active step is at S_NO
A iDB.S_MORE // More than one step is active
JC MULTI // Jump to multi-step handler
L iDB.S_NO // Single step active, S_NO is the answer
T #ActiveStep
JU DONE
MULTI: SET
A iDB.S_NEXT // Pulse S_NEXT to advance to the next active step
JC ADVANCE
L iDB.S_NO // First active step is already in S_NO
T #ActiveStep
JU DONE
ADVANCE: L iDB.S_NO
T #ActiveStep
DONE: NOP 0
If the calling program needs the step from a specific sequence, the standard pattern is to compare S_NO against the expected range and gate downstream logic. For example, if Sequence 1 owns steps 1 through 20 and Sequence 2 owns steps 21 through 40, the calling logic checks S_NO > 20 to identify the sequence.
6. Manual Mode and S_SEL Handling
The S_SEL input parameter is the engineering tool for selecting a step in Manual mode. It is the root of the second mismatch scenario. The official Siemens documentation specifies that S_SEL is an INT (the step number to select), that S_ON and S_OFF are the BOOLEAN commands that enable or disable the step chosen by S_SEL, and that S_SELOK (BOOL) is the acknowledgement output. The common mistake is to wire S_SEL from a non-volatile tag (for example, an HMI tag that retains its last value across power cycles). When the FB returns to Automatic mode, the last commanded step number from S_SEL is still in the input buffer and the FB continues to display it.
Recommended engineering practice:
- Initialize
S_SELto0(no selection) on every transition from Manual to Automatic. Use theSW_AUTOmode bit as the gating condition. - Verify
S_SELOK = FALSEafter the transition. A TRUE value indicates a selection is still pending. - Do not bind
S_SELto retain tags. Use a temporary tag that is reset in the FB's own OB1 call.
Sample STL for a safe Automatic / Manual handover:
// On the rising edge of SW_AUTO, clear S_SEL and force S_OFF
A M 0.0 // SW_AUTO rising edge (one-shot)
JC CLEAR_SEL
L 0
T iDB.S_SEL
CLR // Pulse S_OFF to release the manual selection
S iDB.S_OFF
CLEAR_SEL: SET
A iDB.S_SELOK // Wait for acknowledgement
R iDB.S_OFF // Release the manual step
NOP 0
7. Avoiding the Memory Reset Workaround
The source observation is correct: a memory reset is not required, and it is destructive. The correct non-destructive sequence to recover the sequencer state is:
- Stop the CPU via the PG (online > stop).
- Open the GRAPH instance DB. Correct the offending static parameter (Section 4) or the
S_SELinput (Section 6). - Download the modified DB to the CPU as a consistent download in RUN mode (TIA Portal will prompt). The retentive bits of the instance DB are preserved.
- Bring the CPU back to RUN. Verify
S_NOmatches the active step in the GRAPH online view.
If the CPU is in STOP because the sequencer entered an unrecoverable state, perform a restart rather than a memory reset. The S7-1500 CPU's restart initialization clears the working memory but preserves the retentive tags you have configured. The S7-300/400 restart is equivalent to an S7-1500 restart for the purposes of recovering a GRAPH FB.
8. Verification Procedure
After applying the fix, the following acceptance test must pass before the program is released to production:
- Place the GRAPH FB in Automatic mode and run the sequencer through every transition at least once.
- Monitor
S_NOin a watch table and confirm it tracks the highlighted step in the GRAPH online view at every cycle. - Toggle the FB to Manual, select a step that is not the current active step with
S_SEL, then toggle back to Automatic. VerifyS_NOreturns to the actual active step and thatS_SELis cleared. - Confirm
S_MORE = FALSEfor the entire run. If it ever flips toTRUE, a parallel branch or multi-sequence scenario is still present and Section 5 must be revisited. - Confirm
S_ACTIVE = TRUEfor the entire run. This is the canonical confirmation that the FB agrees the step displayed inS_NOis the active one. - Save the GRAPH online trace and the watch table screenshot to the project change-log.
9. Troubleshooting Matrix
| Symptom | First Tag to Check | Root Cause | Remediation |
|---|---|---|---|
S_NO shows wrong step after Auto/Manual toggle |
S_SEL |
Manual selection left active | Reset S_SEL = 0 and pulse S_OFF on the Auto rising edge |
S_NO cycles through multiple values |
MOP.SALL_DISP |
Display mode = rotate all active steps | Set SALL_DISP = FALSE and SACT_DISP = TRUE
|
S_MORE = TRUE but no parallel branch in source |
Number of sequences in the FB | Multi-sequence FB; S_NO is sequence-independent |
Filter by sequence index in the caller; use S_PREV/S_NEXT to walk |
S_NO correct, S_ACTIVE = FALSE
|
MOP.SEF_DISP |
Step-just-fired display is active | Set SEF_DISP = FALSE and SACT_DISP = TRUE
|
| GRAPH FB does not react to mode toggle |
OFFLINE/ONLINE view |
Static parameter not downloaded | Consistent download of the instance DB |
S_NO always zero |
Instance DB linkage | Caller passes the wrong DB number | Verify the FB instance parameter and re-link |
| CPU goes to STOP with GRAPH OB121 diagnostic | Step number overflow | Program jumped to a step number that does not exist | Validate the S_SEL value range against the maximum step number |
10. Compatibility Notes Across S7-300, S7-400, and S7-1500
The interface described in this article is stable across the documented platforms:
-
S7-300 / S7-400: S7-GRAPH runs as a separate option package on STEP 7 V5.x and on TIA Portal up to V20. The
MOPstructure,S_NO,S_MORE,S_ACTIVE,S_PREV,S_NEXT, andS_SELare present in every GRAPH FB from version 5.3 onward. -
S7-1500: S7-GRAPH is part of the standard TIA Portal installation. The interface is the same, but the display parameters are also exposed through the GRAPH FB's Properties dialog under Settings > Display. Configuration there is equivalent to writing to the
MOPstructure manually. - Firmware sensitivity: The display logic has been stable across S7-1500 CPU firmware V2.5 through V3.1. The Siemens Knowledge Base article ID 10103460 documents the S_NO display behaviour and applies to all listed firmware versions.
11. Field-Commissioning Checklist
Before sign-off, verify the following items on the live CPU:
- The GRAPH instance DB is in the program and matches the FB type in the project.
-
MOP.SACT_DISP = TRUE,MOP.SEF_DISP = FALSE,MOP.SALL_DISP = FALSEunless the application explicitly needs the alternate behaviour. - The HMI is bound to
S_NOthrough a non-retain tag; the S_NO value is not stored across cold restarts. - No ladder / STL / SCL code forces
S_SELto a non-zero value whenSW_AUTOis active. - The sequencer is exercised through every transition at commissioning, and a watch-table screenshot of
S_NOmatching the GRAPH online view is archived. - The operator console's Testing > Sequence Control > Mode function is restricted to authorized personnel to prevent accidental Manual/Auto toggles that could expose the mismatch condition.
S_NO mismatch described in this article is a display and control problem, not a safety-rated function. Do not use S_NO as the sole source for safety interlocks. Always cross-check the actuator feedback in the F-I/O slice.12. Frequently Asked Questions
Why does S_NO show a step number that is not highlighted in the GRAPH online view?
S_NO always reports the currently active step regardless of which sequence owns it, so the value cycles if the GRAPH FB contains a simultaneous branch or more than one sequence. The S_MORE output will be TRUE, signalling that multiple steps are active. The Siemens Knowledge Base article ID 10103460 documents this behaviour and the S_PREV/S_NEXT mechanism for walking the active steps.
What is the difference between S_ACTIVE, S_MORE, and S_NO in S7-GRAPH?
S_NO is the integer step number the FB reports, S_MORE is a BOOL that is TRUE when more than one step is active internally, and S_ACTIVE is a BOOL that is TRUE when the step currently shown in S_NO is the canonical active step. If S_ACTIVE is FALSE but S_MORE is TRUE, the FB is showing a non-primary active step, typically the rightmost in a parallel branch.
How do MOP.SACT_DISP, MOP.SEF_DISP, and MOP.SALL_DISP affect the S_NO display?
SACT_DISP=TRUE filters S_NO to the single canonical active step. SEF_DISP=TRUE shows the step whose transition has just fired. SALL_DISP=TRUE causes S_NO to cycle through all active steps on every scan. For stable production display, set SACT_DISP=TRUE, SEF_DISP=FALSE, SALL_DISP=FALSE.
How is S_SEL used to select a step in Manual mode?
S_SEL is an INT input that names the step number to act on. S_ON enables that step and S_OFF disables it. S_SELOK (BOOL) is the acknowledgement that the FB has accepted the selection. To avoid leftover selections corrupting the Automatic mode display, reset S_SEL to 0 and pulse S_OFF on the rising edge of SW_AUTO.
Can I fix the S_NO mismatch without a memory reset of the CPU?
Yes. Modify the MOP static parameters in the GRAPH instance DB and download the DB to the CPU as a consistent download in RUN mode. The retentive bits of the DB are preserved, and the FB picks up the new display parameters on the next scan. A memory reset is destructive and is not required for this fix.