Topic: Prototype: simulating control circuits directly from .qet files

Hello everyone,

I'm Tony, an instructor of industrial mechatronics at SENAI (Brazil). My students learn contactor-based control circuits, and most of them use CADe_SIMU on Windows to simulate them. There is no free equivalent on Linux, so I started a small experiment: a simulator that reads QElectroTech .qet files directly.

What works today (command-line prototype, Python, no dependencies):
- reads elements, conductors and master/slave links from the .qet XML
- simulates push buttons, coils and NO/NC contacts (self-holding, interlocking, stop)
- push button type (NO/NC) is inferred from IEC terminal numbers (13-14 / 21-22)

Example: reversing starter with interlock, drawn in QET 0.100.0:

> S1 -> K1 = ON, K2 = off
> S2 -> K1 = ON, K2 = off (interlock blocks K2)
> S0 -> K1 = off, K2 = off
> S2 -> K1 = off, K2 = ON

Repository (GPL-3.0): https://github.com/tonymarim/qet-simulador
Two example .qet files are included.

Disclosure: the prototype was written with the help of an AI assistant (Claude). I reviewed it and tested it with my own circuits.

Some questions for the community:
1. Has anyone worked on simulation on top of .qet files before? I don't want to duplicate effort.
2. Is relying on master/slave links plus IEC terminal numbering a sound approach? Or is there a more reliable way to identify NO/NC push buttons in the element definitions?
3. Would there be interest in this eventually becoming a plugin, like qet_tb_generator?

Any feedback is welcome. And thank you for QElectroTech!

Tony

Re: Prototype: simulating control circuits directly from .qet files

Hi Tony, and welcome!

Nice work!

  1. As far as I know there's no circuit simulation in or around QET today, so this fills a real gap, especially for teaching.

  2. Master/slave links are the right foundation — that's exactly how QET models the relationship. For slave contacts, you can also read state (NO/NC/SW) and type (simple, power, delayOn, delayOff) from the element's kindInformations in the .qet/.elmt XML: more reliable than terminal numbers, and it gives you timers for free. For push buttons (simple elements without that info), IEC terminal numbering is a reasonable fallback, but not everyone numbers terminals, so maybe also check the element name/informations.

  3. Yes, an external plugin in the spirit of qet_tb_generator would be welcome — keeping it outside the core is the best approach.



Laurent

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Prototype: simulating control circuits directly from .qet files

Hi Laurent,

Thank you for the welcome and for the very useful answer!

Your suggestion about kindInformations was spot on. Contacts are already identified by state and type from kindInformations, and timers came almost for free, as you said:

1. Timers. On-delay and off-delay contacts (delayOn / delayOff) are now supported. QET has no field for the time value, so the simulator uses 5 s by default, accepts a command to change it ("tempo KT1 3"), and also reads a value like "5s" written in any text field of the coil. Time is simulated: "t 5" advances 5 seconds, so a class can stop at second 4 and ask what happens next.

2. Star-delta. The classic star-delta starter now simulates correctly:

t=0.0s  S1  ->  K1, KT1, K2 (star) ON
t=5.0s      ->  K2 OFF, K3 (delta) ON   (never both at the same time)
t=5.0s  S0  ->  all OFF

The simulator also caught two mistakes in my own drawing: a timed contact linked to the wrong coil, and the star contactor energized with the motor stopped. For teaching, that alone was worth it.

3. A small fix to the collection. While doing this, I found that con_simple_tmp_r.elmt (NO off-delay) had the same EN/ES/PT name as con_simple_tmp_t.elmt (NO on-delay), "switch-on delay", so the two cannot be told apart in those languages. I opened a PR with the fix:
https://github.com/qelectrotech/qelectr … ts/pull/98

For push buttons, I will add your suggestion of also checking the element name/informations when the terminals are not numbered. And I agree that it should stay an external plugin, outside the core.

Repository, now with four example circuits: https://github.com/tonymarim/qet-simulador

Thanks again,
Tony

Re: Prototype: simulating control circuits directly from .qet files

Hi everyone,

A bigger update: the simulator now has a graphical version that runs in the browser, and you can try it without installing anything:

https://tonymarim.github.io/qet-simulador/

You open a .qet file and the folio is drawn as in QElectroTech. Wire routing and junction dots follow QET's own conductor code (generateConductorPath and junctions), translated to JavaScript. Then you simulate directly on the drawing:

- press and hold a push button (Shift+click latches it); click the circuit breaker to switch it on/off, or the thermal relay to simulate an overload
- live wires turn red (phase) or blue (neutral); energized coils and operated contacts are highlighted
- the motor shows its direction of rotation; missing phase and short circuits are flagged, and the breaker trips by itself on a phase-to-phase short
- on-delay and off-delay timers run in real time, with an adjustable time

There is an "example" menu with six circuits: DOL and reversing starters (control and power), timed start and star-delta. The .qet file never leaves your computer: everything runs locally in the browser, and the page also works offline if you download it.

The command-line Python version is still there and is used as a reference: both engines must give identical results on the same test scenarios.

Tested on Windows (QET 0.100) and Ubuntu (QET 0.200, Flatpak), in the browser.

Current limits: only the first folio of multi-folio projects is shown, and 6-terminal motors (star-delta power circuit) are not supported yet.

Feedback is very welcome, especially circuits drawn in ways I haven't thought of.

Note: the simulator reads .qet files only; projects saved as .qetz need to be saved as .qet first.

Tony