B9X Ladder Editor

B9X Ladder Editor Language Reference

Version 1.50 – B9X Basic and Arduino Exports

B9X Ladder Editor is a graphical control-programming environment based on relay ladder logic. Use this reference to design, document, save, and export complete ladder programs.

Overview and Quick Start

What B9X Ladder Editor is

B9X Ladder Editor is a graphical control-programming environment based on relay ladder logic. A program is built from horizontal rungs. Contacts and comparison elements form a condition on the left; coils, timers, counters, assignments, calls, and other actions appear toward the right. The completed project can be saved, reopened, reviewed, and exported as B9X Basic or Arduino source.

How to use this reference

Begin with the quick-start workflow, then use the element reference while building rungs. The operators and expressions chapter explains how series and parallel paths combine. The design and troubleshooting chapters cover reliable program structure. Examples are intentionally small so each rule is visible.

Language scope

The ladder language is graphical. Terms such as operator, statement, clause, and expression describe the behavior of rungs and elements; users do not type a separate textual ladder syntax. Function calls and include elements connect ladder conditions to customer-supplied B9X Basic or Arduino routines.

Create a project

Add a rung, place the required contacts from left to right, add an output or action, select each element, enter its Label, GPIO, Value, and Debounce settings as applicable, and choose Apply. Add a clear rung comment. Repeat for each operation.

Test the logic on paper

Read every rung from left to right and the project from top to bottom. Verify what happens when every input is 0, when each input changes, when timers finish, and when resets occur. Confirm that mutually exclusive outputs cannot be true together.

Save and export

Use Save App to preserve the editable ladder project. Use Load App to reopen it. Export B9X Basic .bas for B9X Basic or Export Arduino .ino for Arduino. A compressed Arduino option is available when a compact sketch is preferred. The configured rung limit is checked before export.

Ladder Language Fundamentals

Program scan

A ladder program is evaluated repeatedly from the first rung to the last. Within each rung, contact groups form the condition and actions operate from that condition. Rung order therefore affects behavior.

Rung anatomy

  • Contacts and comparisons form the condition.
  • Series groups produce AND logic.
  • Parallel branch contacts produce OR logic.
  • Coils and control blocks perform actions.
  • A rung comment records intent and assumptions.
(StartA OR StartB) AND StopHealthy AND NOT AlarmActive -> Motor OUT

Fields and Data Types

Element fields

FieldMeaningRules
LabelSymbolic name, message, or function/block name.Use descriptive names. Cross-references must match exactly.
GPIOPhysical digital pin for an input or output.Leave blank for internal elements. Do not use GPIO as a general value field.
Value / CommentShared field for presets, thresholds, assignments, paths, sequence steps, and rung comments.Its meaning depends on the selected element.
DebounceInput stabilization time from 0 to 5000 milliseconds.Used for physical GPIO contacts and edge contacts; use 0 when not needed.
Coil modeOUT, SET, or RST.OUT follows the rung; SET latches on; RST clears.
Rung commentPlain-language purpose and assumptions for the selected rung.Comments are saved and carried into exports.

Data types

TypeRepresentationTypical uses
Boolean/state0 or 1Digital inputs, OUT/SET/RST coils, internal permissives, one-shot states.
NumericNumeric valueADC and temperature readings, comparison values, SET DBL variables, timer/counter support values.
StringTextSET STR and PRINT. B9X Basic string names use a trailing $, such as message$.
Digital inputPhysical logic levelNO, NC, rising-edge, and falling-edge contacts with a GPIO.
Digital outputPhysical logic levelA coil with an assigned GPIO.
Timer stateRunning, elapsed/done conceptTON, TOF, TP, RTO and timer-done contacts.
Counter stateCount and done conceptCTU, CTD, counter-done contacts, and reset.
Sequencer stateCurrent step and done conceptSEQ, SEQ STEP, SEQ DONE, and SEQ RST.

Naming rules

  • Begin names with a letter and use descriptive letters, digits, and underscores.
  • Use the same spelling and capitalization for every reference.
  • Use a trailing dollar sign for B9X Basic strings, such as message$.
  • Leave GPIO blank for internal states and non-I/O elements.

Operators, Statements, Clauses, and Expressions

Graphical/operator formMeaningEvaluationExample
Series connectionANDEvery series group must be true.Start AND StopHealthy AND NoAlarm
Parallel branch groupORAt least one contact in the group must be true.StartA OR StartB
Normally-closed contactNOT / inverse testTrue when the tested state is 0.NOT alarmActive
>Greater thanLeft numeric tag is greater than Value.temperature > 80
<Less thanLeft numeric tag is less than Value.level < 20
=EqualNumeric tag equals Value.mode = 2
>=Greater than or equalNumeric tag is at least Value.pressure >= 100
<=Less than or equalNumeric tag is no greater than Value.speed <= 500
<>Not equalNumeric tag differs from Value.errorCode <> 0
Rising edge0 to 1 transitionTrue for one scan on an off-to-on change.partSensor rises
Falling edge1 to 0 transitionTrue for one scan on an on-to-off change.doorSwitch falls

Statements

A statement is an action controlled by a rung expression: a coil, timer, counter, reset, sequencer, assignment, print, call, or include action.

Clauses

A rung is equivalent to a conditional clause: when the combined contact expression is true, perform the action. Inverse behavior is formed with NC contacts or complementary comparisons.

Expressions

  • Boolean series/parallel expressions
  • Numeric comparisons
  • Rising and falling edge expressions
  • Timer/counter/sequencer done expressions
  • Coil and internal-state expressions

Complete Element Reference

Each example appears before the resulting value or state.

Contacts

NO – Normally-open contact

Purpose. Tests a digital input or Boolean tag for an ON state.

Fields. Label: tag name. GPIO: physical input pin or blank for an internal tag. Debounce: 0 to 5000 ms.

Behavior. The contact is true when its tag value is 1. In series it participates in AND logic; in a branch group it participates in OR logic.

Example
Use NO startButton on GPIO 13 ahead of an OUT coil named motorRelay.

Resulting value or state. The rung path through this contact is true while startButton is 1.

Note. A blank GPIO makes the contact an internal condition. Use Coil NO for a clearer internal output-state contact.

NC – Normally-closed contact

Purpose. Tests a digital input or Boolean tag for an OFF state.

Fields. Label: tag name. GPIO: physical input pin or blank. Debounce: 0 to 5000 ms.

Behavior. The contact is true when its tag value is 0. It is the logical inverse of a normally-open test.

Example
Use NC stopButton on GPIO 14 in series with the motor start path.

Resulting value or state. The path remains true while stopButton is 0 and becomes false when it is 1.

Note. NO and NC describe the logical test. Confirm the actual field wiring and active level separately.

↑ – Rising-edge contact

Purpose. Creates a one-scan condition when an input changes from OFF to ON.

Fields. Label: tag name. GPIO: physical input pin. Debounce: 0 to 5000 ms.

Behavior. The contact is true only during the scan that detects a 0-to-1 transition.

Example
Place ↑ partSensor on GPIO 12 ahead of a CTU counter.

Resulting value or state. One count request is produced for each detected rising transition.

Note. Use this element for events. Use NO when the condition must remain true while the input stays on.

↓ – Falling-edge contact

Purpose. Creates a one-scan condition when an input changes from ON to OFF.

Fields. Label: tag name. GPIO: physical input pin. Debounce: 0 to 5000 ms.

Behavior. The contact is true only during the scan that detects a 1-to-0 transition.

Example
Place ↓ doorSwitch ahead of a SET coil named doorWasClosed.

Resulting value or state. doorWasClosed is set once when doorSwitch changes from 1 to 0.

Note. The input must first be observed on before a falling transition can occur.

Coil NO – Coil-state normally-open contact

Purpose. Tests the state of a coil or internal Boolean tag.

Fields. Label: the exact coil or internal state name. GPIO is not used.

Behavior. The contact is true while the named state equals 1.

Example
Use Coil NO motorRelay in parallel with the Start contact to make a seal-in path.

Resulting value or state. The parallel path remains true after Start is released while motorRelay remains on.

Note. The label must exactly match the state being referenced.

Coil NC – Coil-state normally-closed contact

Purpose. Tests the inverse state of a coil or internal Boolean tag.

Fields. Label: the exact coil or internal state name. GPIO is not used.

Behavior. The contact is true while the named state equals 0.

Example
Use Coil NC alarmActive in series with a normal-operation output.

Resulting value or state. The path is enabled only while alarmActive is off.

Note. Useful for interlocks, mutual exclusion, and permissive logic.

Branches

Branch NO – Parallel normally-open contact

Purpose. Adds a normally-open alternative path at the selected series position.

Fields. Select an existing contact first; then assign Label, GPIO, and Debounce as needed.

Behavior. All contacts in the same branch group are ORed.

Example
Place Start A and Start B in the same branch group ahead of one motor coil.

Resulting value or state. The group is true when Start A OR Start B is true.

Note. Branch NC, B Coil NO, B Coil NC, Branch ↑, and Branch ↓ follow the same OR grouping rule.

Branch NC – Parallel normally-closed contact

Purpose. Adds a normally-closed alternative path at the selected series position.

Fields. Select a contact, choose Branch NC, then set its label, GPIO, and debounce.

Behavior. The branch is true when the new contact value is 0.

Example
Branch NC manualMode in parallel with NO automaticPermit.

Resulting value or state. The group is true when manualMode is 0 OR automaticPermit is 1.

B Coil NO / B Coil NC – Parallel coil-state contact

Purpose. Adds an internal-state alternative path without assigning a GPIO.

Fields. Label: exact coil or state name.

Behavior. B Coil NO is true for state 1; B Coil NC is true for state 0.

Example
Add B Coil NO motorRelay beside NO startButton.

Resulting value or state. The branch group stays true through motorRelay after the Start button is released.

Branch ↑ / Branch ↓ – Parallel edge contact

Purpose. Adds a transition-sensitive alternative path.

Fields. Label, GPIO, and debounce identify the physical event input.

Behavior. The branch contributes a one-scan true state on the selected transition.

Example
Place rising events from sensorA and sensorB in one branch group.

Resulting value or state. The group pulses when either sensor produces the selected edge.

Outputs

OUT – Output coil

Purpose. Makes an output or Boolean state follow the complete rung condition.

Fields. Label: output/state name. GPIO: physical output pin or blank for an internal state. Mode: OUT.

Behavior. The output is set to 1 when the rung is true and 0 when the rung is false.

Example
NO enableSwitch followed by OUT fanRelay on GPIO 18.

Resulting value or state. fanRelay and GPIO 18 follow enableSwitch.

Note. Avoid driving the same OUT label from multiple rungs; combine the conditions instead.

SET – Set coil

Purpose. Latches an output or internal state on.

Fields. Label: output/state name. GPIO: output pin or blank. Mode: SET.

Behavior. When the rung becomes true, the state is assigned 1 and remains 1 after the rung becomes false.

Example
Rising-edge faultSensor followed by SET alarmLatched.

Resulting value or state. alarmLatched remains 1 until a RESET coil clears it.

Note. Every latched state should have a deliberate and reachable reset path.

RST – Reset coil

Purpose. Clears a latched output or internal state.

Fields. Label and GPIO must identify the same state used by SET. Mode: RESET.

Behavior. When the rung is true, the state is assigned 0.

Example
NO resetButton followed by RST alarmLatched.

Resulting value or state. alarmLatched becomes 0 while the reset condition is true.

Timers

TON – On-delay timer

Purpose. Delays the timer-done state after the rung condition turns on.

Fields. Label: timer name. Value: preset time in milliseconds.

Behavior. Timing begins when the rung becomes true. Done becomes true after the condition stays true for the preset. A false rung clears normal TON timing.

Example
NO startRequest followed by TON startDelay with Value 5000.

Resulting value or state. startDelay done becomes 1 after startRequest remains true for 5 seconds.

Note. Use T DN NO or T DN NC with the same label in another rung.

TOF – Off-delay timer

Purpose. Delays the timer-done state from turning off after the rung condition turns off.

Fields. Label: timer name. Value: off-delay in milliseconds.

Behavior. Done is true while the rung is true and remains true for the preset interval after the rung becomes false.

Example
NO occupancy followed by TOF lightDelay with Value 30000.

Resulting value or state. lightDelay done remains true for 30 seconds after occupancy turns off.

TP – Pulse timer

Purpose. Produces a timed pulse from a triggering condition.

Fields. Label: timer name. Value: pulse width in milliseconds.

Behavior. A trigger starts a pulse whose done state remains true for the preset duration.

Example
↑ triggerButton followed by TP hornPulse with Value 1000.

Resulting value or state. hornPulse done stays true for approximately 1 second per accepted trigger.

Note. Use a transition contact when exactly one pulse is required per press.

RTO – Retentive on-delay timer

Purpose. Accumulates enabled time across interruptions.

Fields. Label: timer name. Value: accumulated-time preset in milliseconds.

Behavior. Elapsed enabled time is retained when the rung becomes false. Done becomes true when accumulated time reaches the preset.

Example
NO pumpRunning followed by RTO serviceTimer with Value 3600000.

Resulting value or state. serviceTimer done becomes true after one accumulated hour of pump operation.

Note. Use T RST with the same timer name to clear accumulated time and done state.

T DN NO – Timer-done normally-open contact

Purpose. Tests whether a named timer is done.

Fields. Label: exact TON, TOF, TP, or RTO name. GPIO is not used.

Behavior. The contact is true when the timer done state equals 1.

Example
T DN NO startDelay followed by OUT motorRelay.

Resulting value or state. motorRelay turns on after startDelay becomes done.

T DN NC – Timer-done normally-closed contact

Purpose. Tests whether a named timer is not done.

Fields. Label: exact timer name. GPIO is not used.

Behavior. The contact is true while the timer done state equals 0.

Example
T DN NC warmup followed by OUT warmingLamp.

Resulting value or state. warmingLamp remains on until warmup is done.

T RST – Timer restart/reset

Purpose. Restarts or clears the named timer state.

Fields. Label: exact timer name.

Behavior. When its rung condition is true, the timer is returned to its restart state.

Example
NO resetButton followed by T RST serviceTimer.

Resulting value or state. serviceTimer timing and done state are cleared/restarted.

Counters

CTU – Count-up counter

Purpose. Counts false-to-true transitions of its rung condition.

Fields. Label: counter name. Value: positive preset count.

Behavior. The count increases once per condition transition. Done becomes true when count reaches the preset.

Example
↑ partSensor followed by CTU batchCount with Value 10.

Resulting value or state. batchCount done becomes 1 when ten accepted part events have occurred.

Note. Do not feed a continuously true condition when distinct events are intended.

CTD – Count-down counter

Purpose. Counts downward from a preset on condition transitions.

Fields. Label: counter name. Value: starting count.

Behavior. Each accepted transition decreases the count. Done becomes true when the count reaches zero.

Example
↑ dispenseEvent followed by CTD itemsRemaining with Value 25.

Resulting value or state. itemsRemaining done becomes 1 after 25 accepted events.

C DN NO – Counter-done normally-open contact

Purpose. Tests whether a named counter is done.

Fields. Label: exact CTU or CTD name.

Behavior. The contact is true when the counter done state equals 1.

Example
C DN NO batchCount followed by SET batchComplete.

Resulting value or state. batchComplete is latched when the counter reaches its preset.

C DN NC – Counter-done normally-closed contact

Purpose. Tests whether a named counter is not done.

Fields. Label: exact CTU or CTD name.

Behavior. The contact is true while the counter done state equals 0.

Example
C DN NC batchCount followed by OUT conveyorEnable.

Resulting value or state. conveyorEnable remains on until the batch count is complete.

C RST – Counter reset

Purpose. Clears the named counter.

Fields. Label: exact counter name.

Behavior. When the rung is true, count, done, and event-history state are reset.

Example
NO newBatchButton followed by C RST batchCount.

Resulting value or state. batchCount returns to its reset state for a new batch.

Analog and temperature

ADC – Analog input

Purpose. Reads a calibrated analog channel into a numeric tag.

Fields. Label: numeric tag. Value/ADC channel: 0, 1, 2, or 3.

Behavior. The tag is refreshed during program scanning and can be tested by comparison contacts.

Example
ADC tankLevel using channel 0, followed elsewhere by > tankLevel with Value 2500.

Resulting value or state. tankLevel contains the current calibrated reading; the comparison is true above 2500.

Note. An ADC channel is not an arbitrary digital GPIO number.

TEMP – Temperature input

Purpose. Reads a supported temperature sensor into a numeric tag.

Fields. Label: temperature tag. Value: sensor data GPIO required by the target hardware configuration.

Behavior. The numeric reading is refreshed and can be used by comparison contacts.

Example
TEMP roomTemperature with Value 4, then < roomTemperature with Value 68.

Resulting value or state. The comparison becomes true when roomTemperature is below 68.

Comparisons

> – Greater-than comparison

Purpose. Tests whether a numeric tag is greater than a value.

Fields. Label: numeric tag. Value: threshold or valid numeric expression.

Behavior. Acts as a contact and may be placed in series or parallel.

Example
> tankLevel with Value 2500 followed by OUT highLevelAlarm.

Resulting value or state. The path is true when tankLevel > 2500.

< – Less-than comparison

Purpose. Tests whether a numeric tag is less than a value.

Fields. Label: numeric tag. Value: threshold.

Behavior. Acts as a contact.

Example
< roomTemperature with Value 68 followed by OUT heater.

Resulting value or state. The path is true when roomTemperature < 68.

= – Equal comparison

Purpose. Tests whether a numeric tag equals a value.

Fields. Label: numeric tag. Value: comparison value.

Behavior. Acts as a contact using numeric equality.

Example
= operatingMode with Value 2 followed by OUT automaticModeLamp.

Resulting value or state. The path is true when operatingMode equals 2.

>= – Greater-than-or-equal comparison

Purpose. Tests whether a numeric tag is at least a value.

Fields. Label: numeric tag. Value: threshold.

Behavior. Acts as a contact.

Example
>= pressure with Value 100 followed by SET pressureAlarm.

Resulting value or state. The path is true when pressure is 100 or greater.

<= – Less-than-or-equal comparison

Purpose. Tests whether a numeric tag is no greater than a value.

Fields. Label: numeric tag. Value: threshold.

Behavior. Acts as a contact.

Example
<= speed with Value 500 followed by OUT lowSpeedPermit.

Resulting value or state. The path is true when speed is 500 or less.

<> – Not-equal comparison

Purpose. Tests whether a numeric tag differs from a value.

Fields. Label: numeric tag. Value: comparison value.

Behavior. Acts as a contact.

Example
<> errorCode with Value 0 followed by SET alarmActive.

Resulting value or state. The path is true whenever errorCode is not zero.

Control

ONE SHOT – One-shot output

Purpose. Creates an internal pulse that is true for one scan on a false-to-true rung transition.

Fields. Label: pulse tag. GPIO is not used.

Behavior. The pulse tag is set for one scan, then automatically returns to 0.

Example
NO cycleStart followed by ONE SHOT startPulse; use Coil NO startPulse in another rung.

Resulting value or state. startPulse is 1 for one scan per new cycleStart activation.

SEQ – Sequencer

Purpose. Maintains an integer step and advances it on accepted rung transitions.

Fields. Label: sequencer name. Value: number of steps supported by the selected export target.

Behavior. A new triggering transition advances the current step. Step and done contacts coordinate staged operation.

Example
TP cyclePulse followed by SEQ trafficSequence with Value 4.

Resulting value or state. trafficSequence advances through its configured step states.

Note. For B9X Basic projects, design and test the complete step wrap/reset behavior before connecting outputs.

SEQ STEP – Sequencer step contact

Purpose. Tests whether a sequencer is at a specified step.

Fields. Label: exact sequencer name. Value: requested step number. GPIO is not used.

Behavior. The contact is true only while the current step equals the selected value.

Example
SEQ STEP trafficSequence with Value 1 followed by OUT yellowLight.

Resulting value or state. yellowLight is enabled while trafficSequence is at step 1.

SEQ DONE – Sequencer done contact

Purpose. Tests the completion state of a sequencer.

Fields. Label: exact sequencer name.

Behavior. The contact becomes true at the sequencer completion state.

Example
SEQ DONE washCycle followed by SET cycleComplete.

Resulting value or state. cycleComplete is latched when washCycle reports done.

SEQ RST – Sequencer reset

Purpose. Returns a sequencer to its initial step.

Fields. Label: exact sequencer name.

Behavior. When the rung is true, step, done, and edge-history state are reset.

Example
NO resetButton followed by SEQ RST washCycle.

Resulting value or state. washCycle returns to its initial state.

Functions and inclusion

CALL – Conditional function call

Purpose. Calls a named B9X Basic or Arduino function when the rung is true.

Fields. Label: function name. The function must exist in the destination project.

Behavior. The function is invoked during each scan in which the rung condition is true.

Example
C DN NO batchCount followed by CALL reportBatchComplete.

Resulting value or state. Control returns to the ladder scan after reportBatchComplete finishes.

Note. Use an edge or one-shot condition if the function should run only once per event.

CALL INITIALIZATION – Initialization function call

Purpose. Calls a named function once during startup before repeated ladder scanning begins.

Fields. Label: function name. Put this element on its own rung.

Behavior. The function is placed in the initialization portion of the export.

Example
CALL INITIALIZATION initializeDisplay on a dedicated rung.

Resulting value or state. Control returns after initializeDisplay finishes, then normal scanning begins.

INCLUDE FILE – Conditional include file

Purpose. Includes the contents of a customer-supplied text/source file under a rung condition.

Fields. Label: descriptive block name. Value: exact existing file path selected through the editor.

Behavior. The included text is exported verbatim at the conditional location.

Example
NO alarmActive followed by INCLUDE FILE named customAlarm using an existing alarm source file.

Resulting value or state. The supplied file contents execute under the alarmActive condition.

Note. The project depends on the selected external file. Preserve it when moving the project.

INCLUDE INIT – Initialization include file

Purpose. Includes customer-supplied text/source verbatim in the startup area.

Fields. Label: descriptive block name. Value: exact existing file path.

Behavior. The contents are placed before repeated ladder scanning.

Example
INCLUDE INIT named startupDefinitions using an existing initialization file.

Resulting value or state. The supplied initialization content is included once in the exported program.

Data and diagnostics

PRINT – Print text or string

Purpose. Prints quoted text or a string variable when the rung is true.

Fields. Label: quoted text such as "Ready" or a B9X Basic string variable such as message$.

Behavior. Printing occurs during every scan for which the rung remains true.

Example
↑ startButton followed by PRINT with Label "Cycle started".

Resulting value or state. The message is printed once for the rising-edge event.

Note. Use an edge or one-shot to prevent repeated lines from a continuously true rung.

PRINT DBL – Print numeric value

Purpose. Prints a numeric variable when the rung is true.

Fields. Label: numeric variable name.

Behavior. The current numeric value is printed each time the action executes.

Example
↑ sampleButton followed by PRINT DBL temperature.

Resulting value or state. The current value of temperature is printed once per button transition.

SET DBL – Set numeric variable

Purpose. Assigns a numeric value or expression to a numeric variable.

Fields. Label: numeric variable name. Value: number or supported numeric expression.

Behavior. The assignment is performed whenever the rung condition is true.

Example
NO recipe2Selected followed by SET DBL targetTemperature with Value 72.5.

Resulting value or state. targetTemperature becomes 72.5.

SET STR – Set string variable

Purpose. Assigns text to a string variable.

Fields. Label: string variable. For B9X Basic use a trailing dollar sign, for example message$. Value: text to assign.

Behavior. The string assignment occurs whenever the rung is true.

Example
C DN NO batchCount followed by SET STR message$ with Value Batch complete.

Resulting value or state. message$ contains "Batch complete".

Note. For Arduino export, the editor adapts the string name to the target naming rules.

Editor and Project Commands

CommandPurpose
ApplyStores edits made to the selected element.
DeleteRemoves the selected element.
ClearClears the current editable rung.
Add RungAdds a new rung to the project.
Delete RungRemoves the selected rung.
Move Up / Move DownMoves the selected rung by one position.
Move To Top / Move To BottomMoves the selected rung to the first or last position.
Delete BranchRemoves the selected branch contact from its parallel group.
Apply Rung CommentStores the text in the rung comment field.
VariablesShows the variables and state names used by the current project.
Rungs PreviewShows a read-only overview of all rungs.
Save AppSaves the editable ladder project.
Load AppLoads a previously saved ladder project.
Export B9X Basic .basCreates B9X Basic source from the ladder project.
Export Arduino .inoCreates a readable Arduino sketch.
Export Compressed Arduino .inoCreates a compact Arduino sketch.

Export Reference

B9X Basic

Export B9X Basic .bas creates a B9X Basic program. String names use a trailing dollar sign. PRINT accepts quoted text or a string variable; PRINT DBL prints a numeric variable.

Arduino

Export Arduino .ino creates a readable sketch. Export Compressed Arduino .ino creates a compact sketch. Include content must be valid for the selected target.

Rung limit

Export is cancelled if the project exceeds the configured rung limit.

Programming Patterns and Examples

Start/stop seal-in motor

  1. Rung 1: Branch NO startButton and B Coil NO motorRelay in the same parallel group; place the StopHealthy condition in series; finish with OUT motorRelay.
  2. Operation: pressing Start turns on motorRelay. Its state contact holds the path after Start is released. Removing StopHealthy breaks the series path and turns the motor off.
  3. Review: confirm the actual stop circuit produces the intended logical level and use suitable hardware for safety functions.

Five-second delayed output

  1. Rung 1: NO enableSwitch followed by TON readyDelay, Value 5000.
  2. Rung 2: T DN NO readyDelay followed by OUT readyLamp.
  3. Operation: readyLamp turns on after enableSwitch remains true for five seconds and turns off when normal TON timing is cleared.

Ten-part batch counter

  1. Rung 1: ↑ partSensor followed by CTU partCount, Value 10.
  2. Rung 2: C DN NO partCount followed by SET batchComplete.
  3. Rung 3: NO resetButton followed by C RST partCount.
  4. Rung 4: NO resetButton followed by RST batchComplete.
  5. Operation: each accepted part edge counts once. The completion state latches at ten and the reset button clears both counter and latch.

Temperature-controlled heater with hysteresis

  1. Rung 1: TEMP roomTemperature; use < roomTemperature with Value 68 followed by SET heaterDemand.
  2. Rung 2: > roomTemperature with Value 72 followed by RST heaterDemand.
  3. Rung 3: Coil NO heaterDemand followed by OUT heaterRelay.
  4. Operation: the heater turns on below 68 and stays on until temperature rises above 72. The four-degree separation prevents rapid switching near one threshold.

Mutually exclusive outputs

  1. Use separate step/state conditions for each OUT coil.
  2. Add Coil NC contacts for every conflicting output when an additional interlock is needed.
  3. Verify each possible state, including startup and reset, and confirm that no two output conditions can be true during the same scan.

Design Rules and Safety

  • Write a clear comment for every rung.
  • Use GPIO only for actual physical I/O.
  • Use edges or ONE SHOT for actions that must occur once.
  • Avoid duplicate OUT writers.
  • Give every SET state a reset path.
  • Use hysteresis for analog switching.
  • Define startup and reset behavior.
  • Review rung order and mutually exclusive outputs.
  • Use appropriate electrical drivers and protection.
  • Do not use ordinary software logic as the only personnel-safety system.

Troubleshooting

SymptomChecks
Output never turns onTrace every series group; verify active levels, labels, thresholds, GPIO, and duplicate writers.
Output stays onCheck for SET without RST, a seal-in branch, TOF delay, or an unconditional rung.
Counter counts too quicklyUse a rising edge or ONE SHOT and appropriate debounce.
Print repeatsTrigger PRINT with an edge or ONE SHOT.
Timer does not completeVerify the condition remains true, the preset is milliseconds, and reset is not continuously active.
Wrong branch behaviorSame-group contacts are ORed; separate groups are ANDed.
Export is blockedReduce rung count or use a configuration that permits the project size.

Glossary

TermDefinition
ActionAn element that changes or uses program state.
BranchA parallel OR path.
CoilAn output or internal Boolean state.
ContactA true/false condition.
DebounceA time filter for an input transition.
DoneA completion state.
GPIOA physical input/output pin.
PresetA configured duration, count, threshold, or size.
RungOne horizontal ladder condition and action.
ScanOne top-to-bottom program evaluation.
TagA symbolic program name.

Back to top