Testing

Unit tests for LAD and SCL blocks on PLCSIM Advanced

A block that compiles can still do the wrong thing. Coilmind keeps tests next to the project, runs them on PLCSIM Advanced and shows you which assertion failed. LAD blocks get the same treatment as SCL.

Start your 14-day free trial

A test run going from 0 passed, 2 failed to 2 / 2 pass. Taken from the full recorded session.

Why a clean compile proves less than it seems

The compiler checks types, operands, interfaces and calls. It does not check what the block does over time. The classic cases all compile without a warning:

  • ›A TON instance called only inside an IF branch, so the timer stops being evaluated when the condition drops and never resets the way you expected.
  • ›An edge detection (R_TRIG or P_TRIG) inside a CASE branch that is not active on every cycle, so the edge is missed.
  • ›A latch that sets correctly but whose reset sits in a network that never runs in the state you care about.
  • ›An output that is right after one cycle and wrong after ten, because a value carries over between cycles.

All of these only show up when the block runs for several cycles with real input changes. That is what a test on the simulator does.

How a test is built

Tests live in .test.json files that belong to the project. Each test sets inputs, runs the block for a number of cycles and checks the outputs. You can watch the values change while the test runs.

You can write a test yourself or ask Coilmind to draft the suite from a description of what the block should do. It then downloads to PLCSIM Advanced and runs the suite there.

1

Describe the behaviour, or point Coilmind at the block and its spec.

2

Coilmind drafts the test cases: inputs, number of cycles, expected outputs.

3

The block is downloaded to PLCSIM Advanced and the suite runs.

4

Failed assertions are listed, so you know which case to look at.

LAD blocks, not only SCL

Most test tooling around TIA Portal assumes SCL, because text is easier to reason about. The test runs against the compiled block on the simulator, so the language it was written in does not matter: a LAD block with timers, counters and latches is tested the same way as an SCL one.

This is also how a rewrite of legacy STL is checked: the original’s tests are run against the new SCL or LAD block, and they have to pass the same way.

Simulator only

Coilmind downloads to PLCSIM Advanced and nowhere else. It never downloads to real hardware, so a test cannot move an actuator on a running machine.

What you need

  • ›TIA Portal V17 to V21 on Windows, with the project open.
  • ›PLCSIM Advanced V3 to V6. Siemens sells it separately; Coilmind does not include it.
  • ›Any Coilmind plan. Tests are part of the product, not an add-on.

Common questions

Do I need PLCSIM Advanced, or does the regular PLCSIM work?

PLCSIM Advanced, versions V3 to V6. It is a separate purchase from Siemens. Without it Coilmind still writes, imports and compiles blocks, but it cannot run tests.

Can it test LAD blocks?

Yes. The test runs against the compiled block on the simulator, so LAD, SCL and blocks rewritten from STL are all tested the same way.

Can a test write to a real PLC?

No. Coilmind downloads to PLCSIM Advanced only, never to real hardware.

Where are the tests stored?

In .test.json files that belong to the project, so they stay with it and can be run again after the next change.

Does Coilmind write the tests for me?

It can draft a suite from a description of what the block should do. You review it like any other generated code, and you can edit or add cases by hand.

Run a test on your own block

Take a block you know, describe what it should do, and see whether it passes on PLCSIM Advanced.

Start your 14-day free trial