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 (or alternatively 750-841) are used as slaves.

Modbus Command Overview

Code Bits Target Count Direction Name in Spec libmodbus Function Name
01 1 DO many read Read Coils read_coil_status
02 1 DI many read Read Discrete Inputs read_input_status
03 16 AO many read Read Holding Registers read_holding_registers
04 16 AI many read Read Input Register read_input_registers
05 1 DO one write Write Single Coil force_single_coil
06 16 AO one write Write Single Register preset_single_register
15 1 DO many write Write Multiple Coils force_multiple_coils
16 16 AO many write Write Multiple registers preset_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()

Web access to 750-342 is admin / wago

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.

Wago Adressing in Libmodbus

Bit-based access to digital IOs

  • Bit-based function codes are # 1,2,5,15
  • The first digital input and output bits have both address 0
  • The 2nd digital input and output bits have both address 1
  • Addressing of inputs and outputs are independent (ie. there exists DI 0 and DO 0)
  • Each input/output bit consumes one member of the uint8_t dest[] array. I.e. each bit consumes one byte.

Register-based access to analog IOs

  • Register-based (16bit) function codes are # 3,4,6,16
  • The first analog input and output register have both address 0
  • Contrary to the Wago manuals the 2nd analog input and output registers have address 1 :!:

Register-based access to digital IOs

  • Access to digital inputs and outputs is also possible with the register-based function codes
  • Digital input and output addresses are automatically appended after the analog addresses. This means the digital addresses are dependend of the number of the analog devices.
  • Each digital IO consumes on bit in the uint16_t dest[] array
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.1288360601.txt.gz · Zuletzt geändert: 2010-10-29 13:56 von becki

Impressum - Datenschutzerklärung