先看一各种设备连接的示意图,第一张是连线图,第二张图是两路继电器的背面,是默认的常开和常关接口可以根据需要接入对应的线。第三图是WEB控制界面的图。
首页index.php代码:
<?
date_default_timezone_set ("PRC");//设置时区
set_time_limit(0);
ini_set('memory_limit','1024M');
header("Content-Type: text/html;charset=GB2312");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="jquery.min.js"></script>
<script>
function tcp_control(zhiling,type){
$("#status").html('正在读取数据,请稍后...');
//版本所有,李雷博客 www.mdaima.com
var ajaxform=$.post("rs485-ajax.php",{zhiling:zhiling,type:type},function(result){
var give_strs= new Array(); //定义一数组
give_strs=result.split("|"); //字符分割
if (give_strs[0]=="ok"){
if (zhiling=='wendu'){
$("#shidu").html(give_strs[1]);
$("#wendu").html(give_strs[2]);
$("#status").html('<span style=color:gre