Giter Club home page Giter Club logo

awlsim's Introduction

Awlsim - S7 compatible Programmable Logic Controller (PLC/SPS)

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 latest version of Awlsim can be downloaded at the official Awlsim site.

Main git repository

Github / issue tracking / pull requests

Awlsim - Programmable Logic Controller (PLC/SPS)

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.

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.

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 COMPATIBILITY documentation and TODO documentation files.

Quick start tutorial

See the quick start tutorial for a simple example on how to use Awlsim in simulator mode. In simulator mode Awlsim can be run on any desktop PC. No special hardware is required.

Example project

If you don't know where to start, you can find an example project in the examples directory as EXAMPLE.awlpro. You can easily run this example in simulation mode without the need for special hardware.

Git repository

The latest development version of Awlsim can be fetched with git:

git clone https://git.bues.ch/git/awlsim.git
cd awlsim

After cloning the main repository the git submodules must also be fetched. The following helper script can be used:

./maintenance/update-submodules

Dependencies

Awlsim depends on

These packages can be installed with pip:

pip3 install --upgrade PyQt5
pip3 install --upgrade cffi

If building and using Awlsim with Cython acceleration is desired, Cython must also be installed:

pip3 install --upgrade Cython

On Windows all Awlsim dependencies can be installed by double clicking the shipped installer script: maintenance\win-install-dependencies.cmd

For Debian Linux users the script maintenance/deb-dependencies-install.sh installs all required and optional runtime and build dependencies.

Directory structure

The Awlsim Git repository and source archive awlsim-x.yz.tar.bz2 contain lots of files and directories. Here is an overview of the main files and directories and their purpose:

Main executables

User interface executables. The main user executable is awlsim-gui.

.  awlsim-client             : Command line client tool.
.  awlsim-gui                : Graphical user interface. This is the main user frontend.
.  awlsim-linuxcnc-hal       : LinuxCNC HAL module executable.
.  awlsim-proupgrade         : Command line tool to update .awlpro file formats.
.  awlsim-server             : Command line server tool.
.  awlsim-symtab             : Command line tool to parse symbol tables (.ASC).
.  awlsim-test               : Command line tool for unit testing.
.                              See tests/run.sh for execution of unit tests.
.  awlsim-win.cmd            : Windows wrapper for awlsim-gui.

Documentation

These files and directories contain useful information about Awlsim.

.  doc/                      : Main documentation.
.  doc/fup/                  : Awlsim FUP language and editor documentation.
.  examples/                 : Various example projects and feature demonstrations.
.  COMPATIBILITY.md|html     : S7 compatibility documentation.
.  COPYING.txt               : Main license.
.  DEVELOPMENT.md|html       : How to enhance and develop Awlsim.
.  QUICK-START.md|html       : Quick start tutorial.
.  README.md|html            : Main README document.
.  TODO.md|html              : TODO list.

Main modules

The main modules implement most of Awlsim's functionality.

.  awlsim/                   : Main Awlsim Python-module directory. This is where the magic happens.
.  awlsim/awlcompiler        : AWL compiler.
.  awlsim/awloptimizer       : AWL optimizer.
.  awlsim/common             : Common libraries, modules and helper functions.
.  awlsim/core               : AWL interpreter core. This is where the AWL program is executed.
.  awlsim/core/instructions  : Implementation of AWL instructions.
.  awlsim/core/systemblocks  : Implementation of SFCs and SFBs.
.  awlsim/coreclient         : Client library to connect to coreserver.
.  awlsim/coreserver         : Server library to provide AWL interpreter core access via networking.
.  awlsim/fupcompiler        : FUP compiler.
.  awlsim/gui                : Graphical user interface implementation (Qt).
.  awlsim/library            : AWL block (FC and FB) libraries.
.  awlsim/library/iec        : Implementation of IEC FCs and FBs.
.  awlsim_loader/            : Import wrapper for the main Awlsim Python-module.
.                              This is used to automatically load Cython optimized modules.
.  libs/                     : External libraries used for running or testing Awlsim.
.  progs/                    : External programs used in Awlsim.
.  submodules/               : Git submodules used for running Awlsim.
.                              See  man git-submodule  for general help about Git submodules.
.  submodules/pyprofibus/    : PROFIBUS-DP implementation.
.  tests/                    : Unit test cases.
.  tests/run.sh              : Main interface to run unit tests. Please see --help

Hardware support modules

The hardware modules are the glue between the Awlsim core and the real world. The hardware modules are invoked before and after running the user cycle (OB 1).

.  awlsimhw_debug/           : Hardware module for unit tests. Do not use in production.
.  awlsimhw_dummy/           : Dummy no-operation hardware module for testing, debugging or simulation.
.  awlsimhw_linuxcnc/        : LinuxCNC hardware support module.
.  awlsimhw_pixtend/         : PiXtend hardware support module.
.  awlsimhw_pyprofibus/      : PROFIBUS-DP hardware support module.
.  awlsimhw_pyprofibus.conf  : Configuration file for awlsimhw_pyprofibus.
.  awlsimhw_rpigpio/         : Raspberry Pi GPIO hardware support module.

Misc

.  awlsim-server.service     : Systemd unit for awlsim-server.
.  debian/                   : Debian packaging support.
.  maintenance/              : Maintainer scripts.
.  misc/                     : Miscellaneous scripts and files.
.  setup.py                  : Python package build script. This also builds the Cython modules.

FUP - Funktionsplan - Function block diagram

Awlsim supports programming in an S7-FUP like language. See the FUP documentation for more information about Awlsim's implementation of FUP.

Environment variables

The following environment variables control Awlsim's basic behavior:

  • AWLSIM_GUI
    =auto Automatically select the best GUI framework (default)
    =pyside Use PySide as GUI framework.
    =pyqt Use PyQt as GUI framework.

  • AWLSIM_CYTHON
    =0 Do not attempt to use Cython core (default)
    =1 Attempt to use Cython core, but fall back to Python
    =2 Enforce Cython core

  • AWLSIM_SCHED
    =default Do not change the scheduling policy. Keep the policy that was assigned to Awlsim by the operating system. (default)
    =normal Use the normal non-realtime OS scheduling.
    =fifo Use FIFO realtime scheduling (SCHED_FIFO).
    =rr Use Round-robin realtime scheduling (SCHED_RR).
    =deadline Use Deadline realtime scheduling (SCHED_DEADLINE).
    =realtime Use a realtime scheduling algorithm that performs best in most situations. The actual algorithm selection might change between Awlsim releases.

    The suffix -if-multicore can be appended to the options fifo, rr, deadline and realtime. That will trigger a fall back to normal, if the system is single-core (has only one CPU).

  • AWLSIM_PRIO
    =default Do not change the priority (default).
    =1-99 Set the scheduling priority. The meaning of the priority depends on the operating system and the selected scheduling algorithm. See AWLSIM_SCHED.

  • AWLSIM_AFFINITY
    =0,2,... Comma separated list of host CPU cores to run on. Default: all cores.

  • AWLSIM_MLOCK
    =0 Do not try to mlockall. See man 2 mlockall. (default).
    =1 Try to mlockall all current and future memory. See man 2 mlockall.
    =2 mlockall all current and future memory. Abort on failure. See man 2 mlockall.

  • AWLSIM_PROFILE
    =0 Disable profiling (default)
    =1 Enable core cycle profiling
    =2 Enable full core profiling (including startup)

  • AWLSIM_COVERAGE
    =DATAFILE Enable code coverage tracing.

  • AWLSIM_GCMODE
    =realtime Enable manual garbage collection, if realtime scheduling is enabled. (default)
    =auto Always use automatic garbage collection.
    =manual Always use manual garbage collection.

  • AWLSIM_GCTHRES
    =700,1,1
    A comma separated string with up to 3 integers.
    Each integer corresponding to the Python garbage collector generation 0 to 2 thresholds for manual garbage collection.
    A threshold value of 0 disables garbage collection. (not recommended)

  • AWLSIM_GCCYCLE
    =64
    The number of OB1 cycles it takes to trigger a manual garbage collection.

Environment variables during build (setup.py)

The following environment variables control Awlsim's build (setup.py) behavior:

  • AWLSIM_FULL_BUILD
    =0 Do not include scripts that are not necessary on this platform. (default)
    =1 Include all scripts; also those that aren't required on the platform.

  • AWLSIM_CYTHON_BUILD
    =0 Do not build any Cython modules. (default on non-Posix)
    =1 Build Cython modules. (default on Posix)

  • AWLSIM_CYTHON_PARALLEL
    =0 Do not use parallel compilation for Cython modules.
    =1 Invoke multiple compilers in parallel (faster on multicore). (default)

  • AWLSIM_PROFILE
    =0 Do not enable profiling support in compiled Cython modules. (default)
    =1 Enable profiling support in compiled Cython modules.

  • AWLSIM_DEBUG_BUILD
    =0 Do not enable debugging support in compiled Cython modules. (default)
    =1 Enable debugging support in compiled Cython modules.

Building Awlsim

Awlsim can be run from the source directory in interpreted Python mode without building it. Just cd into the Awlsim source directory and execute the desired main executable (e.g. ./awlsim-gui or ./awlsim-server etc...).

The accelerated Cython libraries can be built with the standard Python ./setup.py build command.

For convenience there also is a helper script ./maintenance/build.sh, which will do everything right to build Awlsim. That can be used instead of calling setup.py directly.

There also is ./maintenance/build-noopt.sh. That builds Cython modules without optimization. The build is much faster, but the resulting Cython libraries will be much slower. This is useful for development. Do not use this for production.

PiLC - The Raspberry Pi PLC

If you want to use PiLC, please also see the PiLC documentation.

Building Debian / Raspbian / PiLC .deb packages

Installing or upgrading Awlsim on a Debian based system is easy. The debuild can be used to build the .deb packages. Just run the following commands to build all Awlsim .deb packages:

cd path/to/awlsim                                 # Go to Awlsim source directory
sudo ./maintenance/deb-dependencies-install.sh    # This installs all dependencies
debuild -uc -us                                   # Build all Awlsim .deb packages
sudo ./maintenance/deb-install.sh ..              # Install or upgrade all Awlsim .deb packages

The .deb files will be put into the parent directory of the Awlsim source directory.

If you get the following build failure during build:

/usr/include/features.h:xxx:xx: fatal error: sys/cdefs.h: No such file or directory

this can be fixed by re-installing the libc development package:

sudo apt install --reinstall libc-dev

Development

Information about Awlsim development can be found in the Awlsim development documentation.

License / Copyright

Copyright (C) Michael Büsch / et al.

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.

awlsim's People

Contributors

mbuesch avatar rahix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

awlsim's Issues

AWL translation issues

I am not sure what to do about these issues, I'd like to use the AWL file as is but it is from the 90's and I'm not sure what may have changed since then. I've attached screenshots and the original AWL file

Screen Shot 06-11-21 at 07 09 PM 52
Screen Shot 06-11-21 at 07 14 PM 25
Screen Shot 06-10-21 at 06 05 PM 20
mill55awl.txt

awlsimhw_linuxcnc: Error on clicking "Add inspection: Online block"

An error occurs when the server passes an instance of hal to gui.

Traceback (most recent call last):
  File "/home/lcnc/awlsim/examples/linuxcnc-demo/../..//awlsim-linuxcnc-hal", line 438, in <module>
    sys.exit(main())
  File "/home/lcnc/awlsim/examples/linuxcnc-demo/../..//awlsim-linuxcnc-hal", line 394, in main
    server.run()
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1691, in run
    self.__handleCommunication()		#@cy-win
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1466, in __handleCommunication
    self.__handleSocketComm(rlist)
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1439, in __handleSocketComm
    self.__handleClientComm(self.__sock2client[sock])
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1423, in __handleClientComm
    handler(self, client, msg)
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1340, in __rx_GET_IDENTS
    client.transceiver.send(reply)
  File "/home/lcnc/awlsim/awlsim/coreserver/messages.py", line 1918, in send
    data = memoryview(msg.toBytes())
  File "/home/lcnc/awlsim/awlsim/coreserver/messages.py", line 1582, in toBytes
    payload.append(self.packString(pVal))
  File "/home/lcnc/awlsim/awlsim/coreserver/messages.py", line 180, in packString
    return cls.packBytes(string.encode("utf-8", "strict"))
AttributeError: Pin 'encode' does not exist

In file "awlsim/coreserver/messages.py" attached such a bone:

175: 	@classmethod
	def packString(cls, string):
		try:
			if not string:
				string = ""
			try:
				ret=cls.packBytes(string.encode("utf-8", "strict"))
			except:
				ret=cls.packBytes("")

			return ret 
		except UnicodeError as e:
			raise ValueError

Add localization support

As I understand it, the error message code is not optimized to create localization. There is no great need for this, but it would be nice to add this feature too.

Just add "_ ()":

print(_("Triggered LinuxCNC E-Stop"))

Also need to be added at the beginning:

import locale 
import gettext

and something like this:

        locale.setlocale( locale.LC_ALL, '' )
        locale.bindtextdomain( "awlsim", LOCALEDIR )
        gettext.install( "awlsim", localedir = LOCALEDIR, unicode = True )
        gettext.bindtextdomain( "awlsim", LOCALEDIR )

GUI freeze and doesn't respond

On Windows, the system works as usual, but on Linux the Avlsim interface freezes. If you do not press the disconnect button, then everything also works as usual.

Steps to reproduce the issue:

  1. Press server connection button and start simulator core.
  2. Press server connection button to disconect.
  3. Close window or press exit button.
  4. ...
AwlSimServer: [2.304] Received message: RUNSTATE 0
awlsim-gui: [5.546] AwlSimClient: Received message 0x0000
AwlSimServer: [2.305] Client '[127.0.0.1]:36058' disconnected
AwlSimServer: [5.212] Received signal 15
AwlSimServer: [5.213] Switched to AUTO garbage collection.

Incorrect rounding of RND+ and RND- instructions

For values above -1.0 and below 0.0 the instructions RND+ and RND- round incorrectly.

RND+:
For -1.0 < ACCU1 < 0.0:
Expected result: 0
Actual incorrect result: 1

RND-:
For -1.0 < ACCU1 < 0.0:
Expected result: -1
Actual incorrect result: 0

Incorrect handling of STW OR bit

The handling of the STW OR bit is partially incorrect in U, UN, O, ON, X, XN, U(, UN(, O(, ON(, X( and XN( instructions.

This can lead to incorrect AWL program execution, if AND-before-OR (UND vor ODER) logic is used.
Programs that do not contain a plain O instruction (O instruction without operands) are not affected.

This will be fixed in awlsim-0.65.0

GUI: FUP editor does not work on Python 2.7/3.2

  1. GUI startup aborts with a syntax error:
  File ".../awlsim/gui/fup/fup_elem.py", line 410
    LineSeg2D.fromCoords(*trans.map(tlX, tlY), *trans.map(trX, trY)),
                                               ^
SyntaxError: invalid syntax

fixed by 5896e57

  1. All wire lines are marked as "colliding".

fixed by 1da9447

break at remove rpigpio in the Hardware module setup

Hello,

have copy the soure from the homepage, unzip and start awlsim-win.cmd (use W7), python3 and pyqt5 is already install.

Opening the Hardware module setup, add rpigpio and remove, test it with add 3 times and remove one.
Program quit and show this:

awlsim-0.47>py -3 -O awlsim-gui
awlsim-gui: Using PyQt5 GUI framework
Traceback (most recent call last):
  File "C:\Users\mhackspacher\Downloads\awlsim-0.47\awlsim\gui\hwmodconfig.py",line 357, in __handleDel
    self.__loadedModDescs.remove(modDesc)
  File "C:\Users\mhackspacher\Downloads\awlsim-0.47\awlsim\common\hwmod.py", line 117, in __eq__
    return self.getIdentHash() == other.getIdentHash()
  File "C:\Users\mhackspacher\Downloads\awlsim-0.47\awlsim\common\hwmod.py", line 109, in getIdentHash
    h.update(pValue.encode("utf-8", "ignore"))
AttributeError: 'NoneType' object has no attribute 'encode'

Using raw calls on blocks that are not raw crashes the interpreter

FUNCTION FC 1 : VOID
        VAR_INPUT
                IN0     : INT;
        END_VAR
BEGIN
        L       #IN0
END_FUNCTION


ORGANIZATION_BLOCK OB 1
BEGIN
        UC      FC 1
        CALL SFC 46 // STOP CPU
END_ORGANIZATION_BLOCK
Traceback (most recent call last):
  File "./awlsim-test", line 578, in <module>
    sys.exit(main())
  File "./awlsim-test", line 575, in main
    return run(inputFile)
  File "./awlsim-test", line 245, in run
    s.runCycle()
  File "/home/mb/develop/git/awlsim/awlsim/core/main.py", line 207, in runCycle
    self.cpu.runCycle()
  File "/home/mb/develop/git/awlsim/awlsim/core/cpu.py", line 882, in runCycle
    self.__runOB(self.obs[1])
  File "/home/mb/develop/git/awlsim/awlsim/core/cpu.py", line 823, in __runOB
    insn.run()
  File "/home/mb/develop/git/awlsim/awlsim/core/instructions/insn_l.py", line 42, in run
    self.cpu.accu1.set(self.cpu.fetch(self.ops[0], {8, 16, 32}))
  File "/home/mb/develop/git/awlsim/awlsim/core/cpu.py", line 1261, in fetch
    return fetchMethod(self, operator, enforceWidth)
  File "/home/mb/develop/git/awlsim/awlsim/core/cpu.py", line 1490, in fetchNAMED_LOCAL
    return self.fetch(self.__translateFCNamedLocalOper(operator, False),
  File "/home/mb/develop/git/awlsim/awlsim/core/cpu.py", line 1201, in __translateFCNamedLocalOper
    interfOp = self.callStackTop.interfRefs[operator.interfaceIndex].resolve(store)
AttributeError: 'CallStackElem' object has no attribute 'interfRefs'

It should fail gracefully instead.

awlsimhw_linuxcnc: Error on launching linuxcnc example

An error occurs when a clean instance hal is passed to the descriptor.

Traceback (most recent call last): File "/home/lcnc/awlsim/examples/linuxcnc-demo/../..//awlsim-linuxcnc-hal", line 438, in <module> sys.exit(main()) File "/home/lcnc/awlsim/examples/linuxcnc-demo/../..//awlsim-linuxcnc-hal", line 390, in main server.setRunState(server.STATE_RUN) File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 642, in setRunState raise e AttributeError: 'unicode' object has no attribute 'ready'

In file "awlsim/awlsim/common/hwmod.py" empty quotes cause an error.

159:  	def setParameterValue(self, name, value):
		"""Set the value of a parameter.
		"""
		self.parameters[name] = value or ""
		self.__identHash = None

Add tooltips and autocomplete when entering a field in GUI

I did not find this items in the todo list, but it would greatly simplify the work:

  • In the "Symbols" table in the "Symbol" column, you can make a hint for the names entered above, for example, as in the MS Excell tables, and in the "Data type" column, type auto-completion by the first letter entered.

  • Also, when editing the operand name in the FBD scheme, it would be nice to have a name hint from the "Symbols" tables.

  • If this is very difficult, then you can make the operand name be copied or pasted immediately with quotation marks or pound.

  • Also, I did not find how to enter constants besides creating a memory flag. In the examples there is "L # 65000" as far as I understand it passes a 32 bit variable, but how do I pass a boolean?

RESOLVED! Error running setup.py from the unzipped folder, also error running linuxcnc demo may be related

Here's what I get:

cnc@linuxcnc:~/Desktop/awlsim-0.74.0$ python setup.py
WARNING: Could not build the CYTHON modules: Cython 2 not supported. Please use Cython 3.
Skipping build of CYTHON modules.
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied
cnc@linuxcnc:~/Desktop/awlsim-0.74.0$ 

app dependencies were installed from the github zip

I also have the following report after an error running linuxcnc with the example files:

Error report created by /usr/lib/tcltk/linuxcnc/show_errors.tcl:

Print file information:
RUN_IN_PLACE=no
LINUXCNC_DIR=
LINUXCNC_BIN_DIR=/usr/bin
LINUXCNC_TCL_DIR=/usr/lib/tcltk/linuxcnc
LINUXCNC_SCRIPT_DIR=
LINUXCNC_RTLIB_DIR=/usr/lib/linuxcnc/modules
LINUXCNC_CONFIG_DIR=
LINUXCNC_LANG_DIR=/usr/lib/tcltk/linuxcnc/msgs
INIVAR=inivar
HALCMD=halcmd
LINUXCNC_EMCSH=/usr/bin/wish8.6
LINUXCNC - 2.8.0
Machine configuration directory is "/home/cnc/linuxcnc/configs/test_all_demo_files"
Machine configuration file is "test_all_demo_files.ini"
INIFILE=/home/cnc/linuxcnc/configs/test_all_demo_files/test_all_demo_files.ini
VERSION=1.1
PARAMETER_FILE=emc.var
TASK=milltask
HALUI=halui
DISPLAY=axis
COORDINATES=XYZ
KINEMATICS=trivkins coordinates=XYZ
Starting LinuxCNC...
Starting LinuxCNC server program: linuxcncsvr
Loading Real Time OS, RTAPI, and HAL_LIB modules
Starting LinuxCNC IO program: io
Starting HAL User Interface program: halui
Found file(REL): ./linuxcnc-demo.hal
Found file(REL): ./awlsim.hal
Shutting down and cleaning up LinuxCNC...
Removing HAL_LIB, RTAPI, and Real Time OS modules
Removing NML shared memory segments

Debug file information:
Note: Using POSIX realtime
Unexpected realtime delay on task 0 with period 20000
This Message will only display once per session.
Run the Latency Test and resolve before continuing.
./awlsim.hal:25: execv(awlsim-linuxcnc-hal): No such file or directory
./awlsim.hal:25: waitpid failed awlsim-linuxcnc-hal awlsim
./awlsim.hal:25: awlsim-linuxcnc-hal exited without becoming ready
3964
Stopping realtime threads
Unloading hal components
Note: Using POSIX realtime



-----------------------------------------------------------------------
Info report created by linuxcnc_info:
The file:    /tmp/linuxcnc_info.txt
can be posted to a forum or a web site like:
     http://pastebin.com
in order to provide information about the linuxcnc
system and configuration.

                Date: Thu 10 Jun 2021 11:36:30 AM EDT
            UTC Date: Thu 10 Jun 2021 03:36:30 PM UTC
        this program: /usr/bin/linuxcnc_info
              uptime: 11:36:30 up 1:03, 1 user, load average: 0.02, 0.04, 0.08
     lsb_release -sa: Debian Debian GNU/Linux 10 (buster) 10 buster
      which linuxcnc: /usr/bin/linuxcnc
                 pwd: /home/cnc/linuxcnc/configs/test_all_demo_files
                USER: cnc
             LOGNAME: cnc
                HOME: /home/cnc
              EDITOR: 
              VISUAL: 
            LANGUAGE: 
                TERM: dumb
           COLORTERM: 
             DISPLAY: :0.0
             DESKTOP: lightdm-xsession
        display size: 800x600 pixels (211x158 millimeters)
                PATH: /usr/bin:/home/cnc/linuxcnc/configs/test_all_demo_files/bin:/usr/bin:/home/cnc/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

uname items:
         nodename -n: linuxcnc
      kernel-name -s: Linux
      kernel-vers -v: #1 SMP PREEMPT RT Debian 4.19.146-1 (2020-09-17)
          machine -m: x86_64
        processor -p: unknown
         platform -i: unknown
      oper system -o: GNU/Linux

/proc items:
             cmdline: BOOT_IMAGE=/boot/vmlinuz-4.19.0-11-rt-amd64 root=UUID=9457fa4f-82b8-4c33-8384-2ef2f2f77780 ro initrd=/install/gtk/initrd.gz quiet
          model name: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
               cores: 1
             cpu MHz: 3400.030
             parport: 
              serial: 

Versions:
                 gcc: gcc (Debian 8.3.0-6) 8.3.0
              python: Python 2.7.16
                 git: git version 2.20.1
          git commit: NA
                 tcl: 8.6
                  tk: 8.6
               glade: not_in_PATH
          glade-gtk2: not_in_PATH

linuxcnc_var all:

     LINUXCNCVERSION: 2.8.0
LINUXCNC_AUX_GLADEVCP: /usr/share/linuxcnc/aux_gladevcp
LINUXCNC_AUX_EXAMPLES: /usr/share/linuxcnc/aux_examples
            REALTIME: /etc/init.d/realtime
                 RTS: uspace
          HALLIB_DIR: /usr/share/linuxcnc/hallib

dpkg -l "*linuxcnc*":
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                Version      Architecture Description
+++-===================-============-============-=====================================================================
un  linuxcnc            <none>       <none>       (no description available)
un  linuxcnc-dev        <none>       <none>       (no description available)
un  linuxcnc-doc        <none>       <none>       (no description available)
ii  linuxcnc-doc-cn     1:2.8.0      all          motion controller for CNC machines and robots (Chinese
ii  linuxcnc-doc-en     1:2.8.0      all          motion controller for CNC machines and robots (English documentation)
ii  linuxcnc-doc-es     1:2.8.0      all          controlador de movimiento para máquinas CNC y robots (Español).
ii  linuxcnc-doc-fr     1:2.8.0      all          motion controller for CNC machines and robots (French documentation)
un  linuxcnc-sim        <none>       <none>       (no description available)
un  linuxcnc-sim-dev    <none>       <none>       (no description available)
ii  linuxcnc-uspace     1:2.8.0      amd64        motion controller for CNC machines and robots
ii  linuxcnc-uspace-dev 1:2.8.0      amd64        PC based motion controller for real-time Linux

This should be my operating system info:

The file:    /tmp/linuxcnc_info.txt
can be posted to a forum or a web site like:
     http://pastebin.com
in order to provide information about the linuxcnc
system and configuration.

                Date: Thu 10 Jun 2021 11:36:30 AM EDT
            UTC Date: Thu 10 Jun 2021 03:36:30 PM UTC
        this program: /usr/bin/linuxcnc_info
              uptime: 11:36:30 up 1:03, 1 user, load average: 0.02, 0.04, 0.08
     lsb_release -sa: Debian Debian GNU/Linux 10 (buster) 10 buster
      which linuxcnc: /usr/bin/linuxcnc
                 pwd: /home/cnc/linuxcnc/configs/test_all_demo_files
                USER: cnc
             LOGNAME: cnc
                HOME: /home/cnc
              EDITOR: 
              VISUAL: 
            LANGUAGE: 
                TERM: dumb
           COLORTERM: 
             DISPLAY: :0.0
             DESKTOP: lightdm-xsession
        display size: 800x600 pixels (211x158 millimeters)
                PATH: /usr/bin:/home/cnc/linuxcnc/configs/test_all_demo_files/bin:/usr/bin:/home/cnc/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

uname items:
         nodename -n: linuxcnc
      kernel-name -s: Linux
      kernel-vers -v: #1 SMP PREEMPT RT Debian 4.19.146-1 (2020-09-17)
          machine -m: x86_64
        processor -p: unknown
         platform -i: unknown
      oper system -o: GNU/Linux

/proc items:
             cmdline: BOOT_IMAGE=/boot/vmlinuz-4.19.0-11-rt-amd64 root=UUID=9457fa4f-82b8-4c33-8384-2ef2f2f77780 ro initrd=/install/gtk/initrd.gz quiet
          model name: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
               cores: 1
             cpu MHz: 3400.030
             parport: 
              serial: 

Versions:
                 gcc: gcc (Debian 8.3.0-6) 8.3.0
              python: Python 2.7.16
                 git: git version 2.20.1
          git commit: NA
                 tcl: 8.6
                  tk: 8.6
               glade: not_in_PATH
          glade-gtk2: not_in_PATH

linuxcnc_var all:

     LINUXCNCVERSION: 2.8.0
LINUXCNC_AUX_GLADEVCP: /usr/share/linuxcnc/aux_gladevcp
LINUXCNC_AUX_EXAMPLES: /usr/share/linuxcnc/aux_examples
            REALTIME: /etc/init.d/realtime
                 RTS: uspace
          HALLIB_DIR: /usr/share/linuxcnc/hallib

dpkg -l "*linuxcnc*":
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                Version      Architecture Description
+++-===================-============-============-=====================================================================
un  linuxcnc            <none>       <none>       (no description available)
un  linuxcnc-dev        <none>       <none>       (no description available)
un  linuxcnc-doc        <none>       <none>       (no description available)
ii  linuxcnc-doc-cn     1:2.8.0      all          motion controller for CNC machines and robots (Chinese
ii  linuxcnc-doc-en     1:2.8.0      all          motion controller for CNC machines and robots (English documentation)
ii  linuxcnc-doc-es     1:2.8.0      all          controlador de movimiento para máquinas CNC y robots (Español).
ii  linuxcnc-doc-fr     1:2.8.0      all          motion controller for CNC machines and robots (French documentation)
un  linuxcnc-sim        <none>       <none>       (no description available)
un  linuxcnc-sim-dev    <none>       <none>       (no description available)
ii  linuxcnc-uspace     1:2.8.0      amd64        motion controller for CNC machines and robots
ii  linuxcnc-uspace-dev 1:2.8.0      amd64        PC based motion controller for real-time Linux

I do have the newer python installed but that file shows the older one

Connecting LINUXCNC to physical CNC machine using AWLSIM

I am admittedly having a hard time with this part! I am not sure where to go next but other than AWL file issues I think this is my last hurdle.

Map1

Do I need some commercial ethernet to PLC hardware? The machine uses RS485 in particular, and I have all sorts of adapters.

Also is there some slack channel for forum we can use for support / documentation?

awlsimhw_linuxcnc: Error on loading program to CPU

When gui reloads the program, the instance variable hal is cleared. The hal.ready () function is also executed twice, which causes an error.

Traceback (most recent call last):
  File "/home/lcnc/awlsim/examples/linuxcnc-demo/../..//awlsim-linuxcnc-hal", line 438, in <module>
    sys.exit(main())
  File "/home/lcnc/awlsim/examples/linuxcnc-demo/../..//awlsim-linuxcnc-hal", line 394, in main
    server.run()
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1683, in run
    self.__handleCommunicationBlocking()
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1506, in __handleCommunicationBlocking
    self.__handleCommunication()
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1466, in __handleCommunication
    self.__handleSocketComm(rlist)
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1439, in __handleSocketComm
    self.__handleClientComm(self.__sock2client[sock])
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1423, in __handleClientComm
    handler(self, client, msg)
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1049, in __rx_RUNSTATE
    self.setRunState(self.STATE_RUN)
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 642, in setRunState
    raise e
AttributeError: 'unicode' object has no attribute 'ready'

I came up with adding a global variable for hal instance.

In file "awlsim/coreserver/server.py" added
304: self.linuxcncHALcomponent = None
and

961: if "linuxcnc" in hwmodName:
hwmodDesc.setParameterValue('hal',self.linuxcncHALcomponent)

In file "awlsim_linuxcnc_hal"
359: server.linuxcncHALcomponent = hal

In file "awlsimhw_linuxcnc/main.py"

207: if not self.LinuxCNC_HAL.component_is_ready("awlsim"):
self.hal.ready()

Error message on client and server

Is it possible to do precompilation on the client side? A commonplace error in the name causes a stop CPU and there are no error messages on the client side.

awlsim-linuxcnc: [133.250] Awlsim error:
  Multiple definitions of FC 1.

When you load an STL file, the error is at least highlighted in red, but when you work in FBD there are no messages or highlighting.
Also, the FBD source file is not indicated in the error, which greatly complicates the search.

awlsim-linuxcnc: [1919.813] Awlsim error:
  Unconnected pin "Q" found in FUP element XOR(x3/y10, 2c096344..65166).
The reporting FUP/FBD element is:
FUP-grid

If there is no way to precompile on the client, is there a way to display the error in the server GUI?

Add the ability to embed the application

Now I am making the Linuxcnc GUI on pyqt and want to embed awlsim in one of the tabs.
But starting with this code leads to a number of errors or freezes:

from awlsim.gui.mainwindow import *
class AwlsimWidget(QWidget):
    def __init__(self, parent=None, path=None):
        QWidget.__init__(self, parent)
        try:
            mainwnd = MainWindow.start()
            layout = QHBoxLayout()
            layout.addWidget(mainwnd)
            self.setLayout(layout)
        except Exception as e:
            printDebug(_("Failed to import awlsim, {}",e))

Can you add a parameter to start awlism process in the window?
Like this:

self.process = QtCore.QProcess(self)
self.process.start('xterm',['-into', str(int(self.winId())), '-geometry', "600x60+0+400"])

Non-English names are not displayed in the compiler window

Non-English names are not displayed in the compiler window.
Instead of words it turns out "____".

// 
// FUNCTION generated by Awlsim FUP compiler
// 
// Source            : 123 ____ 
// Compiler version  : 0.73.0-pre
// AWL mnemonics     : DE (German)
// Optimizers        : grid-1: biefwd, lblrem, noprem
// 
FUNCTION FC 1 : VOID
	TITLE   = 123 ____ 
	FAMILY  : FUP
	VERSION : 0.73.0-pre
BEGIN
        BE;
END_FUNCTION

Function / Functionblock Calls (Syntax)

According to the specification brackets and commas are not required for function block / function calls:

CALL FB 27 , DB 27
RZNR := EB11
Q1_IMP := L40.0
Q2_IMP := L40.1

L W [P#M 0.0, P#0.0] crashes

Trying to run L W [P#M 0.0, P#0.0] results in a crash, whereas the expected behaviour is to fail gracefully.

Stack trace:

AwlSimServer: Shutting down.
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/[...]/awlsim/awlsim/coreserver/server.py", line 1207, in <module>
    sys.exit(AwlSimServer._execute())
  File "/[...]/awlsim/awlsim/coreserver/server.py", line 207, in _execute
    server.runFromEnvironment(env)
  File "/[...]/awlsim/awlsim/coreserver/server.py", line 309, in runFromEnvironment
    self.run()
  File "/[...]/awlsim/awlsim/coreserver/server.py", line 1036, in run
    self.__handleCommunicationBlocking()
  File "/[...]/awlsim/awlsim/coreserver/server.py", line 900, in __handleCommunicationBlocking
    self.__handleCommunication()
  File "/[...]/awlsim/awlsim/coreserver/server.py", line 893, in __handleCommunication
    self.__handleSocketComm(rlist)
  File "/[...]/awlsim/awlsim/coreserver/server.py", line 868, in __handleSocketComm
    self.__handleClientComm(self.__sock2client[sock])
  File "/[...]/awlsim/awlsim/coreserver/server.py", line 858, in __handleClientComm
    handler(self, client, msg)
  File "/[...]/awlsim/awlsim/coreserver/server.py", line 637, in __rx_RUNSTATE
    self.setRunState(self.STATE_RUN)
  File "/[...]/awlsim/awlsim/coreserver/server.py", line 335, in setRunState
    self.__sim.startup()
  File "/[...]/awlsim/awlsim/core/main.py", line 42, in profiled_wrapper
    func(self, *args, **kwargs)
  File "/[...]/awlsim/awlsim/core/main.py", line 55, in awlSimErrorExtension_wrapper
    func(self, *args, **kwargs)
  File "/[...]/awlsim/awlsim/core/main.py", line 190, in startup
    self.cpu.startup()
  File "/[...]/awlsim/awlsim/core/cpu.py", line 846, in startup
    self.prog.build()
  File "/[...]/awlsim/awlsim/core/cpu.py", line 317, in build
    self.__detectMnemonics()
  File "/[...]/awlsim/awlsim/core/cpu.py", line 177, in __detectMnemonics
    optrans.translateFromRawInsn(rawInsn)
  File "/[...]/awlsim/awlsim/core/optrans.py", line 671, in translateFromRawInsn
    opDesc = self.translateOp(rawInsn, rawOps)
  File "/[...]/awlsim/awlsim/core/optrans.py", line 627, in translateOp
    self.__translateAddressOperator(opDesc, rawOps[1:])
  File "/[...]/awlsim/awlsim/core/optrans.py", line 345, in __translateAddressOperator
    self.__translateIndirectAddressing(opDesc, rawOps[1:])
  File "/[...]/awlsim/awlsim/core/optrans.py", line 299, in __translateIndirectAddressing
    assert(offsetOpDesc.fieldCount == end)
AssertionError

awlsimhw_linuxcnc: Changing linuxcnc I/O number cause error.

When in gui you change the number of inputs or outputs, the hal component is not updated.

Traceback (most recent call last):
  File "/home/lcnc/awlsim/examples/linuxcnc-demo/../..//awlsim-linuxcnc-hal", line 441, in <module>
    sys.exit(main())
  File "/home/lcnc/awlsim/examples/linuxcnc-demo/../..//awlsim-linuxcnc-hal", line 397, in main
    server.run()
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1683, in run
    self.__handleCommunicationBlocking()
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1506, in __handleCommunicationBlocking
    self.__handleCommunication()
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1466, in __handleCommunication
    self.__handleSocketComm(rlist)
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1439, in __handleSocketComm
    self.__handleClientComm(self.__sock2client[sock])
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1423, in __handleClientComm
    handler(self, client, msg)
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 1049, in __rx_RUNSTATE
    self.setRunState(self.STATE_RUN)
  File "/home/lcnc/awlsim/awlsim/coreserver/server.py", line 642, in setRunState
    raise e
AttributeError: Pin 'output.u31.6.active' does not exist

To reload hal you can use a bash script like this:

halcmd unloadusr awlsim
halcmd loadusr -Wn awlsim awlsim-linuxcnc-hal --listen localhost:4151 linuxcnc-demo.awlpro

But "unloadusr" breaks all networks, so it's better to call "source":

halcmd unloadusr awlsim
halcmd source awlsim.hal

It would also be nice to have this code called when the awlsim component crash:

        import linuxcnc
	command = linuxcnc.command()
	command.state( linuxcnc.STATE_OFF )
        command.state( linuxcnc.STATE_ESTOP )
	command.wait_complete()

For example, if a component stops during a zero search on a machine, this will result in physical damage to the axis, so it is better to stop the component. You can also add a parameter for the user what to do during an accident.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.