parent
61e7a690eb
commit
4256b6cef7
@ -1,67 +1,65 @@ |
|||||||
<?php |
<?php |
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../Phpmodbus/ModbusMaster.php'; |
use PHPModbus\ModbusMaster; |
||||||
|
|
||||||
// Create Modbus object |
// Create Modbus object |
||||||
$ip = "192.192.15.51"; |
$ip = "192.192.15.51"; |
||||||
$modbus = new ModbusMaster($ip, "UDP"); |
$modbus = new ModbusMaster($ip, "UDP"); |
||||||
|
|
||||||
try { |
try { |
||||||
// FC 3 |
// FC 3 |
||||||
$moduleId = 0; |
$moduleId = 0; |
||||||
$reference = 12288; |
$reference = 12288; |
||||||
$mw0address = 12288; |
$mw0address = 12288; |
||||||
$quantity = 6; |
$quantity = 6; |
||||||
$recData = $modbus->readMultipleRegisters($moduleId, $reference, $quantity); |
$recData = $modbus->readMultipleRegisters($moduleId, $reference, $quantity); |
||||||
} |
} catch (Exception $e) { |
||||||
catch (Exception $e) { |
echo $modbus; |
||||||
echo $modbus; |
echo $e; |
||||||
echo $e; |
exit; |
||||||
exit; |
|
||||||
} |
} |
||||||
|
|
||||||
?> |
?> |
||||||
<html> |
<html> |
||||||
<head> |
<head> |
||||||
<meta http-equiv="content-type" content="text/html; charset=windows-1250"> |
<meta http-equiv="content-type" content="text/html; charset=windows-1250"> |
||||||
<meta name="generator" content="PSPad editor, www.pspad.com"> |
<meta name="generator" content="PSPad editor, www.pspad.com"> |
||||||
<title>WAGO 750-841 M-memory dump</title> |
<title>WAGO 750-841 M-memory dump</title> |
||||||
</head> |
</head> |
||||||
<body> |
<body> |
||||||
<h1>Dump of M-memory from WAGO 750-84x series coupler.</h1> |
<h1>Dump of M-memory from WAGO 750-84x series coupler.</h1> |
||||||
<ul> |
<ul> |
||||||
<li>PLC: 750-84x series</li> |
<li>PLC: 750-84x series</li> |
||||||
<li>IP: <?php echo $ip?></li>
|
<li>IP: <?php echo $ip ?></li>
|
||||||
<li>Modbus module ID: <?php echo $moduleId?></li>
|
<li>Modbus module ID: <?php echo $moduleId ?></li>
|
||||||
<li>Modbus memory reference: <?php echo $reference?></li>
|
<li>Modbus memory reference: <?php echo $reference ?></li>
|
||||||
<li>Modbus memory quantity: <?php echo $quantity?></li>
|
<li>Modbus memory quantity: <?php echo $quantity ?></li>
|
||||||
</ul> |
</ul> |
||||||
|
|
||||||
|
<h2>M-memory dump</h2> |
||||||
|
|
||||||
<h2>M-memory dump</h2> |
<table border="1px" width="400px"> |
||||||
|
<tr> |
||||||
|
<td>Modbus address</td> |
||||||
|
<td>MWx</td> |
||||||
|
<td>value</td> |
||||||
|
</tr> |
||||||
|
<?php |
||||||
|
for ($i = 0; $i < count($recData); $i += 2) { |
||||||
|
?> |
||||||
|
<tr> |
||||||
|
<td><?php echo $i + $reference ?></td>
|
||||||
|
<td>MW<?php echo ($i + $reference - $mw0address) / 2 ?></td>
|
||||||
|
<td><?php echo ($recData[$i] << 8) + $recData[$i + 1] ?></td>
|
||||||
|
</tr> |
||||||
|
<?php |
||||||
|
} |
||||||
|
?> |
||||||
|
</table> |
||||||
|
|
||||||
<table border="1px" width="400px"> |
<h2>Modbus class status</h2> |
||||||
<tr> |
|
||||||
<td>Modbus address</td> |
|
||||||
<td>MWx</td> |
|
||||||
<td>value</td> |
|
||||||
</tr> |
|
||||||
<?php |
|
||||||
for($i=0;$i<count($recData);$i+=2) { |
|
||||||
?> |
|
||||||
<tr> |
|
||||||
<td><?php echo $i+$reference?></td>
|
|
||||||
<td>MW<?php echo ($i + $reference - $mw0address)/2?></td>
|
|
||||||
<td><?php echo ($recData[$i] << 8)+ $recData[$i+1]?></td>
|
|
||||||
</tr> |
|
||||||
<?php |
|
||||||
} |
|
||||||
?> |
|
||||||
</table> |
|
||||||
|
|
||||||
<h2>Modbus class status</h2> |
<pre><?= $modbus ?></pre>
|
||||||
<?php |
|
||||||
echo $modbus; |
|
||||||
?> |
|
||||||
|
|
||||||
</body> |
</body> |
||||||
</html> |
</html> |
||||||
|
@ -1,19 +1,18 @@ |
|||||||
<?php |
<?php |
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php'; |
use PHPModbus\ModbusMasterUdp; |
||||||
|
|
||||||
// Create Modbus object |
// Create Modbus object |
||||||
$modbus = new ModbusMasterUdp("192.192.15.51"); |
$modbus = new ModbusMasterUdp("192.192.15.51"); |
||||||
|
|
||||||
try { |
try { |
||||||
// Read input discretes - FC 4 |
// Read input discretes - FC 4 |
||||||
$recData = $modbus->readMultipleInputRegisters(0, 0, 2); |
$recData = $modbus->readMultipleInputRegisters(0, 0, 2); |
||||||
} |
} catch (Exception $e) { |
||||||
catch (Exception $e) { |
// Print error information if any |
||||||
// Print error information if any |
echo $modbus; |
||||||
echo $modbus; |
echo $e; |
||||||
echo $e; |
exit; |
||||||
exit; |
|
||||||
} |
} |
||||||
|
|
||||||
var_dump($recData); |
var_dump($recData); |
@ -1,24 +1,23 @@ |
|||||||
<?php |
<?php |
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../../Phpmodbus/ModbusMasterUdp.php'; |
use PHPModbus\ModbusMasterUdp; |
||||||
|
|
||||||
// Create Modbus object |
// Create Modbus object |
||||||
$modbus = new ModbusMasterUdp("192.192.15.51"); |
$modbus = new ModbusMasterUdp("192.192.15.51"); |
||||||
|
|
||||||
// Data to be writen - TRUE, FALSE |
// Data to be writen - TRUE, FALSE |
||||||
$data_true = array(TRUE); |
$data_true = array(true); |
||||||
$data_false = array(FALSE); |
$data_false = array(false); |
||||||
|
|
||||||
try { |
try { |
||||||
// Write single coil - FC5 |
// Write single coil - FC5 |
||||||
$modbus->writeSingleCoil(0, 12288, $data_true); |
$modbus->writeSingleCoil(0, 12288, $data_true); |
||||||
$modbus->writeSingleCoil(0, 12289, $data_false); |
$modbus->writeSingleCoil(0, 12289, $data_false); |
||||||
$modbus->writeSingleCoil(0, 12290, $data_true); |
$modbus->writeSingleCoil(0, 12290, $data_true); |
||||||
$modbus->writeSingleCoil(0, 12291, $data_false); |
$modbus->writeSingleCoil(0, 12291, $data_false); |
||||||
} |
} catch (Exception $e) { |
||||||
catch (Exception $e) { |
// Print error information if any |
||||||
// Print error information if any |
echo $modbus; |
||||||
echo $modbus; |
echo $e; |
||||||
echo $e; |
exit; |
||||||
exit; |
|
||||||
} |
} |
||||||
|
@ -1,26 +1,22 @@ |
|||||||
<?php |
<?php |
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../Phpmodbus/ModbusMaster.php'; |
use PHPModbus\ModbusMaster; |
||||||
|
|
||||||
// Create Modbus object |
// Create Modbus object |
||||||
$modbus = new ModbusMaster("192.192.15.51", "UDP"); |
$modbus = new ModbusMaster("192.192.15.51", "UDP"); |
||||||
|
|
||||||
// Data to be writen |
// Data to be writen |
||||||
$data = array(-1000); |
$data = array(-1000); |
||||||
$dataTypes = array("INT"); |
|
||||||
|
|
||||||
try { |
try { |
||||||
// FC6 |
// FC6 |
||||||
$modbus->writeSingleRegister(0, 12288, $data, $dataTypes); |
$modbus->writeSingleRegister(0, 12288, $data); |
||||||
} |
} catch (Exception $e) { |
||||||
catch (Exception $e) { |
// Print error information if any |
||||||
// Print error information if any |
echo $modbus; |
||||||
echo $modbus; |
echo $e; |
||||||
echo $e; |
exit; |
||||||
exit; |
|
||||||
} |
} |
||||||
|
|
||||||
// Print status information |
// Print status information |
||||||
echo $modbus; |
echo $modbus; |
||||||
|
|
||||||
?> |
|
Loading…
Reference in new issue