Concept Guide: Triggers, Scripts, and Atomic Tag Control (The "Ladder" Analogy)

If you come from a traditional PLC background (Allen Bradley, Siemens), moving to a JavaScript-based runtime might feel unfamiliar. However, the core logic flow remains surprisingly similar to a standard Ladder Rung.

We use an architecture based on three components: Triggers, Scripts, and Returns/Results.

1. The Visual Analogy

In a traditional PLC (like RSLogix 5000 or TIA Portal), a rung of logic reads inputs on the left to drive an output coil on the right.

JasperNode follows this exact pattern but formalises it to prevent errors.

  • The “Initial Contacts” = Triggers: In Ladder, the rung executes based on the state of the contacts. In JasperNode, a script executes only when specific tags change value.

  • The “Rung Logic” = Script: This is the transformation layer. In Ladder, it’s series/parallel logic or function blocks. In JasperNode, this is a JavaScript function generated by the AI (or written by you).

  • The “Coil” = Result (Atomic Tag): The final output variable that gets updated.

2. The Core Difference: Event-Driven vs. Cyclic Scan

While the structure looks similar, the execution engine is different.

  • Traditional PLC: Runs a “Continuous Scan.” It reads all inputs and solves every rung, every cycle, regardless of whether data has changed.
  • JasperNode: Has a cycle, but it employs an “Event-Driven” model.
  1. Data In: The system detects a value change in a tag.
  2. Event Preparation: It identifies only the scripts linked to that specific change.
  3. Execution: It runs those specific scripts.
  4. Data Out: It writes the results.

This means if your machine is idle, JasperNode is using almost zero CPU.

3. Atomic Tag Control (Solving “Double Coil” Syndrome)

One of the most dangerous bugs in PLC programming is the “Double Coil”, where two different rungs try to write to the same output, causing the machine to flicker or behave unpredictably.

JasperNode eliminates this via Atomic Tag Control.

The Rule:

A tag can only be changed by one single assigned script.

In JasperNode, you do not write to a tag from a script. Instead, you assign a script to a tag. The tag “owns” the script. This strictly enforces a single source of truth for every variable in your system, making “race conditions” impossible by design.

Summary Table

Feature Traditional PLC (Ladder) JasperNode (JS)
Execution Cyclic Scan (Loops everything) Event-Driven (Runs on change)
Inputs Contacts (XIC/XIO) Triggers (Tag Subscriptions)
Logic Rungs / Function Blocks JavaScript Functions
Output Safety “Double Coil” is possible Atomic Tag Control (Enforced)