Troubleshooting S7-400 CPU Program Loss After Power Failure

David Krause14 min read
S7-400SiemensTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

1. Problem Overview

An S7-400 CPU (typical example 6ES7412-2XK05-0AB0 / S7-412-2 DP, but the same symptoms apply to S7-414, S7-416, S7-417, and the H/F variants) returns from a mains event with the user program gone, the hardware configuration missing, or both. The fault is intermittent, frequently observed after thunderstorm activity, and persists even when a three-phase 6 kVA UPS is in the line. The most common misdiagnosis is flash memory corruption; in the field, the actual root cause is almost always a depleted, missing, or reversed backup battery on the PS 405 / PS 407 power supply module combined with a UPS topology that does not mask short-duration sags.

Critical safety implication: S7-400 work memory is volatile CMOS RAM. The single 3.6 V lithium cell in the PS 405 / PS 407 is the only thing keeping the loaded project and the retentive data alive during an outage. A dead battery, a disconnected battery cable, or a battery inserted with reversed polarity is sufficient to wipe the project on the next mains dip. Replace the battery before assuming the CPU is faulty.

2. S7-400 Memory Architecture and Backup Concept

Understanding where the program physically lives is mandatory before you can interpret the symptoms.

Memory types in S7-400 CPUs and their backup behavior
Memory area Technology What it stores Backup source
Load memory Integrated FEPROM / Flash (soldered or plug-in card) User program (OB/FB/FC/DB), HW Config, system data, comments Non-volatile — no battery required
Work memory Static CMOS RAM Runtime execution of OB/FB/FC/DB Backup battery on PS module
System memory Static CMOS RAM Process image I/O, bit memory M, S7 timers T, counters C Backup battery on PS module
Retentive area Subset of work/system memory flagged in HW Config Selected M, T, C, and DB bytes Backup battery on PS module

STEP 7 downloads the project from the engineering station into load memory. On every restart the CPU copies blocks from load memory into work memory. If work memory loses its content (battery dead, PS module pulled), the CPU cannot rebuild the project and the diagnostic buffer logs Stop by power failure with no successful warm restart. The project is still in load memory and can be re-copied once the battery is restored and a Reset (MRES) or a Cold restart is executed.

For the retentive area to survive a power outage, two things must be true: the battery must be present and healthy, and the engineer must have explicitly marked the M/T/C/DB bytes as retentive in HW Config → CPU properties → Retentive Memory. The default is zero bytes retentive, so production data often disappears even on healthy hardware.

3. Root Cause Matrix

Symptom-to-cause matrix for S7-400 program loss
Symptom Likely cause Diagnostic confirmation
CPU in STOP after outage, BATTF on PS lit Battery exhausted or absent Measure open-circuit voltage of cell, expect < 2.8 V
CPU in STOP, BATF on CPU lit, BATTF on PS off Battery cable broken or connector unseated Inspect battery holder, check plug
CPU in STOP, both indicators off, fault follows every storm PS module failing to charge battery (trickle-charge circuit fault) Replace PS module; verify diagnostic buffer 16#4940
CPU reports "Module not consistent" HW Config lost from load memory or partial download Re-download HW Config from STEP 7
CPU in STOP with no diagnostic buffer entry at all PS module dropped output for > 80 ms, inrush on UPS hand-off Capture mains with power-quality analyzer
Program lost once, then OK for weeks Intermittent battery contact (oxidized holder) Clean battery holder contacts, retest
Project reloads successfully, fails again after next dip Load memory (FEPROM) write-back incomplete Force consistent download; check for OB121 / OB122

4. Diagnostic Buffer Deep-Dive

Open the diagnostic buffer first — before touching hardware. In STEP 7 / TIA Portal: Online → Diagnostics → Diagnostic Buffer. The most relevant event IDs for a power-loss scenario are:

S7-400 diagnostic buffer entries related to program / memory loss
Event ID Meaning Interpretation
16#4300 / 16#4301 Power OFF ↔ Power ON transition Confirms the outage; entry always present
16#4302 Power ON with backup voltage (PS OK, battery OK) Healthy restart path
16#4303 Power ON with backup failure No battery ⇒ cold restart forced
16#4915 STOP due to power failure, no battery, no warm restart possible Smoking gun for battery / PS module
16#4920 STOP due to missing or invalid load memory FEPROM/Flash corrupt or empty — re-download required
16#4921 STOP due to module configuration mismatch HW Config lost or a slot physically empty
16#4940 Battery exhausted (BATTF) Replace cell, then cold restart
16#43A0 / 16#43A1 Memory reset (MRES) executed — automatic or manual Operator triggered reset, or watchdog timeout
16#49A0 FEPROM fault detected and corrected Flash memory reaching end of life — replace CPU

The smoking-gun signature is a 16#4301 "Power OFF" followed within seconds by 16#4940 "Battery exhausted" and 16#4915 "STOP due to power failure without battery". Whenever 16#4940 appears, the root cause is the backup cell, not the program.

S7-300 and S7-400 CPUs do not behave identically on power return. The S7-300 family only supports "warm restart" after a power dip; an S7-400 supports a configurable warm or cold restart depending on the OB100 / OB101 / OB102 selection in HW Config. When a battery is dead, both families fall back to "Power-on with no battery backup" and lose RAM contents. For a detailed Siemens reference, see Retentive behavior after loss of power (S7-300 / S7-400).

5. Battery Hardware Inspection

With the rack de-energized at the upstream breaker but the PS module still inserted, remove the battery holder cover on the front of the PS 405 / PS 407.

5.1 Visual inspection

  • Check for white lithium salt deposits around the holder — sign of venting.
  • Inspect the spring contact and the +/− pads for green oxidation.
  • Confirm the cable strain relief is intact and the connector is fully seated.

5.2 Open-circuit voltage measurement

Lithium backup battery state versus open-circuit voltage
Open-circuit voltage (V) State Field action
3.55 – 3.65 New, fully charged None
3.20 – 3.54 Aged but serviceable Schedule replacement within 6 months
2.80 – 3.19 End of life Replace at next opportunity
< 2.70 Dead — CPU cannot retain RAM Replace immediately and reload project

5.3 Load test

A cell that reads 3.3 V unloaded but collapses below 2.0 V under the PS module's bias current has high internal resistance and is unfit for service. Apply a 1 mA load and re-measure; voltage must remain above 2.9 V for 60 s.

5.4 Replacement part numbers

Siemens S7-400 backup battery part numbers
Order number Type Used in
6ES7971-0BA00 3.6 V / 2.3 Ah lithium (AA-size, lead wires) PS 405 4A, PS 405 10A, PS 407 4A, PS 407 10A
6ES7971-0BA01 3.6 V / 5.6 Ah lithium (C-size) PS 407 20A for long backup time
6ES7971-0BB00 3.6 V / 5.6 Ah lithium (C-size, alternate lead length) PS 407 20A in some rack configurations
Always confirm against the spare parts list in the installed PS module manual. Substituting an off-brand lithium cell is a frequent cause of early failure: industrial cells from the OEM have a defined self-discharge curve under the PS module's floating charge profile. Non-OEM cells often drift above 3.7 V and lose capacity within 12 months.

6. Power Supply Module Diagnostics

The PS 405 (24 V DC input) and PS 407 (120/230 V AC; 120/230 V DC input) each contain three subsystems: AC/DC conversion, +5 V / +24 V regulator, and battery floating-charge circuit. Only the first two are protected by the UPS; the third is internal and can fail independently.

6.1 LED status

PS 405 / PS 407 front-panel LEDs
LED State Meaning
DC 5V (green) On Internal 5 V regulator OK, backplane powered
DC 24V (green) On Sensor / load 24 V OK
BATTF (red) On Battery absent, reversed, or below 2.7 V; cable broken
SF (red) On PS module diagnostic fault — internal error

6.2 STEP 7 diagnostic flags

Under HW Config → PS module properties → Diagnostics, enable the following diagnostic interrupts:

  • Primary voltage failure
  • Battery backup failed
  • 5 V / 24 V output failed

When enabled, these generate OB82 diagnostic-interrupt calls and write a 16#494x event to the diagnostic buffer the moment the fault occurs — well before the next mains dip causes a STOP.

7. UPS Topology and AC Power Quality

A 6 kVA three-phase UPS is a typical installation for a control cabinet, but only one topology actually masks sags and short interruptions: online double-conversion (VFI per IEC 62040-3). The other common topologies either pass the mains straight through or switch too slowly to be useful.

Mains → UPS → PS module → CPU hold-up chain 3-phase mains Standby UPS transfer 4-10 ms PS 405 / 407 hold-up 20-80 ms S7-400 CPU load Li 3.6V PS battery Best topology: Online double-conversion (VFI) — masks all sags < 20 ms

7.1 Topology comparison

UPS topology vs S7-400 sensitivity to short sags
UPS topology (IEC 62040-3 class) Transfer / response time Effective against 200 ms sag Effective against lightning impulse
Standby (VFD) 4-10 ms Partial — PS module sees the dip No — surge passes to load
Line-interactive (VI) 2-4 ms Partial — brownouts filtered No
Online double-conversion (VFI) 0 ms (output always conditioned) Yes — output stable Yes — isolation transformer in path

7.2 AC sag duration reference

IEC 61000-4-11 / -4-34 voltage dip classes and PS module reaction
Dip class Residual voltage Duration PS 407 response (battery healthy)
Class 1 / 2 (light) 70-80% Un 10-200 ms PS holds output, CPU keeps running
Class 3 (medium) 40-70% Un 100-500 ms PS holds 20-80 ms, then drops
Class 4 (deep) < 40% Un > 500 ms PS drops immediately, battery must hold RAM

A standby UPS allows a 4-10 ms gap; the PS module can ride through it on its internal capacitor. A line-interactive UPS does the same. A storm-driven sag of 200 ms will, however, exhaust the PS capacitor long before the inverter picks up. For an S7-400 installation, only an online double-conversion UPS guarantees no interruption at the PS module input.

8. Load Memory and Flash Considerations

The symptom of "the program and HW config are gone" is often reported even when the load memory is intact. The reason: the work memory copy is empty (battery dead), so STEP 7 cannot find any blocks when it goes online. The load memory is non-volatile; the work memory is not.

8.1 Verify load memory is intact

  1. Power the rack on a known-good feed with a fresh battery inserted.
  2. From STEP 7, connect online and select PLC → Download User Program to Memory Card — if the menu is greyed out, the load memory is already populated.
  3. Read the diagnostic buffer; if you see 16#4915 and 16#4301 but not 16#4920, the load memory survived and the issue is exclusively battery / RAM loss.

8.2 Verify the FEPROM end-of-life

Flash memory has a finite write endurance (typically 100k to 1M cycles per sector). A site that performs frequent online edits ("test changes") and writes the project to the CPU via Download to Target System can wear the FEPROM. The diagnostic buffer will eventually emit 16#49A0 ("FEPROM fault detected and corrected"), and from that point on you must assume the load memory is unreliable.

9. Step-by-Step Recovery Procedure

  1. Verify and de-energize. Open the upstream breaker (the UPS keeps the socket alive, so this is mandatory). Confirm zero voltage with a CAT III multimeter.
  2. Remove and inspect the backup battery. Measure the open-circuit voltage. Anything below 2.8 V is the failure point.
  3. Clean the battery holder with isopropyl alcohol and a non-metallic brush. Re-tension the spring contact if it is loose.
  4. Install a fresh 6ES7971-0BA00 (or 6ES7971-0BA01 for 20 A PS 407). Observe polarity: red lead to +, black lead to −.
  5. Re-energize the rack. The BATTF LED must extinguish within 30 seconds. If it stays lit, the cable is reversed or the PS module's charge circuit is faulty.
  6. Perform an MRES reset on the CPU: turn the mode switch to MRES, hold for 3 s, release, then turn back to MRES for another 3 s. The STOP LED flashes, then goes solid. This wipes work memory and forces a clean cold restart.
  7. Reload the project from STEP 7: PLC → Download to Target System. Tick both User program and Hardware configuration.
  8. Verify with PLC → Verify Project. STEP 7 compares the on-line blocks against the off-line project; any mismatch is flagged.
  9. Switch the CPU to RUN and observe the diagnostic buffer. The first restart after a battery replacement is logged with 16#4302 "Power ON with backup" instead of 16#4303 "Power ON with backup failure".
  10. Configure the diagnostic OBs (OB82, OB83, OB86, OB121, OB122) so that any future module, battery, or programming error is reported to the HMI instead of leaving the CPU silently in STOP.

10. Verification Checklist

  • BATTF LED on PS 405 / PS 407 is OFF.
  • BATF LED on the CPU is OFF.
  • Diagnostic buffer contains no 16#4940 or 16#4915 after a forced 10-second outage test.
  • Retentive M, T, C, and DB areas retain their last value through the same 10-second outage test.
  • Online → Operating Mode shows RUN immediately after power return (warm restart, OB100).
  • HW Config matches the physical rack — no 16#4921 "module not consistent" entries.
  • No 16#49A0 "FEPROM fault detected and corrected" entries are accumulating over time.
  • STEP 7 → Verify Project reports no differences.

11. Preventive Maintenance Program

  • Annual battery replacement in any environment where the ambient exceeds 30 °C, or where the cabinet is near vibration sources. Service life halves roughly every 10 °C above 25 °C.
  • Quarterly discharge test on the UPS batteries. A UPS that has never been loaded cannot prove that it will pick up during a real sag.
  • Annual thermal imaging of the PS module. A hot-spot on the battery holder indicates rising contact resistance.
  • Surge protective device (SPD) inspection after every named thunderstorm. IEC 61643-11 Type 2 SPDs have a mechanical flag that changes color when the MOV is end-of-life.
  • Document the retentive memory map in the project folder. In a recovery scenario, the operator must know exactly which DBs hold recipe data, which M bits hold machine state, and which timers are critical for the warm restart sequence.
  • Enable SITOP UPS1600 + BAT monitoring in front of the PS module if the site is exposed to chronic mains instability. The UPS1600 closes the gap that the PS 407 hold-up capacitor cannot — typically 5-15 minutes of CPU runtime on battery — long enough to ride out almost any storm.
  • Restrict online edits on FEPROAM-burdened CPUs. Use the off-line / on-line compare workflow and limit Download to Target System to scheduled maintenance windows. This extends FEPROM endurance from years to decades.

12. Standards and Reference

  • Retentive behavior after loss of power — S7-300 / S7-400 (Siemens)
  • IEC 62040-3 — Uninterruptible power systems: method of specifying the performance and test requirements.
  • IEC 61000-4-11 / -4-34 — Voltage dips, short interruptions and voltage variations immunity tests.
  • IEC 61643-11 — Low-voltage surge protective devices.
  • Siemens S7-400 CPU 412-2 DP manual, order number 6ES7412-2XK05-0AB0 — chapter on backup battery and retentive behavior.
  • Siemens PS 405 / PS 407 power supply module manual — chapter on battery holder, BATTF LED, and floating-charge circuit.

Frequently Asked Questions

Why does my S7-400 still lose its program even though a 6 kVA three-phase UPS is in the line?

The UPS protects the AC feed, but the S7-400 work memory is backed up only by the 3.6 V lithium cell on the PS 405 / PS 407. A dead, missing, or reversed battery causes RAM loss the moment the PS module's internal hold-up capacitor (20–80 ms) discharges. In addition, standby and line-interactive UPS topologies have a 2–10 ms transfer time that does not protect the PS module from short sags. Replace the backup battery and verify that the UPS is online double-conversion (VFI per IEC 62040-3).

How do I know if the battery or the flash memory is at fault?

Read the CPU diagnostic buffer after the event. Entry 16#4940 "Battery exhausted" preceded by 16#4301 "Power off" points to a battery problem. Entry 16#4920 "STOP due to missing or invalid load memory" without a battery entry points to flash/FEPROM corruption and requires a full re-download from STEP 7. See the diagnostic buffer table in section 4 for the full event ID list.

Which Siemens order number fits my PS 405 or PS 407?

For most PS 405 (6ES7405-0KA02-0AA0) and PS 407 (6ES7407-0KA02-0AA0, 6ES7407-0KR02-0AA0) the standard cell is 6ES7971-0BA00 (3.6 V / 2.3 Ah). For the 20 A PS 407 the 5.6 Ah version 6ES7971-0BA01 extends backup time roughly 2.4× under identical load. Always confirm against the spare parts list in the installed PS module manual before ordering.

Can I keep the CPU running while swapping the backup battery?

Yes, the PS 405 / PS 407 supports hot-swapping of the backup cell. The rack must remain powered and the CPU must be in RUN, and the replacement must take less than the time it takes the new cell to seat — typically under 30 seconds. Removing the battery with the rack unpowered is equivalent to an outage and will erase RAM immediately.

How long does the S7-400 hold RAM on a fresh battery with the rack powered off?

Backup time depends on the PS module and the number of battery slots filled. A single 6ES7971-0BA00 cell in a PS 407 10 A module typically retains the full project and retentive data for several months at 25 °C. At 60 °C the same cell lasts only a few weeks. Always size the schedule for worst-case ambient, and consider a SITOP UPS1600 in series for chronic mains instability.

Back to blog