# Tech Note : CODESYS Persistent Variables

**URL:** <https://www.wago.community/t/tech-note-codesys-persistent-variables/1845>\
**Category:** CODESYS\
**Tags:** how-to, codesys\
**Created:** [May 14, 2025, 10:33pm UTC](https://www.wago.community/t/tech-note-codesys-persistent-variables/1845 "2025-05-14T22:33:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikePsaltis](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/mikepsaltis/32/47_2.png) [@MikePsaltis](https://www.wago.community/u/MikePsaltis)\
**Post date:** [May 14, 2025, 10:33pm UTC](https://www.wago.community/t/tech-note-codesys-persistent-variables/1845/1 "2025-05-14T22:33:47Z")

</div>

This is short note for new users to CODESYS on how to use local, retain, and persistent retain variables.

**Local or Global Vars** - Values that will be re-initialized when the PLC is rebooted or turned on and off. An example could be speed feedback from a VFD, or variable for the current temperature.

**Retain Vars** - Used for variables where only a cold reset will re-initialize these values. This might be a user configured setpoint where a maintenance tech could perform a cold reset to return a value to a factory state.

**Persistent Retain Vars** - Used for variables like system configuration, that should not re-initialize. The user could use a persistent variable for the number of run hours since the machine was last serviced.

> **[Codesys 3.5 Examples · GitLab](https://gitlab.com/wago_americas/C3.5_Examples)**
>
> GitLab.com

---

<div class="post-metadata">

**Author:** ![durallymax](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@durallymax](https://www.wago.community/u/durallymax)\
**Post date:** [May 19, 2025, 12:21pm UTC](https://www.wago.community/t/tech-note-codesys-persistent-variables/1845/2 "2025-05-19T12:21:31Z")

</div>

One additional gotcha to watch out for, Retain does not survive a download and requires Persistent Vars. Wish there were a better way to handle this.

---

<div class="post-metadata">

**Author:** ![m2brenesp](https://avatars.discourse-cdn.com/v4/letter/m/2bfe46/32.png) [@m2brenesp](https://www.wago.community/u/m2brenesp)\
**Post date:** [March 4, 2026, 7:52pm UTC](https://www.wago.community/t/tech-note-codesys-persistent-variables/1845/3 "2026-03-04T19:52:24Z")

</div>

Then what is the meaning of download? When should it be used?

---

<div class="post-metadata">

**Author:** ![WagoIcard](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagoicard/32/1508_2.png) [@WagoIcard](https://www.wago.community/u/WagoIcard)\
**Post date:** [March 16, 2026, 11:50pm UTC](https://www.wago.community/t/tech-note-codesys-persistent-variables/1845/4 "2026-03-16T23:50:31Z")

</div>

Download mean put a new program which don’t support online changes.

---

<div class="post-metadata">

**Author:** ![William](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@William](https://www.wago.community/u/William)\
**Post date:** [March 31, 2026, 1:05pm UTC](https://www.wago.community/t/tech-note-codesys-persistent-variables/1845/5 "2026-03-31T13:05:37Z")

</div>

Hi, how do retain and persistent variables behave when power is lost?

---

<div class="post-metadata">

**Author:** ![AdamReeve](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/adamreeve/32/59_2.png) [@AdamReeve](https://www.wago.community/u/AdamReeve)\
**Post date:** [March 31, 2026, 3:26pm UTC](https://www.wago.community/t/tech-note-codesys-persistent-variables/1845/6 "2026-03-31T15:26:20Z")

</div>

Both are preserved on power loss. They behave the exact same in this regard.

---

<div class="post-metadata">

**Author:** ![jgovek](https://avatars.discourse-cdn.com/v4/letter/j/f08c70/32.png) [@jgovek](https://www.wago.community/u/jgovek)\
**Post date:** [June 29, 2026, 2:45pm UTC](https://www.wago.community/t/tech-note-codesys-persistent-variables/1845/7 "2026-06-29T14:45:10Z")

</div>

Unless there is a specific reason not to do so, set the variables as both Retain and Persistent. Covers everything.

---

<div class="post-metadata">

**Author:** ![durallymax](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@durallymax](https://www.wago.community/u/durallymax)\
**Post date:** [June 29, 2026, 3:53pm UTC](https://www.wago.community/t/tech-note-codesys-persistent-variables/1845/8 "2026-06-29T15:53:34Z")

</div>

Since V3.3.0.1 PERSISTENT RETAIN and PERSISTENT are treated the same, no need to specify both.

Today I would just avoid PERSISTENT entirely, too many caveats and one corrupted write during a power outage will ruin your day. WAGO supports the Persistence Manager, a bit more initial setup, but a better experience overall.
