Explainer
Why a full download resets analog input offsets in CODESYS
Short answer
Yes, it is normal: a full download pushes the card's offline parameters onto the controller and a cold reset returns every active-application variable to its initial value, so a runtime-tuned offset disappears. Keep engineering-owned offsets in the offline project, operator-tuned offsets in the persistent variable list with a reload step after each download, and use online-change downloads on running machines.

On this page
- Which CODESYS operations reset the analog input offsets?
- Why does a cold reset clear variables when a warm restart keeps them?
- Where should the approved offset live: project, variable, or card?
- How do you keep HMI-entered offsets through a download?
- Can the application read or write the card's own calibration?
- What does a lost offset do to the reading?
- What is the download procedure on a running machine?
- Questions asked
Yes, that is normal behavior, and it has two separate causes. A full download or complete program overwrite pushes the card's offline parameters into the controller, replacing whatever gain and offset were tuned at runtime; a cold reset returns all variables of the active application to their initialization values, and the previous values cannot be recovered afterward. If the project's initial offset is zero, you read zero. The fix is a decision about where the approved offset lives: engineering-owned values belong in the offline project, operator-tuned values belong in the persistent variable list with an explicit reload step, and a running machine gets downloads with online change, not full overwrites.
Which CODESYS operations reset the analog input offsets? #
Two operations do it: a full download or complete program overwrite pushes the card's offline parameters onto the controller and overwrites whatever was tuned at runtime, and a cold reset returns every variable of the active application to its initialization value with no recovery. Everything else you do in a normal shift leaves the values alone.
A full download. The development environment writes the complete application, including the I/O configuration, onto the controller. The card's gain and offset go across exactly as they sit in the offline project, so any value that was tuned in the running controller is replaced. If the offline offset is zero, that is what the channel gets.
A cold reset. This is initialization: every variable of the active application goes back to its declared initial value. The runtime values are gone, and there is no recovery from the controller afterwards.
A download with online change does neither. It transfers only the changed code and leaves stored values in place, which is why it is the download to use on a production machine.
Why does a cold reset clear variables when a warm restart keeps them? #
Because initialization means assigning each variable's declared initial value: a warm restart skips that step for retained data, while reset cold, reset origin and an application download apply it. That is the documented behavior of retain variables on this platform, and it decides which storage grade your offsets need.
The standard behind the behavior is IEC 61131-3: every variable carries a declared initial value, and initialization assigns it. What the standard does not fix is which operations trigger initialization. The controller vendor documents that, and on CODESYS-based platforms the documentation splits retention into two grades.
The SoMachine V4.3 FAQ from Schneider Electric states that retain variables are reinitialized after reset cold, reset origin and an application download, and maintain their values otherwise. ABB's documentation for its CODESYS-based controllers adds that persistent variables have the higher degree of value retention. Read together: retain alone is not enough for an offset that must survive a download. Persistent storage is.
Where should the approved offset live: project, variable, or card? #
If engineering owns the calibration, keep the approved gain and offset in the offline project, so a full download deliberately restores them; if operators tune the offset from an HMI, keep it in a persistent variable and reload it after every download. Pick one owner per value and write that ownership down.
For an engineering-owned calibration, a commissioning task repeated only when a card is replaced, the offline project is the source of truth. Store the approved gain and offset there, and a full download becomes a deliberate restore of approved values instead of an accident. That only works if the project is kept current, and the project is the only complete record you have: why an uploaded PLC program is not full source recovery explains what an upload leaves behind.
If operators tune the offset from an HMI, the current value is production data, not code. It belongs in persistent storage in the controller, and the project's initial value becomes a fallback for a bare controller, never the source of truth.
How do you keep HMI-entered offsets through a download? #
Declare the offset variables in the application, add them to the persistent variable list, and make an explicit reload step part of the written download procedure; on a running machine, download with online change instead of a full download whenever the change supports it. The sequence, as a procedure you can hand to the next engineer:
- Declare each channel's offset, and gain if operators adjust it, as an application variable with the commissioning figure as its initial value.
- Add those variables to the persistent variable list, so the controller keeps their values through a download; plain retain variables are reinitialized by one.
- Write the reload into the download procedure: after the download, the application reads the stored values back before the first scan uses them.
- On a running machine, download with online change whenever the edit supports it; the stored values are untouched.
- Keep the offline card gain and offset synchronized with the approved calibration anyway, because the one full download you cannot avoid, a replacement controller, pushes them.
Can the application read or write the card's own calibration? #
No documented application interface for the input card's built-in calibration was identified for this platform, so apply the offset in application code: scale the raw value to engineering units first, then add the offset variable before anything else uses the value. Do not design HMI logic that assumes an ordinary application variable writes the channel's built-in calibration.
The input hardware has a calibration feature and the development environment has one, but neither was shown to be reachable from application code in the documentation used here. Do the offset in your own logic and treat any hardware-calibration interface you later confirm as a bonus, not a dependency. An application-level offset is data you can retain, reload and record, and that is the whole point of the exercise.
What does a lost offset do to the reading? #
The full pre-calibration error returns: in the example below, a channel that read 0.8 °C high before calibration reads 0.8 °C high again after the reset, which is 0.8 % of a 100 °C span. The loss is not a fraction of the correction; it is the whole correction.
Illustrative example, so you can size your own loss. A 4-20 mA transmitter is scaled 0-100 °C:
- Span: 20 mA − 4 mA = 16 mA
- Sensitivity: 100 °C ÷ 16 mA = 6.25 °C per mA
- At the low reference the channel reads 0.8 °C high, which equals 0.8 °C ÷ 6.25 °C per mA = 0.128 mA of current error
- The operator enters an offset of −0.8 °C, and the displayed value is correct across the range because the error is additive
A cold reset returns the offset to its initial value of 0.0 °C, and the display shows true value plus the error again: at a true 60 °C it reads 60.8 °C. If your channel reads zero for a different reason, with no raw counts at all, that is a wiring or configuration fault rather than this one; why a CODESYS analog input stays at zero on one channel works through that chain.
What is the download procedure on a running machine? #
Record every channel's approved offset before you touch the controller, then download with online change and verify the reading against that record; reserve the cold reset and the full download for hardware changes and controller replacements, the only jobs that require them. The decisions, by case:
- Engineering-owned calibration: the source of truth is the offline project. Any full download restores the approved values, no runtime tuning is allowed, so nothing can be lost.
- Operator-tuned offsets: the persistent variable list plus the reload step in the written download procedure. The calibration record outside the controller is the backup; the controller is not.
- Production machine, normal change: download with online change only. The stored offsets are untouched and no reload is needed.
- Controller replacement or hardware change: the full download belongs here. The new controller has no stored values, so re-enter the offsets from the calibration record and verify at the reference before the machine goes back to service.
One safety rule covers all four cases: a download, a reset or a controller swap stops the application, so put the machine in its safe state under your lockout and machine procedure before you start.
Questions asked
Do the offsets survive a power failure?
Usually yes. A power failure normally ends in a warm restart, and both retain and persistent variables keep their values through a warm start. Reset cold and reset origin reinitialize them, and an application download reinitializes plain retain variables, which is why an offset that must survive a download belongs in the persistent list. Check which restart your controller performs after power returns.
The offset was restored but the reading is still wrong, so what next?
Check the gain, not only the offset. An offset error is the same number of units at every point of the range; a gain error grows with the reading. Verify at two points, near the low and the high end: equal errors at both points mean the offset is wrong, and a larger error at the top means the gain or the card's offline scaling is wrong.
Does a download with online change push the card's offline parameters?
No. An online change transfers only the modified application code and leaves stored values and device parameters as they are, which is why it is the right download on a running machine. The complete overwrite is the operation that pushes the card's offline parameters into the controller.
Does a project backup include the tuned offsets?
No. Persistent values are stored on the controller, not inside the project file, so a project archive does not contain them. Before any download or reset, read each channel's current offset from the running application and write it into the calibration record with the date, the channel and the reference used to produce it.


