Skip to content

Starting, Stopping and Faults ​

Last updated

License feature: Ladder Logic

Ways to start and stop a task ​

FromControlWho
Ladder Logic pagePlay / Square on the task cardAdmin, Editor (with run permission); Operator when Operators can run this is ticked
Editor toolbarRun / StopAdmin, Editor
DashboardButton widget → Ladder Task → Do What: Start scanning / Stop scanningAdmin or Editor (with run permission if the task is restricted); an Operator needs Operators can run this ticked in Task Settings — a Viewer gets an error
WorkflowStart Ladder Task, Stop Ladder Task; Ladder Task Status branches on Running/StoppedRuns as the system
Scriptladder.start(t), ladder.stop(t), ladder.isRunning(t), ladder.status(t), ladder.find(name), ladder.list() — t is the task id or nameRuns as the system
Schedules pageStart Ladder Task / Stop Ladder Task on a cronRuns as the system
RESTSee the table belowStart / stop: Admin, Editor, Operator (with run permission). Editing: Admin, Editor

Starting a running task, or stopping a stopped one, does nothing. None of these change the task's Enabled setting.

javascript
// Script: stop the palletizer task when the line goes into maintenance mode
if (tags.read('Local Tags', 'Line2/Maintenance') === 'true' && ladder.isRunning('Palletizer')) {
  ladder.stop('Palletizer');
  log('Palletizer logic stopped for maintenance');
}
MethodPathPurpose
POST/api/ladder/tasks/:id/startStart scanning
POST/api/ladder/tasks/:id/stopStop scanning
GET/api/ladder/statusStatus of every loaded task
GET/api/ladder/tasks/:id/statusRunning, scan times, fault message, rung and element states
GET/api/ladder/tasks/:id/logStart/stop/fault/reset events, newest first (?limit=, default 100)

What Stop does ​

  • Scanning stops at the end of the current scan.
  • Coils and Destinations keep their last values. An OTE that was on stays on; a motor-run bit you wrote stays 1. Only SFC N actions are switched off (see SFC).
  • Timers, counters, one-shots and internal tags keep their values; timers do not count the time the task was stopped.
  • The state is saved to the database.

Warning: Because Stop does not de-energize outputs, stopping a task is not a way to make a machine safe. If outputs must go off, drive them off first (for example a rung that unlatches them on a "Stop requested" bit), then stop the task.

Online edits ​

Saving a routine, a program change or Task Settings while the task is running:

  1. stops the task (without releasing SFC outputs),
  2. loads the saved logic,
  3. restores timers, counters, one-shots, internal tags and chart positions,
  4. starts it again straight away.

Elements are matched by their internal id, so a timer that still exists keeps its accumulated time and a counter keeps its count. A newly added element starts from zero. Outputs are not rewritten during the reload. One scan period may be missed.

There is no test-edits mode: each Save changes the running logic at once. Build and check risky changes on a stopped copy of the task first.

Forcing ​

To hold a bit on or off regardless of the real input, force it in Monitor mode. See Forcing Bits. Forces persist until removed, so an amber Forces active banner stays up while any are set.

Faults ​

A fault is an error that stops a scan part-way. The faults the engine can raise are:

MessageCause
Call stack overflow (max 32)JSR calls nested more than 32 deep — usually two routines calling each other
SFC routine "…" has no initial stepAn SFC chart with steps but no initial step is run
Call stack overflow (max 32) from SFC action in "…"An SFC routine action that calls back into itself

When a scan faults:

  • the rest of that scan is abandoned, and none of that scan's device-tag outputs are written (internal tags already changed stay changed);
  • the fault message appears in red in the editor's status bar;
  • a fault event is added to the task's event log when the fault starts or its message changes (not on every faulted scan), and a recovered event when a scan next completes;
  • a critical alarm is raised the first time the task starts faulting, named after the task, with the fault message — see Alarms. It clears itself once a scan completes cleanly, or the task is stopped;
  • _STATUS/Ladder/<task name>/Faulted on the Local Tags device goes true, with the message in _STATUS/Ladder/<task name>/LastError;
  • what happens next is the task's On a fault setting: Keep scanning (alarm only), the default, lets the next scan try again, and the fault clears if it succeeds; Stop the task halts it there, the way a PLC major fault halts a CPU.

Two faults ignore that setting and always stop the task:

  • the scan watchdog (see above), because scanning again would just block the appliance for another second;
  • the driver service not running, on a task that reads or writes tags on a real device. Without it the task has no inputs and no outputs, so it would solve on stale values and command nothing. A task built only from task tags, local tags and simulators is unaffected and keeps running.

With Keep scanning, a fault that repeats every scan blocks all output writes from the task while it still shows Running — but the alarm only fires once for that streak, not once per scan, so it won't flood the alarm list.

Errors that are not faults, and happen silently: divide by zero (result 0), an invalid CPT expression (Destination unchanged), a JSR to a routine that doesn't exist (nothing called), a tag with no value (reads as 0/false).

Alarming on a task's state ​

Each task has three tags on the Local Tags device — _STATUS/Ladder/<task name>/Running, /Faulted and /LastError — kept up to date by the engine. To be paged when a task faults, add an alarm rule on …/Faulted (Equal to 1) and attach it to a pipeline; use …/Running (Equal to 0) for a task that should never stop. The automatic fault alarm above runs no pipeline, so this is how a fault reaches a phone. See System Status Tags.

Restarts and power loss ​

ThingAfter the Scada.Ink service starts again
Tasks with Enabled tickedStart automatically
Other tasksStay stopped, even if they were running before
Timers, counters, one-shots, Task Tags, Program Tags, SFC step positionsRestored from the last saved state
Timer accumulatorsResume from the saved value; downtime is not counted
Local Tags valuesRestored by the tag engine from the database
Outputs to devicesNot re-sent until the first scan writes them

State is saved every 10 seconds while a task runs, and whenever it stops or is saved. After a power cut, counters, internal tags and SFC charts can come back up to 10 seconds out of date — a count can be a few parts short, or a chart can resume one step back. Design sequences so that repeating the last step is harmless.

License changes ​

If the Ladder Logic feature is removed, tasks don't load at the next start and the pages refuse access. If Sequential Function Charts is removed, charts stop scanning but ordinary ladder routines in the same task continue, and the SFC step tags are removed.

See also ​

Scada.Ink Help Center