> For the complete documentation index, see [llms.txt](https://help.qtech.co.nz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.qtech.co.nz/datran/datran-vi-scada/datran-dlp-ide/ladder-editor.md).

# Ladder editor

Draw a DLP as ladder logic: rungs, input and output points, functions, labels and OR rungs. Open an existing DLP as ladder.

The ladder editor lets you draw a DLP as ladder logic, much like programming a PLC. When you build a ladder file, the DLP IDE converts it to source code, then builds the DLP. The ladder editor uses the same instructions as the [source editor](https://help.qtech.co.nz/datran/datran-vi-scada/datran-dlp-ide/source-editor.md).

![The ladder editor with a new ladder file. The three text rungs PROGINIT, PROGSTART and PROGEND are always there.](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FpEeuTmQV1vsQ9SbP8nhJ%2Fdlp-ide-ladder-editor-window.png?alt=media)

## How the ladder editor works

A ladder is made of rungs. Each rung is one piece of logic, usually ending with a digital output or a value written to an analogue point. To add something, select the place on the ladder where you want it, then click the button for the component on the component toolbar. You can drag the toolbar wherever suits you.

There are seven components:

| Component            | What it is                                                                        |
| -------------------- | --------------------------------------------------------------------------------- |
| Rung                 | One piece of logic. You can only delete a rung when it's selected.                |
| Text rung            | A comment, or an instruction such as `EQU`, on its own line                       |
| Digital input point  | Tests a digital point: `TCE` (on) or `TCD` (off)                                  |
| Digital output point | Writes the result to a digital point: `EC`, `ECC`, `NOT EC`, `SETDIG` or `RESDIG` |
| Function point       | Any other instruction, such as a timer or a comparison, with its parameters       |
| Label point          | A jump destination                                                                |
| OR rung              | Up to five lines combined with `OR`, `NOR` or `XOR`                               |

### Rules the ladder editor follows

* There are three text rungs which cannot be edited or deleted. These are `PROGSTART`, `PROGINIT` and `PROGEND`.
* Components are always inserted directly after the current selection on the screen.
* Labels can only be inserted at the start of a rung.
* Only one `EC` or `NOT EC` can be on a rung. It is not possible to add additional points after an `EC` or `NOT EC`.
* It is advisable to place all `EQU`'s and `EQULAB`'s in the `PROGINIT` section of the ladder.
* There's no warning when you delete something, but you can undo it with **Ctrl+Z** or **Edit > Undo**.

## How ladder maps to source code

| In the ladder                     | In the source code                                 | Where it can go                                                                        |
| --------------------------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------- |
| An empty rung                     | `BEGIN` … `END`                                    |                                                                                        |
| Input point `[ ]`                 | `TCE point`                                        |                                                                                        |
| Not input point `[/]`             | `TCD point`                                        |                                                                                        |
| Output point `( )`, ends the rung | `EC point`                                         | Always situated at the end of a rung.                                                  |
| Output point, continues the rung  | `ECC point`                                        | Situated anywhere on the rung after the first digital input.                           |
| Not output point `(/)`            | `NOT` then `EC point`                              | Always situated at the end of a rung.                                                  |
| SETDIG output point               | `SETDIG point`                                     | Situated anywhere on the rung after the first digital input.                           |
| RESDIG output point               | `RESDIG point`                                     | Situated anywhere on the rung after the first digital input.                           |
| Function point (box)              | The instruction and its parameters                 |                                                                                        |
| Label point (box)                 | The label name                                     | Start of a rung                                                                        |
| OR, NOR or XOR rung               | `OR` … `OREND`, `NOR` … `NOREND`, `XOR` … `XOREND` | Up to 5 lines. Each line is one digital input, or a comparison of two analogue points. |
| Text rung                         | Copied across as written                           |                                                                                        |

When a ladder is converted to source code, each rung ends with `END`.

## Add a text rung

Text rungs hold comments, or instructions that usually go in the initialisation section: `COSMASK`, `EQU`, `EQULAB`, `INITANL`, `INITDIG`, `TELINP` and `TELOUT`.

![The text rung dialog, with the predefined instructions on the left](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2Fp6jeYx8kheip5zygIfzx%2Fdlp-ide-ladder-text-rung.png?alt=media)

1. Select the rung that the new text rung should follow.
2. Use the **Insert text rung** button on the component toolbar.
3. Choose the type:
   * **Predefined:** select the instruction and click **OK**. If it needs parameters, enter them, or use the **\[...]** button to pick them, and click **OK**.
   * **Comment or other:** type the comment. To enter a line of source code instead, delete the `;` and type the code. Click **OK**.

The text rung will display on the ladder after the last selected rung.

* **To edit it:** select it and click **Edit text rung**. Change the text or choose another instruction, and click **OK**.
* **To delete it:** select it and click **Delete text rung**, or press **Delete** or **Backspace**.

## Add an input point

Input points are always digital. Choose `TCE` to test that the point is on (AND), or `TCD` to test that it's off (NAND).

![The input point dialog](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FXVRHgGnfRYOmMncBkpCc%2Fdlp-ide-ladder-input-point.png?alt=media)

1. Select the rung, or the point the new one should follow.
2. Click **Insert input point**.
3. Select the type of input required. Then select the input point you require by using the **\[...]** button. Click **OK**.

To change a point, select it and click **Edit point**. To delete it, select it and click **Delete point**, or press **Delete** or **Backspace**.

## Add an output point

Output points are always digital.

| Output       | What it does                                                                                            |
| ------------ | ------------------------------------------------------------------------------------------------------- |
| `( )` EC     | Always displayed at the end of a rung. Copies the accumulator to a digital I/O. Clears the accumulator. |
| `(->)` ECC   | Copies the accumulator to a digital I/O and leaves the result in the accumulator.                       |
| `(/)` NOT EC | Inverts the accumulator and copies this to a digital I/O. Clears the accumulator.                       |
| SETDIG       | Tests the accumulator and sets the digital I/O to true if the accumulator is true.                      |
| RESDIG       | Tests the accumulator and sets the digital I/O to false if the accumulator is true.                     |

![The output point dialog](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FFr4jD1rYoL0ikhxFDSds%2Fdlp-ide-ladder-output-point.png?alt=media)

1. Select where the point should go.
2. Click **Insert output point**.
3. Select the output type required. Then select the output point you require by using the **\[...]** button. Click **OK**.

After an `EC` or `NOT EC`, you can't add more points to the rung. If you add a label, it goes at the start of the rung.

## Add a function

Use the **Fx** button for any other instruction, such as a comparison, arithmetic, a copy or a timer.

![The function dialog, with ADDR selected and its two parameters below](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2Fs08psy5Ywntzrjbm4z2G%2Fdlp-ide-ladder-function.png?alt=media)

1. Select where the function should go.
2. Click **Insert function**.
3. Find the instruction: use the up and down buttons, type its first letter, or click **\[...]** to pick it from a list.
4. Check the name, then fill in each parameter. Where there's a **\[...]** button, use it to pick the point.
5. Click **OK**.

## Add labels and jumps

Labels are only used with jumps. A jump skips the rungs between it and the label.

| Jump    | When it jumps                 |
| ------- | ----------------------------- |
| `JUMPA` | Always                        |
| `JUMPT` | When the accumulator is true  |
| `JUMPF` | When the accumulator is false |

There are 255 standard labels, `Label1` to `Label255`. To give one a meaningful name, the ladder editor adds an `EQULAB` text rung after `PROGINIT`.

![The label dialog, with Create New, Set New and Set Existing](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FbPimJzXpOJkNeM8SPy1y%2Fdlp-ide-ladder-label.png?alt=media)

**To name a label and place it:**

1. Select the rung where the jump should land.
2. Click **Insert label**.
3. Choose a label type:
   * **Create New:** will only put an `EQULAB` function in the `PROGINIT` section of the current ladder.
   * **Set New:** will create an `EQULAB` function in the `PROGINIT` section of the current ladder and then insert the label in the current position.
   * **Set Existing:** insert an existing label into the current position.
4. Select an existing label using the **\[...]** button. Then type the new label name. Click **OK**.

**To add the jump:**

1. Select where the jump should go.
2. Click **Insert function**, then select `JUMPA`, `JUMPT` or `JUMPF` (type **J** to get there quickly).
3. Click **\[...]** to pick the label, and click **OK**.

![A JUMPA to NewLabelName, placed before the label](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FXV0pgiBaWkemHslM5ewc%2Fdlp-ide-ladder-jump-example.png?alt=media)

Rules for labels:

* A label needs to be declared before a jump statement. It is advisable to set up a label first, and then jump to them using jump statements. Only the default labels from `Label1` to `Label255` can be used if you try to create a jump to a label before giving the label an appropriate name using `EQULAB`.
* Jump statements to a label must be placed before the label statement. If the label is placed before the jump statement, compiling the ladder will cause a compiler error to occur.
* Do not use dashes '-' in the label name. However, for compatibility with older ASM files, if a dash exists in the name already, the ladder editor will convert this to an underscore before displaying it on the screen.
* If you rename a label, the old name becomes a comment throughout the source code. Use the source editor's search (**Ctrl+F**) to find where it's used.

To change a label on the ladder, select it and click **Edit point**. To rename it, select its `EQULAB` text rung and click **Edit text rung**.

## Add an OR rung

![The OR rung dialog, with up to five lines](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2Flr54qHxTlb7Fu7kZomV6%2Fdlp-ide-ladder-or-rung.png?alt=media)

1. Select the point the OR rung should follow.
2. Click **Insert OR rung**.
3. Select the type: **OR**, **XOR** or **NOR**.
4. For each line, up to five:
   * select the kind of input point (**TCE** `[ ]` or **TCD** `[/]`) and select the point using the **\[...]** buttons, or
   * select an analogue comparison, and pick the two points to compare.
5. Click **OK**.

To change it, select it and click **Edit OR rung**. To delete it, select it and click **Delete OR rung**, or press **Delete** or **Backspace**.

## Pick a point

Every **\[...]** button opens a list of the points that suit the current task. Select one and click **Select** (**Alt+S**). If a number is highlighted after you select it, type the point number you want.

## Move around the ladder

* Use the arrow keys or mouse wheel to easily move around the ladder. The keypad on your keyboard allows for easy navigation around the ladder.
* The **Page Up** and **Page Down** keys make scrolling fast.
* The **Delete** and **Backspace** keys will delete the currently selected object on the screen - be that a point or a rung.
* To go to a rung, use **Go To Line Number** and enter the rung number.
* The status bar shows the position of the currently selected rung or point, the current modified status of the ladder file currently viewed and the description of any I/O where the mouse cursor is hovering over.

### Naming points and labels

There are some naming conventions to be aware of when using `EQULAB` (naming labels) and `EQU` (naming points):

* Never include spaces in the name.
* Never use dashes in the name - these convert to underscores if they are used.
* Try to make each name as unique as possible to reduce ambiguity.

### Colours and fonts

You can't change the border and fill colours of points. You can change the font, size and text colour in **Tools > Editor Options**. Use a font size of at least 8 so you can read the whole ladder.

## Open an existing DLP as ladder

You can save an existing DLP file as a ladder file. This is great for both training and project documentation.

![A DLP shown as source code on the left, and the same DLP as ladder logic on the right](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FCXAUaqI9lAetCtKtA925%2Fdlp-ide-dlp-to-ladder.jpg?alt=media)

1. Open the existing DLP file. See [Read a DLP back from an RTU](https://help.qtech.co.nz/datran/datran-vi-scada/datran-dlp-ide/compile-and-load.md#read-a-dlp-back-from-an-rtu).
2. Select **File > Save As** and select the Ladder type from the drop-down list.

![The Save As dialog, with Ladder logic file (.ldr) selected](https://3621580088-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fa5hMAUl7E1cWeN5Rghg0%2Fuploads%2FlaU6kiOUV6tlFzAEvMGL%2Fdlp-ide-save-as-ladder.png?alt=media)

## Menus

| Menu   | What it's for                                                                                                                     |
| ------ | --------------------------------------------------------------------------------------------------------------------------------- |
| File   | Allows you to open new files, close files and print files.                                                                        |
| Ladder | Allows you to insert points, just like the component tool bar.                                                                    |
| Build  | Allows you to build the currently displayed ladder. This internally converts the ladder to ASM code. It then builds the DLP file. |
| Tools  | Allows you to set properties.                                                                                                     |
