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

**URL:** <https://forum.jasperx.io/t/concept-guide-triggers-scripts-and-atomic-tag-control-the-ladder-analogy/28>\
**Category:** Knowledge Base\
**Created:** [30 January 2026 04:52 UTC](https://forum.jasperx.io/t/concept-guide-triggers-scripts-and-atomic-tag-control-the-ladder-analogy/28 "2026-01-30T04:52:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex-cx](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.jasperx.io/alex-cx/32/8_2.png) [@alex-cx](https://forum.jasperx.io/u/alex-cx)\
**Post date:** [30 January 2026 04:52 UTC](https://forum.jasperx.io/t/concept-guide-triggers-scripts-and-atomic-tag-control-the-ladder-analogy/28/1 "2026-01-30T04:52:49Z")

</div>

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.

 ![JasperNode Scripts Explanation as RSLogix5000](https://canada1.discourse-cdn.com/flex028/uploads/jasperx/original/1X/f196409473db0b1bad26ef0570d380dba72fe949.jpeg)

- **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) |
