Set the project compile settings
You decide, per project, what the PLC does with an out-of-range value in a subrange variable, and how many bytes an online change may copy in one cycle.
| Setting (Studio) | Setting (API) | Values | Default |
|---|---|---|---|
| Out-of-range values | subrange_violation |
Clamp and count (clamp): store the nearest bound, count it, never stop. Stop the task (fault) (fault) |
Clamp and count |
| Values copied per switch, at most | migrate_cap_bytes |
1 B to 16 MB | 1 MB |
These settings are part of the program: they are saved in the project, then signed and applied by the next Test edits or Build & Deploy, like a changed POU.
Before you start
Section titled “Before you start”- You are a Lead Engineer or an Administrator. Other users see the card read-only (Changing these settings needs a Lead Engineer or Administrator).
- The PLC has a project store (the Studio shows the Changes view).
Set them in the Studio
Section titled “Set them in the Studio”- Open File → Project Settings. The Program settings card sits with the deploy settings.
- Choose Out-of-range values: Clamp and count or Stop the task (fault).
- In Values copied per switch, at most, enter a whole number and pick B, KB or MB. The card refuses a value outside 1 B to 16 MB, or one that is not a whole number of bytes.
- Click Save in the project. Revert puts back the saved values.
- The card’s state reads changed: not running yet, with the running program’s values and the project’s: Not running yet: the running program uses clamp and count, 1 MB per switch; Test edits or Build & Deploy applies …. The Changes view shows a chip for the difference.
- Click Test edits or Build & Deploy. The test’s impact summary has the line program settings: old → new with the POUs changed. Sign as usual.
After the switch the card reads running.
Saving changes nothing that runs: until the test or deploy, the running program keeps the settings it was compiled with.
Set them through the API
Section titled “Set them through the API”-
Read the project’s revision and settings:
GET /api/projectanswersrevisionandsettings(the effective values). -
Send the change, with that revision:
PUT /api/project/settingsContent-Type: application/json{"base_revision": 57, "subrange_violation": "fault", "migrate_cap_bytes": 4194304}A key you leave out keeps its value. The answer is
{revision, format, settings, changed}.GET /api/project/comparereports (entrysettings) when the project’s settings differ from the running program’s. -
Test or deploy, as above.
How the settings are carried
Section titled “How the settings are carried”The PLC writes the settings that differ from their defaults as the first line of the linked program text:
{project subrange_violation := 'fault'; migrate_cap_bytes := 4194304}That line is part of the program hash, so a settings change is signed and audited like any other change to what runs, and a rolled-back program runs with the settings it was signed with.
Never write {project ...} in a POU yourself. A POU that holds one is refused at save, import and link ({project …} is written by the PLC only (the project’s compile settings, first line of the linked text): remove it, and set the settings with PUT /api/project/settings), and a PLCopen document that holds one is refused.
The first non-default setting changes the project file format to 2.
What each setting does
Section titled “What each setting does”Clamp and count (default). A store outside a subrange (INT(0..3000)) stores the nearest bound and counts it per variable. Watch the live values system/RangeClamps (the total) and system/RangeClamps/<Var>. A growing counter raises a diagnostic event (audited DIAGNOSTIC / RANGE_CLAMPED) at most every 10 seconds, shown in the Studio’s Diagnostics & Events panel and published on NATS plc.<id>.events (Diagnostic events). The PLC never stops for it.
Stop the task (fault). A store outside the range faults the task before anything is stored, naming the variable: range violation of X: a value outside lo..hi was stored (project setting subrange_violation = fault). Fault mode supports subrange bounds within DINT; wider bounds are a compile error.
In both modes, an external write outside the range is refused (WRITE_OUT_OF_RANGE), and a constant outside the range is a compile error.
Values copied per switch. The most bytes of migrated structure members one switch may copy in its first cycle. Above it, Test edits is blocked and a deploy is refused while the PLC runs (409 migration_too_large); with the PLC paused the deploy goes through. See Online changes to data structures. Raise it only if your fastest task can absorb the copy: roughly 0.1 ms per megabyte.
Result
Section titled “Result”- The project has a new revision; the change is audited
PROJECT_SETTINGSwith the old and the new settings line (compile settings changed (not running): the next test or deploy signs and applies them). - After the test or deploy, the running program carries the settings, and the card reads running.
Troubleshooting
Section titled “Troubleshooting”| Answer | Fix |
|---|---|
409, the project changed since you loaded it: reload |
Someone saved the project meanwhile. Reload (in the Studio the card reads the project again) and set the values again. |
400, subrange_violation is clamp or fault |
Use one of the two values. |
400, migrate_cap_bytes is 1..16777216 bytes (16 MB) |
Use a value in range. |
| X: the fault mode supports subrange bounds within DINT (compile) | Narrow the subrange, or stay with clamp and count. |
| This PLC has no project store: the program settings live in the project. | Deploy a project to the PLC first. |