Faults
A fault means the runtime met something it could not safely do, such as dividing by zero, and stopped. FORGE then refuses Run and Single Scan until you reset it. A fault is different from a build error, which the editor finds before the PLC runs.
Where a fault shows
| Place | What you see |
|---|---|
| The runtime banner | A red banner reads Faulted, the fault in words and a Reset button. |
| Run and Single Scan | They are refused with the message Faulted. Reset. |
| Problems | The fault is a row marked as a fault. The Faults filter lists only faults. |
| Troubleshoot | The Last scan card shows Fault and its code, with a Go to button that opens the instruction at fault. |
| Replay | The Faults tab lists faults with the scan each happened in. See Replay. |
Common causes
| Fault | Cause | What happens and what to do |
|---|---|---|
| Divided by zero | A DIV, a MODULO or a Structured Text division has a divisor of 0. | Nothing is written. Guard it with a compare so the divisor is above 0. |
| Square root of a negative number | A square root instruction or function got a value below 0. | Nothing is written. Check the sign of the value first. |
| Result outside its type's range | A math result is too large or small for the destination tag's type. | Nothing is written. Use a wider type, such as DINT or REAL. |
| Loop past its limit | A Structured Text loop ran more times than one scan allows. | The routine stops for that scan. Make the loop shorter, or spread the work over scans. |
| Statement limit | A Structured Text routine ran more statements than one scan allows. | The routine stops for that scan. Split the work into smaller routines. |
| A PID loop setting it refuses | Action is not 0 or 1, Out min is above Out max, or Update ms is 0 or less. | Nothing is written until the setting is fixed. |
An example: a divide by zero
This rung shares a Total over a Count. Count is 0, so DIV cannot give a result. The runtime faults, and Average keeps its old value of 7 because nothing was written. The rung and tag values below are what Core produced after the scan:
DIV
AGlobal.Total100BGlobal.Count0DestGlobal.Average7
| Tag | Value |
|---|---|
| Total | 100 |
| Count | 0 |
| Average | 7 |
A Structured Text division by zero reads Line 4 divided by zero, so nothing was written. The reason a fault stops the run is that a wrong number written to an output could drive a machine the wrong way, so the runtime does not write one.
Clear a fault
- Read the fault in Problems, or in the banner. Note the routine and the instruction.
- Click Reset in the banner, or press Alt+Shift+R.
- Fix the cause. In the example, make Count at least 1 before the DIV runs.
- Click Run or Single Scan again. If the cause is still there, the fault comes back on the first scan.
Good to know
- Reset clears the fault. It does not fix the logic, so a cause that is still there faults again.
- Record the run with Replay when a fault happens only now and then. The Faults tab shows the scan it first appeared in.
- Warnings and build errors are not faults. See The Problems and Troubleshoot panels.