Awlsim: S7 compatible PLC / SPS
Image preview of awlsimgui.png

Awlsim is a free Step 7 compatible Programmable Logic Controller, that supports the automation languages AWL/STL and FUP/FBD. Awlsim itself is written in Python. The speed of execution ranges from several ten thousand AWL/STL instructions per second on slow embedded machines to a couple of million instructions per second on faster computers. German and English S7 AWL/STL mnemonics are supported.

AWL/STL programs on PLCs are used for automation of industrial processes. However Awlsim is very flexible, so it can be used for other purposes beyond industrial applications, too. Awlsim aims to be compatible with the industry standard S7 software on the AWL/STL level.

Image preview of awlsim-on-pixtend.jpg

Awlsim can emulate CPUs with two and four accumulator registers (S7-3xx and S7-4xx).
Compatibility to S7 hardware is a task taken seriously by the Awlsim project. We want to be as close as possible to the real PLC hardware with our AWL/STL code execution. For this reason Awlsim ships an extensive selftest suite. Missing features and differences between Awlsim and Step 7 are documented in the and files. If you find any undocumented bugs and incompatibilities to a real PLC CPU, please contact me.

Awlsim is Open Source Free Software licensed under the GNU General Public License v2+. That means it's available in full source code and you are encouraged to improve it and contribute your changes back to the community. Awlsim is free of charge, too.

The Windows standalone package runs without installing anything and without admin privileges.

More documentation in addition to this website can be found in the documentation files generated from the source package. Older versions of the generated packages can be found here

Awlsim is stable/production quality software.
That means its features are well tested and the remaining amount of bugs probably is minor. The software does include a reasonable amount of documentation.

The execution speed of the AWL/STL (or FUP/FBD) program highly depends on the machine Awlsim is being executed on, of course. It also depends on the Python interpreter that is being used.
Awlsim supports Python high speed techniques such as Cython and PyPy.

But what does that mean? Numbers, please!

AWL/STL program Hardware Average time per instruction Instructions per second Python interpreter
EXAMPLE.awlpro RaspberryPi 4 ~0.6 µs ~1,600,000/s Cython
benchmark-raspberrypi.awlpro RaspberryPi 4 ~0.4 µs ~2,500,000/s Cython
EXAMPLE.awlpro PC hardware
(Intel i5-3320M)
~0.55 µs ~1,800,000/s PyPy
EXAMPLE.awlpro PC hardware
(Intel i5-3320M)
~0.34 µs ~2,950,000/s Cython

These numbers are valid for the latest version of Awlsim.
The actual AWL/STL instructions that are being run also affect the speed. Some instructions are slower than others. That means your speed might differ depending on the instructions of your AWL/STL program.

Support for FBD/FUP is included in the latest Awlsim release.
There is support for the following FUP operations:

There is no LAD/KOP editor and compiler available in Awlsim, yet.

There is no ST/SCL editor and compiler available in Awlsim, yet.

The preferred way to run Awlsim on MS Windows is to use the standalone package:
awlsim-win64-x.y.package.exe (See Download).

Just extract the standalone .exe package by double clicking it and selecting 'extract'. Double click on the file awlsim.cmd that appears in the extracted directory to start Awlsim.
There usually is no need to install anything. Windows will probably ask you (twice) to confirm that you trust the program being run.


If you want to build and run Awlsim from source .tar.xz package (you most likely don't), you need the Python package and either PyQt5 or PySide2:

Please install Python to its default install location. Afterwards install PyQt5 using the pip3 tool that comes with Python. PyQt5 is part of PyPi.
Awlsim ships a convenience shell script to install PyQt5. Just go into the maintenance subdirectory of the Awlsim package and double click on the win-install-dependencies.cmd file. This script will download PyQt5 from PyPi and install it.

To run Awlsim just double click on the awlsim-win.cmd file. The graphical user interface of Awlsim should appear. If you did not install a dependency correctly, or if there is any other problem, an error message will be printed to the console window that also appears.

Awlsim runs on any platform that supports Python and either PyQt5 or PySide2, which includes Linux and Mac OS X. Just run the main Awlsim scripts like awlsim-server or awlsim-client. All scripts include a shebang, so you don't need to specify the Python interpreter explicitly.

See the PiLC page for more information on how to run Awlsim on a Raspberry Pi or similar hardware.

Awlsim runs on Python 2.7 and Python 3.4 or later (C-Python).

The Awlsim core and thus the command line interface 'awlsim-cli' and the core server 'awlsim-server' also run on these alternative Python interpreters:

It is possible to compile the Awlsim core and coreserver with Cython. Cython is an optimizing static compiler for the Python language.
If Cython is installed, the ./ build run will also build the optimized Awlsim package in addition to the standard Python modules. The package will be called awlsim_cython, so both the optimized build and the original Python-code can be installed simultaneously.
To use the awlsim_cython core, set the AWLSIMCYTHON environment variable to 1 before running Awlsim. For example run awlsim-cli like this:
This will also work with awlsimgui.
Using the compiled awlsim_cython core will result in a performance gain of about 50 percent, compared to the pure Python core.

A hardware module for the PiXtend v1.3 hardware is included in Awlsim. So the PiXtend I/Os (Relays, digital inputs, digital outputs, analog inputs, GPIOs) can be used.

Awlsim includes an experimental hardware access layer for connecting the Awlsim S7-CPU to real PROFIBUS-DP slave hardware. It does this by providing an interface to the Raspberry Pi PROFIBUS module.

The hardware access layer module is loaded and executed with the new -H command to awlsim-cli.
For example: awlsim-cli -D -H pyprofibus program.awl
The pyprofibus module has some module options. See the --help and --hardware-info pyprofibus options to awlsim-cli for details.

The pyprofibus module is highly experimental at this time. It lacks a lot of flexibility, but it does work.

Needless to say, the Raspberry Pi PROFIBUS module must be installed before the Awlsim pyprofibus hardware access layer can be used. Otherwise to following error will occur:

  [PyProfibus hardware module] Failed to import PROFIBUS protocol stack module 'pyprofibus':
    No module named 'pyprofibus'

A LinuxCNC HAL module is included in Awlsim. With this module it is possible to use Awlsim as a non-realtime S7-compatible PLC backend.

Image preview of awlsim-linuxcnc.png

To use Awlsim in LinuxCNC, a HAL configuration file has to be added to your LinuxCNC configuration. See the LinuxCNC Integrators Manual on how to add HAL-files. An example LinuxCNC project is included in the Awlsim package as examples/linuxcnc-demo/
See awlsim.hal in this directory for additional information.

If you want to get the latest development version of Awlsim, or if you want to contribute to Awlsim, all information can be found on the Awlsim development page.

Thanks to everybody testing Awlsim and reporting bugs and differences between Awlsim and the original Step 7 AWL/STL language implementation. Also thanks to everybody providing example AWL/STL code and test cases for the testing suite.

Thanks to the lecturers at Balthasar Neumann Technikum Trier for their fine lectures in PLC automation. Those in particular are Mr. Etringer, Mr. Kronenburg, Mr. Laub et al., in lexicographical order.

Copyright (C) Michael Büsch et al.
Licensed under the terms of the GNU General Public License version 2 or (at your option) any later version. See the sourcecode for details.

Updated: Wednesday 17 April 2024 17:44 (UTC)
xhtml / css