Phpmodbus user's guide
Phpmodbus How-to
Jan Krakora
{@link mailto:jak.krakora@wago.com email}
{@toc}
Introduction
Phpmodbus is a PHP library for the Modbus protocol. The library implements
Modbus UDP master class with subset of the most used Modbus commands.
The library implements:
FC 3: read multiple registers
FC 16: write multiple registers
FC 23: read write registers
For more about Modbus protocol see [{@link http://www.modbus.org}] or
[{@link http://en.wikipedia.org/wiki/Modbus Wiki}]
Developed with support of
{@link http://www.wago.com}.
Installation
At the first, it is supposed an PHP solution has been already installed on
your server (LAMP, WAMP, MSS+CGI etc.).
Copy the Phpmodbus library to your PHP project folder.
Create a PHP script and assign the library using
To create the Modbus master object, that will communicate with a Modbus slave
at IP address 192.168.1.1, write
To read 5 words (10 bytes) located at the memory beginning at address = 12288 of
the devide with Modbus ID=0 use
readMultipleRegisters(0, 12288, 5); ]]>
For other examples see sections bellow.
Examples
This section presents library features and examples
FC3 - read mutliple registers
FC3 functionality example
{@example example_fc3.php}
FC16 - write mutliple registers
FC16 functionality example
{@example example_fc16.php}
FC23 - read write registers
FC23 functionality example
{@example example_fc23.php}
Dump of M-memory from WAGO 750-84x series coupler.
Dump of M-memory from WAGO 750-84x series coupler.
{@example example_750841_Mmemory.php}
Data conversion to PHP types.
Conversion of the data bytes, received from Modbus, to a PHP type.
{@example example_datatype.php}