The biggest hidden risk of online modification is not writing wrong code but sweeping data away with it: calibration values, recipes and production counts in retained areas evaporate during one casually ticked "program + data download". Keeping data safe takes four defences: the download scope chosen right, retention attributes set right, timing chosen right, and backups taken first. Each follows.
| Download scene | Tick | Never tick |
|---|---|---|
| Daily logic edits | Program (differential write) | Device memory / DB initial values |
| Parameter changes (timer settings etc.) | Program or parameters | Retained-area current values |
| First download / full program replacement | Program + parameters (data separately) | A full download only when no valid field data exists |
Key awareness: on many platforms a "download" pushes the data block's initial values over the running values — retained accumulators and HMI-edited parameters get overwritten by whatever sits in the editor. Wherever the platform distinguishes "program download" from "program + data download", logic edits always take the former. Read the confirmation dialog line by line before pressing OK — two seconds buying an insurance policy.
Whether data survives downloads and outages depends on storage retention: retained areas (DB retention, holding D areas, retentive M) keep values through most downloads and outages; non-retained areas clear. At design time, produce the "data classification table": calibration, recipes, counts → retained area; intermediates → non-retained. Deciding this after the code exists means re-addressing the whole program — do it before writing code.
| Operation | Risk | Safe practice |
|---|---|---|
| Changing DB structure online (adding variables) | Data re-laid out; retained values misread | Stopped-machine change + structure-change record + verify after |
| Changing a DB variable's initial value | Next full download overwrites the running value | Check retention: retained variables' initial values do not touch running values |
| Downloading while the HMI writes parameters | The write is cut mid-way | Avoid operator parameter sessions when downloading |
| PLC restart after parameter download | Non-retained data cleared, flow reset | Restart only with the machine stationary |
Structure changes (adding fields, changing types) are the data-loss heartland: some platforms re-lay storage offsets online, so old retained data read under the new layout is gibberish. The rule: structure changes are stopped-machine operations — export existing data first, import and verify item by item after.
Before any online modification, take a full "read from PLC" backup (program + parameters + data), named with the date — two minutes of cost, and the only defence that rescues a change that already went wrong. Read back a second copy after the change (the post-edit version). Export recipes and calibration as CSV separately. Of the four defences, backup is the only one that undoes damage; the other three prevent it.
Immediately after any online modification: ① sample 3~5 key retained values (calibration, recipe number, accumulators) against pre-edit values; ② spot-check HMI parameter pages display correctly; ③ run one empty cycle and confirm runtime data accumulates. All three pass and production resumes; any failure restores the pre-edit backup at once — recovery is cheapest while memory is fresh.
| Incident | Root cause | Prevention |
|---|---|---|
| Calibration all reset to defaults | Full download flushed initial values | Program only + backup before download |
| Production counts cleared | Retention never set; lost with the outage | Data classification table at design time |
| Recipe data gibberish | Online DB structure change re-laid offsets | Stopped-machine structure changes + export/import |
| HMI parameter write interrupted | Engineer downloaded during an operator session | Avoid the window; announce the download |
Data preservation is about the boundary between "program space" and "data space", and making every download act precisely on the former. The four defences in one line: scope right (no data ticks), attributes right (retained areas), timing right (avoid operators), backup first (a way back). All four up, and online modification earns its "maintenance without stopping" promise.
Download modes and retention behaviour follow the platform manuals (Mitsubishi GX Works write scopes, Siemens download and retentive memory, CODESYS download behaviour); retentive-memory mechanisms follow each platform's storage documentation; safety during modification follows GB 5226.1 / IEC 60204-1 (no spontaneous restart after reset; parameters verified after change).
Write the standard sequence on the commissioning PC: backup-read → download-scope check → post-edit three-item data check.