Program loss after an outage is not bad luck; it is storage physics. RAM, flash and EEPROM behave differently, and the battery discipline decides whether RAM-based CPUs survive.
Where the program lives decides the outcome. RAM loses everything without power and depends on a backup battery or supercapacitor - when the battery dies, one outage wipes the memory. Flash retains the program but a power cut during a download can corrupt the file. EEPROM cards hold forever but suffer oxidised sockets. Identify your case from the CPU model and card type: RAM-based machines must treat the battery alarm as a fault, flash-based ones need a stable supply during writes.
Battery discipline in detail: lithium cells last 3~5 years, halved at 50C inside a hot cabinet; below the alarm threshold (around 2.9~3.0V on a 3.0~3.6V cell) the CPU warns while data survives days to a few weeks - the last window to change. Replace with the CPU powered up, per the maker procedure; swapping it dead means wiping it yourself. Record the date and roll the schedule forward. Supercapacitor types hold only hours to days - upload before any long shutdown. The permanent cure: flash storage or a memory card, retentive areas plus the backup regime, and an online UPS for 15~30 minutes of ride-through that also protects programs mid-write.
| Storage type | On power loss | Maintenance | Risk |
|---|---|---|---|
| RAM plus battery | Lost when battery dies | Hot-swap cells, 3~5 year cycle | One outage wipes it |
| RAM plus supercap | Hours to days of hold | Upload before long stops | Program evaporates on holiday |
| Flash memory | Retained | Stable supply during writes | Corruption if interrupted |
| EEPROM card | Retained | Check socket and ageing | Oxidised contact failures |
| UPS plus any type | Rides through dips | Quarterly discharge test | Dead UPS battery equals nothing |
Know the storage type, watch the battery, compare after every outage. Treat the cell like a contactor - a consumable on a schedule - and pair the hardware with the backup regime so loss becomes impossible rather than unlikely.
The quantities and component characteristics discussed here follow current national standards and the corresponding IEC documents: Memory and retention requirements per GB/T 15969.2 (IEC 61131-2), UPS systems per the GB/T 7260 series, machinery electricals per GB/T 5226.1. Always check the device datasheet and the product design file for ratings and derating.
Locate the issue with the approach above, then confirm with measurements; safety-related circuits must follow the standards and manufacturer requirements.