Phpmodbus user's guide Phpmodbus How-to Jan Krakora {@link mailto:krakora.jan@googlemail.com email} {@toc} Introduction Phpmodbus is a PHP library for the Modbus protocol. The library implements Modbus TCP/UDP master class with subset of the most used Modbus commands. The library implements: FC 1: read multiple coils FC 2: read input discretes FC 3: read multiple registers FC 4: read multiple input registers FC 5: write single coil FC 6: write single register FC 15: write multiple coils 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}] Install 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 require_once() command To create UDP Modbus master object communicating to an modbus slave e.g. at IP address 192.168.1.1 write To create TCP Modbus master use To read 5 words (10 bytes) from the device ID=0 and its memory address 12288 use try-catch method call readMultipleRegisters(0, 12288, 5); } catch (Exception $e) { // Exception processing, e.g. print error information echo $modbus; echo $e; exit; }]]> To process the function byte stream, use conversion to PHP types in For other examples see sections bellow. Examples This section presents library features and examples FC1 - read mutliple coils FC1 functionality example {@example example_fc1.php} FC2 - read input discretes FC2 functionality example {@example example_fc2.php} FC3 - read mutliple registers FC3 functionality example {@example example_fc3.php} FC4 - read multiple input registers FC4 functionality example {@example example_fc4.php} FC5 - write single coil FC5 functionality example {@example example_fc5.php} FC6 - write single register FC6 functionality example {@example example_fc6.php} FC15 - write mutliple coils FC15 functionality example {@example example_fc15.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} Back compatibility This version is back compatible to the last versions. Just use