Benutzer-Werkzeuge

Webseiten-Werkzeuge


becki:linux:modbus

Dies ist eine alte Version des Dokuments!


Modbus TCP

Collected informations for using Modbus on TCP/IP. Libmodbus is used as master on any Linux computer (Sheevaplug). Wago fieldbuscouplers 750-342 are used as slaves.

Modbus Command Overview

Code Bits Target Count Direction Name
01 1 DO many read Read Coils
02 1 DI many read Read Discrete Inputs
03 16 AO many read Read Holding Registers
04 16 AI many read Read Input Register
05 1 DO one write Write Single Coil
06 16 AO one write Write Single Register
15 1 DO many write Write Multiple Coils
16 16 AO many write Write Multiple registers

Source

More information sources:

Wago 750-342

Setting the IP with bootp

Basic principle: The bootp client (750-342) sends its MAC address to the bootp server (eg. a slackware linux computer). The server in turn provides the client with an IP address.

Example: To provide the client host with the name etb-130 who has the MAC address 0030DE010A2C with the IP address 192.168.132.130 and an appropriate subnet mask, add the following line to /etc/bootptab:

etb-130:ht=1:ha=0030DE010A2C:ip=192.168.132.130:sm=255.255.255.0

Then, on the server machine, start the bootp daemon by uncommenting the following line in /etc/inetd.conf

bootps  dgram   udp     wait    root    /usr/sbin/bootpd        bootpd

…and restart the inetd:

/etc/rc.d/rc.inetd restart

Now connect the Client with the server eg over crosslink cable and boot the client.

The 750-342 fetches its IP from the bootp server only when bootp is enabled. Otherwise it uses the IP saved in its EEPROM. Pseudcode:

ipNumber= bootpEnabled ? getIpNumberFromBootpServer() : getIpNumberFromEeprom()

See also: Wago manual p.82ff and bootptab

Libmodbus

Installation

Note: You could get the latest devel release with git clone http://github.com/stephane/libmodbus.git, but this has no configure script, so we use the lataest stable release instead.

Download v 2.0.3 from here and do the usual ./confiure; make; su; make install;. This installs the following objects to /usr/local/:

lib/libmodbus.so
lib/libmodbus.la
lib/libmodbus.so.2.0.0
lib/pkgconfig/modbus.pc
lib/libmodbus.so.2
include/modbus/modbus.h

Then do ldconfig to update the library system info.

Cookies helfen bei der Bereitstellung von Inhalten. Diese Website verwendet Cookies. Mit der Nutzung der Website erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Computer gespeichert werden. Außerdem bestätigen Sie, dass Sie unsere Datenschutzerklärung gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website. Weitere Information
becki/linux/modbus.1280318089.txt.gz · Zuletzt geändert: 2010-07-28 11:54 von becki

Impressum - Datenschutzerklärung