TOP
SSV Software Systems Register  Register
Log in to check your private messages  Log in to check your private messages
Startseite FAQ Search Mitglieder Profile  Log in 
SSV Support-Forum
Modbus-Anwendungen entwickeln …

 
Post new topic   Reply to topic    SSV-Forum Forum Index >>> IGW/935
<<< Previous topic - Next topic >>>  
Display posts from previous:   
Author Message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 29.06.2013, 08:18    Post subject: Modbus-Anwendungen entwickeln … Reply with quote

Hallo Forum.

In vielen Anwendungen wird das IGW/935 als Modbus-Master eingesetzt, um auf externe Modbus-Datenquellen zuzugreifen. Den Slave bildet dann eine Steuerung oder I/O-Bausteine (zum Beispiel Baugruppen aus dem WAGO I/O System).

Um die Entwicklung eigener Systemlösungen zu vereinfachen, ist mit Modpoll ein Modbus Master Simulator verfügbar, der sowohl Modbus RTU als auch Modbus TCP unterstützt.

Modpoll wird innerhalb einer Telnet-Session von der Kommandozeile gestartet. Es existiert ein umfangreicher Parameter-Vorrat:

Code:
Usage: modpoll [options] serialport|host
Arguments:
serialport    Serial port when using Modbus ASCII or Modbus RTU protocol
              COM1, COM2 ...                on Windows
              /dev/ttyS0, /dev/ttyS1 ...    on Linux
              /dev/ser1, /dev/ser2 ...      on QNX
host          Host name or dotted ip address when using MODBUS/TCP protocol
General options:
-m ascii      Modbus ASCII protocol
-m rtu        Modbus RTU protocol (default)
-m tcp        MODBUS/TCP protocol
-m enc        Encapsulated Modbus RTU over TCP
-a #          Slave address (1-255, 1 is default)
-r #          Start reference (1-65536, 100 is default)
-c #          Number of values to poll (1-100, 1 is default)
-t 0          Discrete output (coil) data type
-t 1          Discrete input data type
-t 3          16-bit input register data type
-t 3:hex      16-bit input register data type with hex display
-t 3:int      32-bit integer data type in input register table
-t 3:mod      32-bit module 10000 data type in input register table
-t 3:float    32-bit float data type in input register table
-t 4          16-bit output (holding) register data type (default)
-t 4:hex      16-bit output (holding) register data type with hex display
-t 4:int      32-bit integer data type in output (holding) register table
-t 4:mod      32-bit module 10000 type in output (holding) register table
-t 4:float    32-bit float data type in output (holding) register table
-i            Slave operates on big-endian 32-bit integers
-f            Slave operates on big-endian 32-bit floats
-1            Poll only once, otherwise poll every second
-e            Use Daniel/Enron single register 32-bit mode
-0            First reference is 0 (PDU addressing) instead 1
Options for MODBUS/TCP:
-p #          TCP port number (502 is default)
Options for Modbus ASCII and Modbus RTU:
-b #          Baudrate (e.g. 9600, 19200, ...) (9600 is default)
-d #          Databits (7 or 8 for ASCII protocol, 8 for RTU)
-s #          Stopbits (1 or 2, 1 is default)
-p none       No parity
-p even       Even parity (default)
-p odd        Odd parity
-4 #          RS-485 mode, RTS on while transmitting and another # ms after
-o #          Time-out in seconds (0.01 - 10.0, 1.0 s is default)


Wenn Sie einen Modbus-Slave mit der RS485-Schnittstelle des IGW/935 verbunden haben oder sichergestellt wurde, dass sich ein solcher Slave in einem LAN befindet, auf das ein IGW/935 per LAN1 oder LAN2 zugreifen kann, können Sie Modpoll als Modbus Master Simulator nutzen.

Wir gehen hier einmal davon aus, dass ein Modbus-TCP-Slave mit dem IGW/935 verbunden ist und das dieser Slave die IP-Adresse 192.168.0.1 besitzt. Durch die Eingabe:

Code:
./modpoll –c 5 –r 100 –m tcp 192.168.0.1


starten Sie Abfrage der Register 100 – 104 (-c 5 = Frage fünf Register ab, -r 100 = Beginne mit der Adresse 100) des Modbus-TCP-Slave (-m TCP = Modbus TCP).

Gruß KDW
Back to top
View user's profile Send private message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 29.06.2013, 15:35    Post subject: Modbus Slave Simulator … Reply with quote

Hallo Forum.

In vielen Anwendungen muss für ein IGW/935 ein spezieller Modbus Master entwickelt werden. Als Gegenstück ist dann ein geeigneter Modbus Slave Simulator recht hilfreich. Sehr empfehlenswert ist hier Ananas für Windows PCs, den man unter http://www.tuomio.fi/ananas/index.htm kostenlos laden kann.

Ananas unterstützt Modbus Holding Register und Modbus Input Register. Die Umschaltung erfolgt über entsprechend gekennzeichnete Schaltflächen. Durch die Eingabe:

Code:
./modpoll –c 5 –r 100 –m tcp 192.168.0.1


werden die Modbus Holding Register ausgelesen. Um auf die Modbus Input Register zuzugreifen, ist –t 3 als zusätzlicher Parameter erforderlich.

Code:
./modpoll –c 5 –r 100 –t 3 –m tcp 192.168.0.1


Gruß KDW
Back to top
View user's profile Send private message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 29.06.2013, 22:00    Post subject: Modbus-Master erstellen … Reply with quote

Hallo Forum.

Mit Hilfe von Python und der Bibliothek Modbus-TK lässt sich ein voll funktionsfähiger Modbus-Master schon mit einigen Zeilen Code erstellen:

Code:
import time
import modbus_tk
import modbus_tk.defines as cst
import modbus_tk.modbus_tcp as modbus_tcp

master = modbus_tcp.TcpMaster("192.168.2.142", 502)
master.set_timeout(5.0)
while True:
    print master.execute(1, cst.READ_INPUT_REGISTERS, 0, 4)    
    time.sleep(1)


Dieses Beispiel greift einmal pro Sekunde (Modbus Poll) auf vier Ananas Input Register zu. Für den Zugriff auf die Holding Register muss lediglich READ_INPUT_REGISTERS durch READ_HOLDING_REGISTERS ersetzt werden.

Die vier gelesenen Werte werden als Python-Tupel – also als unveränderliche Liste – in der Form (a, b, c, d) ausgegeben. Sie lassen sich allerdings auch separat adressieren:

Code:
import time
import modbus_tk
import modbus_tk.defines as cst
import modbus_tk.modbus_tcp as modbus_tcp

master = modbus_tcp.TcpMaster("192.168.2.142", 502)
master.set_timeout(5.0)
while True:
    a = master.execute(1, cst.READ_INPUT_REGISTERS, 0, 4)    
    print "a[0]= ", a[0]
    print "a[1]= ", a[1]
    print "a[2]= ", a[2]
    print "a[3]= ", a[3]
    time.sleep(1)


Gruß KDW
Back to top
View user's profile Send private message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 30.06.2013, 09:11    Post subject: Modbus-Slave erstellen … Reply with quote

Hallo Forum.

Mit Hilfe von Python und der Bibliothek Modbus-TK lässt sich selbstverständlich auch ein voll funktionsfähiger Modbus-Slave erstellen:

Code:
import sys
import modbus_tk
import modbus_tk.modbus_tcp as modbus_tcp
import threading
import modbus_tk.defines as mdef

logger = modbus_tk.utils.create_logger(name="console", record_format="%(message)s")

server = modbus_tcp.TcpServer(address='')
slave1 = server.add_slave(1)
slave1.add_block("a", mdef.HOLDING_REGISTERS, 0, 2)
slave1.set_values("a", 0, 4711) 
slave1.set_values("a", 1, 9422)           
logger.info("Modbus slave running.")
logger.info("Enter 'quit' for stopping the slave!")
server.start()

while True:
    cmd = sys.stdin.readline()
    args = cmd.split(' ')
    if cmd.find('quit') == 0:
        sys.stdout.write('Modbus slave stops!\r\n')
        break
server.stop()


Dieser Modbus-Slave bietet zwei Modbus Holding Register unter den Modbus Register Adressen 0 und 1. Sie können den Slave per Modpoll wie folgt ansprechen:

Code:
./modpoll –m tcp –r 1 –c 2 192.168.0.1


Bitte beachten: Aus der Sicht der Modbus-TK Bibliothek ist ein Modbus-Slave auch ein (Modbus-) TCP-Server, weil er einen Server Socket erzeugt und auf einen Verbindungsaufbau durch einen (Modbus-) TCP-Client (Modbus-Master) wartet.

Gruß KDW
Back to top
View user's profile Send private message
kdw



Joined: 05 May 2006
Posts: 1460

PostPosted: 08.01.2016, 07:24    Post subject: Modbus und Node-RED … Reply with quote

Hallo Forum.

Modbus-Anwendungen lassen sich auch dem IGW/935 auch mit Hilfe von Node-Red entwickeln. Siehe

https://ssv-embedded.de/doks/manuals/Modbus2Cloud_Intro.pdf

und

https://ssv-embedded.de/doks/manuals/MQTT4Sensors_Intro.pdf

In beiden Dokumenten geht es um Modbus-basierte Anwendungen, die mit Hilfe von Node-RED realisiert werden.

Gruß KDW
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SSV-Forum Forum Index >>> IGW/935 All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

SSV Software Systems GmbH

Dünenweg 5
30419 Hannover

Fon: +49(0)511  ·  40 000-0
Fax: +49(0)511  ·  40 000-40

sales@ssv-embedded.de


Impressum    ·    Datenschutz    ·    AGB

© 2023 SSV SOFTWARE SYSTEMS GmbH. Alle Rechte vorbehalten.

ISO 9001:2015