Skip to content

SQL — Sequencer Load

Category
Shift / Sequencer
Type
Output
Availability
All platforms

SQL instruction block: File Learned, Source Teach_Val, Length 4, Position, with DN indicator


SQL (Sequencer Load) fills a sequencer table from live values, one step per rung edge. Each time its rung goes from false to true it advances the position and copies Source into the array element at that position. Use SQL to teach a machine: run a good cycle by hand, advance the SQL at each step, and the table that an SQO or SQC will use is recorded without typing it. Do not confuse the mnemonic with a database query; here it means Load.


Operand Type Format Valid Range Required Description
Control CONTROL tag Tag or Tag[n] One SQL per control tag Yes Holds LEN, POS and the status bits.
File INT or DINT array tag Tag At least Length + 1 elements Yes The table being recorded; element 0 is the parked position and is never written.
Source INT or DINT tag, member, element or literal Tag, 25 Any Yes The value recorded at each step.
Length Whole number 4 1 to array size − 1 Yes Number of steps.
Position Whole number 0 0 to Length No Starting position at power-up.

There is no mask; the whole Source word is stored.


LEN is loaded from Length and POS from Position. The table is not written.

EN is cleared. Nothing advances.

On the scan the rung turns true, POS advances by one, wrapping from Length to 1, and Source is written to File[POS]. DN is set while POS equals Length.

Nothing.

Condition EN DN POS File
Power-up 0 0 Position (usually 0) holds
Rung false 0 holds holds holds
False → true 1 POS = LEN +1, wrapping LEN → 1 File[POS] = Source
Held true 1 holds holds holds
RES on the control 0 0 0 holds

Bit Mnemonic Data type Set by Cleared by Operation description
Enable .EN BOOL The rung being true The rung being false, or RES Mirrors the rung condition.
Enable unload .EU BOOL Never RES Reserved.
Done .DN BOOL POS reaching LEN The next advance, or RES The last step has been recorded.
Empty .EM BOOL Never RES Not used by SQL.
Error .ER BOOL Never RES Reserved. Bad operands are refused at validation.
Unload .UL BOOL Never RES Not used by SQL.
Inhibit .IN BOOL Never RES Reserved.
Found .FD BOOL Never RES Not used by SQL.
Length .LEN INT Length at power-up Never (RES preserves it) Number of steps.
Position .POS INT Each advance RES (to 0) The step just recorded.

Scenario: A setter walks a new product through the four stations and records the required dwell at each one. The value typed into Teach_Val is captured into the table at each teach button press.

Tags:

  • Seq_Teach — Teach button, BOOL
  • Learned — Recorded table, INT[5]
  • Teach_Val — Value to record, INT
  • SQL_Ctl — Control, CONTROL, Length 4

Rung 1:

—] [Seq_Teach———[SQL SQL_Ctl Learned Teach_Val 4]———

Scan 1 — Seq_Teach = 0. Teach_Val reads 25. Position 0, the table untouched. The SQO and SQC rungs above are their own pages’ examples.

Figure 1 — SQO, SQC and SQL rungs false: SQL File Learned all 0, Source Teach_Val 25, Length 4, Position 0

Scan 2 — Seq_Teach = 1. Position advances to 1 and Learned[1] becomes 25. The File list under the operand is trimmed in the middle, so the 25 shows as 2…; the Tag Browser shows the full element.

Figure 2 — SQL rung true after one edge: Learned list changed, Position 1, SQL rung lit; SQO and SQC above at position 1

Change Teach_Val and press again for steps 2, 3 and 4; DN lights on the fourth. The table is then ready for an SQO with the same Length.


Error definitions

.ER cause Condition that sets it .POS / status value Meaning
None .ER is never set by LadderIDE — A File that is not an INT/DINT array, or a Length of array size or more, is refused at validation.

Troubleshooting hints

Symptom: Element 0 of the table never changes. Likely cause: Position 0 is the parked position; the first advance writes element 1. Fix: That is intended. Leave element 0 as a placeholder.

Symptom: The recorded values are one step off. Likely cause: The teach press happened before the value was updated on the same scan. Fix: Update Source on the scan before the teach rung, or drive the SQL from the value-change itself.


  • SQO — Sequencer Output (play the table back)
  • SQC — Sequencer Compare (check against the table)
  • COP — Copy File (copy a taught table into a recipe array)
  • Shift/Sequencer Instructions — Category index

Retention. The table lives in an ordinary array tag, so it survives only as long as the controller is powered unless the project stores it as the tag’s literal.

The block colours neutral. Watch the rung wire, the Position row and DN.

Applies to LadderIDE >=1.2.2 · Last reviewed 2026-09-11 · Screenshots verified 2026-09-11