<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Protokół Modbus/TCP w modułach pomiarowych ADAM</title>
<meta name="keywords" content="Moduły pomiarowe kontrolno-pomiarowe moduł pomiarowy kontrolno-pomiarowy ADAM USB I/O Advantech">
<meta name="description" content="Moduły pomiarowe kontrolno-pomiarowe moduł pomiarowy kontrolno-pomiarowy ADAM USB I/O Advantech">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<meta name="author" content="Jacek Bonecki - Elmark Automatyka Sp. z o.o. - http://www.elmark.com.pl">
<meta name="verify-v1" content="dFPC/7SMwqEjaoI9PbBxgMy61Tm7deLBY7wDvMEdY3E=">
<style type="text/css">
<!--
a:HOVER{TEXT-DECORATION:UNDERLINE;}
a {TEXT-DECORATION:none}
.vlrbt {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-BOTTOM-WIDTH:1px;BORDER-BOTTOM-STYLE:solid;BORDER-BOTTOM-COLOR:#C0C0C0;BORDER-RIGHT-WIDTH:1px;BORDER-RIGHT-STYLE:solid;BORDER-RIGHT-COLOR:#C0C0C0;BORDER-LEFT-WIDTH:1px;BORDER-LEFT-STYLE:solid;BORDER-LEFT-COLOR:#C0C0C0;BORDER-TOP-WIDTH:1px;BORDER-TOP-STYLE:solid;BORDER-TOP-COLOR:#C0C0C0;}
.vrbt {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-BOTTOM-WIDTH:1px;BORDER-BOTTOM-STYLE:solid;BORDER-BOTTOM-COLOR:#C0C0C0;BORDER-RIGHT-WIDTH:1px;BORDER-RIGHT-STYLE:solid;BORDER-RIGHT-COLOR:#C0C0C0;BORDER-TOP-WIDTH:1px;BORDER-TOP-STYLE:solid;BORDER-TOP-COLOR:#C0C0C0;}
.vlbt {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-BOTTOM-WIDTH:1px;BORDER-BOTTOM-STYLE:solid;BORDER-BOTTOM-COLOR:#C0C0C0;BORDER-LEFT-WIDTH:1px;BORDER-LEFT-STYLE:solid;BORDER-LEFT-COLOR:#C0C0C0;BORDER-TOP-WIDTH:1px;BORDER-TOP-STYLE:solid;BORDER-TOP-COLOR:#C0C0C0;}
.vlrt {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-TOP-WIDTH:1px;BORDER-TOP-STYLE:solid;BORDER-TOP-COLOR:#C0C0C0;BORDER-RIGHT-WIDTH:1px;BORDER-RIGHT-STYLE:solid;BORDER-RIGHT-COLOR:#C0C0C0;BORDER-LEFT-WIDTH:1px;BORDER-LEFT-STYLE:solid;BORDER-LEFT-COLOR:#C0C0C0;}
.vlrb {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-BOTTOM-WIDTH:1px;BORDER-BOTTOM-STYLE:solid;BORDER-BOTTOM-COLOR:#C0C0C0;BORDER-RIGHT-WIDTH:1px;BORDER-RIGHT-STYLE:solid;BORDER-RIGHT-COLOR:#C0C0C0;BORDER-LEFT-WIDTH:1px;BORDER-LEFT-STYLE:solid;BORDER-LEFT-COLOR:#C0C0C0;}
.vlr {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-RIGHT-WIDTH:1px;BORDER-RIGHT-STYLE:solid;BORDER-RIGHT-COLOR:#C0C0C0;BORDER-LEFT-WIDTH:1px;BORDER-LEFT-STYLE:solid;BORDER-LEFT-COLOR:#C0C0C0;}
.vbt {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-BOTTOM-WIDTH:1px;BORDER-BOTTOM-STYLE:solid;BORDER-BOTTOM-COLOR:#C0C0C0;BORDER-TOP-WIDTH:1px;BORDER-TOP-STYLE:solid;BORDER-TOP-COLOR:#C0C0C0;}
.vrb {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-BOTTOM-WIDTH:1px;BORDER-BOTTOM-STYLE:solid;BORDER-BOTTOM-COLOR:#C0C0C0;BORDER-RIGHT-WIDTH:1px;BORDER-RIGHT-STYLE:solid;BORDER-RIGHT-COLOR:#C0C0C0;}
.vrt {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-RIGHT-WIDTH:1px;BORDER-RIGHT-STYLE:solid;BORDER-RIGHT-COLOR:#C0C0C0;BORDER-TOP-WIDTH:1px;BORDER-TOP-STYLE:solid;BORDER-TOP-COLOR:#C0C0C0;}
.vlb {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-BOTTOM-WIDTH:1px;BORDER-BOTTOM-STYLE:solid;BORDER-BOTTOM-COLOR:#C0C0C0;BORDER-LEFT-WIDTH:1px;BORDER-LEFT-STYLE:solid;BORDER-LEFT-COLOR:#C0C0C0;}
.vlt {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-LEFT-WIDTH:1px;BORDER-LEFT-STYLE:solid;BORDER-LEFT-COLOR:#C0C0C0;BORDER-TOP-WIDTH:1px;BORDER-TOP-STYLE:solid;BORDER-TOP-COLOR:#C0C0C0;}
.vl {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-LEFT-WIDTH:1px;BORDER-LEFT-STYLE:solid;BORDER-LEFT-COLOR:#C0C0C0;}
.vr {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-RIGHT-WIDTH:1px;BORDER-RIGHT-STYLE:solid;BORDER-RIGHT-COLOR:#C0C0C0;}
.vb {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-BOTTOM-WIDTH:1px;BORDER-BOTTOM-STYLE:solid;BORDER-BOTTOM-COLOR:#C0C0C0;}
.vt {FONT-FAMILY:Tahoma;FONT-SIZE:10px;BORDER-TOP-WIDTH:1px;BORDER-TOP-STYLE:solid;BORDER-TOP-COLOR:#C0C0C0;}
.v {FONT-FAMILY:Tahoma;FONT-SIZE:10px;}
.myframe {FONT-FAMILY:Tahoma;FONT-SIZE:10px;PADDING-RIGHT:10px;PADDING-LEFT:10px;PADDING-BOTTOM:0px;PADDING-TOP:0px;}
.myframe SPAN.CTOP {MARGIN:0px -10px}
.myframe SPAN.CBOT {MARGIN:0px -10px}
SPAN.CTOP {DISPLAY:BLOCK;FONT-SIZE:1px;LINE-HEIGHT:1px;BACKGROUND-REPEAT:no-repeat;HEIGHT:5px}
SPAN.CBOT {DISPLAY:BLOCK;FONT-SIZE:1px;LINE-HEIGHT:1px;BACKGROUND-REPEAT:no-repeat;HEIGHT:5px}
SPAN.CTOP SPAN {DISPLAY:BLOCK;FONT-SIZE:1px;LINE-HEIGHT:1px;BACKGROUND-REPEAT:no-repeat;HEIGHT:5px}
SPAN.CBOT SPAN {DISPLAY:BLOCK;FONT-SIZE:1px;LINE-HEIGHT:1px;BACKGROUND-REPEAT:no-repeat;HEIGHT:5px}
SPAN.CTOP {BACKGROUND-POSITION:0px 0px;BACKGROUND-IMAGE:none;MARGIN:0px -5px}
SPAN.CTOP SPAN {BACKGROUND-POSITION:100% 0px;BACKGROUND-IMAGE:none}
SPAN.CBOT {CLEAR:both;BACKGROUND-POSITION:0px 100%;BACKGROUND-IMAGE:none;MARGIN:0px -5px}
SPAN.CBOT SPAN {BACKGROUND-POSITION:100% 100%;BACKGROUND-IMAGE:none}
SPAN.CTOP {BACKGROUND-IMAGE:URL(IMG/C1.PNG)}
SPAN.CTOP SPAN {BACKGROUND-IMAGE:URL(IMG/C2.PNG)}
SPAN.CBOT {BACKGROUND-IMAGE:URL(IMG/C3.PNG)}
SPAN.CBOT SPAN {BACKGROUND-IMAGE:URL(IMG/C4.PNG)}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#000080" vlink="#000080" alink="#000080" leftmargin="10" topmargin="10">
<table align=center width=1000 bgcolor=#000080 cellpadding=0 cellspacing=0 border=0><tr><td align=left><a href=/><img src=img/top.jpg border=0 width=800 height=65></a></td></tr></table>
<table align=center width=1000 border=0 cellpadding=5 cellspacing=0 style="font-family:tahoma;font-size:10px;"><tr>
<td width=1 valign=top align=center class=vlrbt>
<a target=_blank href=http://www.elmark.com.pl/products/advantech/grupa.php?grupa=1><img src=img/elmark.gif width=200 height=66 border=0 alt="Elmark Automatyka Sp. z o.o."></a><br>
<img src=img/blank.gif width=200 height=5><table cellpadding=3 cellspacing=0 width=200 style="font-family:tahoma;font-size:10px;">
<tr><td bgcolor=#000080><b><font color=#FFFFFF>Menu...</font></b></td></tr>
</table>
<table cellpadding=3 cellspacing=0 width=200 class=vlrb>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=0>Strona główna</a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=1>O nas: Elmark Automatyka Sp. z o.o.</a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=http://www.elmark.com.pl/forum/ target=_blank>Nasze forum</a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=2>Inne/ciekawe strony www</a></td></tr>
</table>
<img src=img/blank.gif width=200 height=5><table cellpadding=3 cellspacing=0 width=200 style="font-family:tahoma;font-size:10px;">
<tr><td bgcolor=#000080><b><font color=#FFFFFF>Artykuły...</font></b></td></tr>
</table>
<table cellpadding=3 cellspacing=0 width=200 class=vlrb>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=101>P2P i GCL w serii ADAM-6000</a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=102>Seria EKI-122X - konwertery Modbus</a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=103>WIRE-CHIP, JAZZ i moduły ADAM</a></td></tr>
</table>
<img src=img/blank.gif width=200 height=5><table cellpadding=3 cellspacing=0 width=200 style="font-family:tahoma;font-size:10px;">
<tr><td bgcolor=#000080><b><font color=#FFFFFF>O czym warto wiedzieć...</font></b></td></tr>
</table>
<table cellpadding=3 cellspacing=0 width=200 class=vlrb>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=201>Protokół ADAM-ASCII</a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=202>Protokół Modbus</a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=203>Implementacja Modbus/RTU</a></td></tr>
<tr><td bgcolor=#FFFF9F>Implementacja Modbus/TCP</td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=205>Wyjścia przekaźnikowe</a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=206>Seria ADAM-6000 i język PHP</a></td></tr>
</table>
<img src=img/blank.gif width=200 height=5><table cellpadding=3 cellspacing=0 width=200 style="font-family:tahoma;font-size:10px;">
<tr><td bgcolor=#000080><b><font color=#FFFFFF>Najpopularniejsze modele...</font></b></td></tr>
</table>
<table cellpadding=3 cellspacing=0 width=200 class=vlrb>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=301>ADAM-4520<font color=#BBBBBB> Optoizolowany<br>konwerter RS-232/422/485</font></a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=302>ADAM-4017+<br><font color=#BBBBBB>Wejścia analogowe (RS-485)</font></a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=303>ADAM-4055<br><font color=#BBBBBB>We/wy cyfrowe (RS-485)</font></a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=304>ADAM-5000/TCP<br><font color=#BBBBBB>Kaseta Modbus/TCP</font></a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=305>ADAM-6017<br><font color=#BBBBBB>Wejścia analogowe</font></a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=306>ADAM-6060<br><font color=#BBBBBB>We/wy cyfrowe (przekaźnikowe)</font></a></td></tr>
<tr><td bgcolor=#F4F4F4 onmouseover="this.style.backgroundColor='#CADCEB'" onmouseout="this.style.backgroundColor='#F4F4F4'"><a href=307>USB-4711A<font color=#BBBBBB> Uniwersalny<br>moduł pomiarowy AI/AO/DI/DO</font></a></td></tr>
</table>
</td>
<td valign=top align=center class=vrbt>
<table width=100% cellpadding=20 cellspacing=0 border=0 style="font-family:tahoma;font-size:12px;">
	<tr>
	<td> 
	<div class="myframe" style="FONT-SIZE:14px;BACKGROUND-COLOR:#EBF3F8;COLOR:#000080;">
	<span class="ctop"><span></span></span>
	<b>Protokół Modbus/TCP</b><br>Czyli komunikacja w sieci Ethernet
	<span class="cbot"><span></span></span>
	</div>
	<br>
	<p align=justify>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	W implementacji TCP/IP zrezygnowano z pola adresowego (w odwołaniach Modbus/TCP adres urządzeń, do których kierowane
	jest zapytanie jednoznacznie określa już przy samym nawiązywaniu połączenia docelowy adres IP) i sumy kontrolnej. Wprowadzono
	natomiast rozszerzony nagłówek MBAP (Modbus Application Protocol Header) zawierający cztery pola:<br>
	<br>
	&#8226; <b>identyfikator transakcji</b> (2 bajty) - wykorzystywany przez urządzenie master do prawidłowego kojarzenia odpowiedzi
	uzyskiwanych na jego kolejne zapytania (wartość ta zostaje ustalona i umieszczona w ramce zapytania przez jednostkę master,
	a następnie skopiowana i umieszczona w ramce odpowiedzi przez jednostkę slave)<br>
	&#8226; <b>identyfikator protokołu</b> (2 bajty) - pole to ma zawsze wartość 0 odpowiadającą oznaczeniu protokołu Modbus<br>
	&#8226; <b>rozmiar wiadomości</b> (2 bajty) - liczba pozostałych bajtów wiadomości (poczynając od pola identyfikatora urządzenia; pole to
	zostało wprowadzone ze względu na możliwość dzielenia pojedynczej wiadomości na oddzielne pakiety TCP/IP)<br>
	&#8226; <b>identyfikator urządzenia</b> (1 bajt) - odgrywający znaczenie np. w przypadku komunikacji z urządzeniami Modbus wyposażonymi
	w interfejs szeregowy za pomocą bram (Modbus Data Gateway)<br>
	<br>
	<img src=cowartowiedziec/modbus-tcp.gif width=663 height=193 border=1>
	<p align=justify>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	Odnośnie wykorzystywanych funkcji i ich parametrów: obowiązują oczywiście te przedstawione wcześniej - jak w przypadku
	implementacji RTU (np. dla modułów serii ADAM-4000). Podobnie jak w przypadku Modbus/RTU musimy oczywiście także posiadać informacje
	na temat listy adresów rejestrów naszego urzadzenia. Dla dwóch najpopularniejszych reprezentantów serii ADAM-6000 i wybranych
	ich rejestrów będą to:<br>
	<br>
	<table cellpadding=3 cellspacing=0>
	<tr><td class=vlrbt colspan=3 style="BACKGROUND-COLOR:#FFFF9F;COLOR:#000000;FONT-WEIGHT:bold;">ADAM-6017</td></tr>
	<tr><td class=vlrb>40001-40008</td><td class=vrb>AI0-AI7 Current Value</td><td class=vrb>R</td></tr>
	<tr><td class=vlrb>40011-40018</td><td class=vrb>AI0-AI7 Max Value</td><td class=vrb>R</td></tr>
	<tr><td class=vlrb>40021-40028</td><td class=vrb>AI0-AI7 Min Value</td><td class=vrb>R</td></tr>
	<tr><td class=vlrb>00101-00108</td><td class=vrb>AI0-AI7 Max Value Reset</td><td class=vrb>R/W</td></tr>
	<tr><td class=vlrb>00111-00118</td><td class=vrb>AI0-AI7 Min Value Reset</td><td class=vrb>R/W</td></tr>
	<tr><td class=vlrb>00131-00138</td><td class=vrb>AI0-AI7 HI Alarm Flag</td><td class=vrb>R</td></tr>
	<tr><td class=vlrb>00141-00148</td><td class=vrb>AI0-AI7 LO Alarm Flag</td><td class=vrb>R</td></tr>
	<tr><td class=v colspan=3>&nbsp;</td></tr>
	<tr><td class=vlrbt colspan=3 style="BACKGROUND-COLOR:#FFFF9F;COLOR:#000000;FONT-WEIGHT:bold;">ADAM-6060</td></tr>
	<tr><td class=vlrb>00001-00006</td><td class=vrb>DI0-DI5</td><td class=vrb>R</td></tr>
	<tr><td class=vlrb>00017-00022</td><td class=vrb>DO0-DO5</td><td class=vrb>R/W</td></tr>
	<tr><td class=vlrb>40001</td><td class=vrb>CNT0</td><td class=vrb>R (32bit)</td></tr>
	<tr><td class=vlrb>00033</td><td class=vrb>CNT0 Start[1]/Stop[0]</td><td class=vrb>W</td></tr>
	<tr><td class=vlrb>00034</td><td class=vrb>CNT0 Clear[1]</td><td class=vrb>W</td></tr>
	</table>
	<br>
	W przypadku kasety komunikacyjnej <b>ADAM-5000/TCP</b> adresy przypisane są natomiast do poszczególnych jej slotów:<br>
	<br>
	<table cellpadding=3 cellspacing=0>
	<tr style="BACKGROUND-COLOR:#FFFF9F;COLOR:#000000;FONT-WEIGHT:bold;"><td class=vlrbt>Slot number</td><td class=vrbt>Analog I/O</td><td class=vrbt>Digital I/O</td></tr>
	<tr><td class=vlrb align=center>0</td><td class=vrb>40001&divide;40008</td><td class=vrb>00001&divide;00016</td></tr>
	<tr><td class=vlrb align=center>1</td><td class=vrb>40009&divide;40016</td><td class=vrb>00017&divide;00032</td></tr>
	<tr><td class=vlrb align=center>2</td><td class=vrb>40017&divide;40024</td><td class=vrb>00033&divide;00048</td></tr>
	<tr><td class=vlrb align=center>3</td><td class=vrb>40025&divide;40032</td><td class=vrb>00049&divide;00064</td></tr>
	<tr><td class=vlrb align=center>4</td><td class=vrb>40033&divide;40040</td><td class=vrb>00065&divide;00080</td></tr>
	<tr><td class=vlrb align=center>5</td><td class=vrb>40041&divide;40048</td><td class=vrb>00081&divide;00096</td></tr>
	<tr><td class=vlrb align=center>6</td><td class=vrb>40049&divide;40056</td><td class=vrb>00097&divide;00112</td></tr>
	<tr><td class=vlrb align=center>7</td><td class=vrb>40057&divide;40064</td><td class=vrb>00113&divide;00128</td></tr>
	</table>
	<br>
	Przykładowe transakcje Modbus/TCP będą więc wyglądały następująco:<br>
	<br>
	&#8226; Odczyt wartości wejścia analogowego AI-0 dla modułu <b>ADAM-6017</b>:<br>
	<br>
	<table cellpadding=2 cellspacing=0><tr>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>03</td><td class=vrbt>00-00</td><td class=vrbt>00-01</td>
	<td class=v width=20 align=center> -> </td>
	<td class=vlrbt>45-72-00-00-00-05</td><td class=vrbt>01</td><td class=vrbt>03</td><td class=vrbt>02</td><td class=vrbt bgcolor=#F0F0F0>B8-FA</td>
	</tr></table>
	<br>
	&#8226; Odczyt stanu DI2-DI5 w module <b>ADAM-6060</b>:<br>
	<br>
	<table cellpadding=2 cellspacing=0><tr>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>02</td><td class=vrbt>00-02</td><td class=vrbt>00-04</td>
	<td class=v width=20 align=center> -> </td>
	<td class=vlrbt>45-72-00-00-00-04</td><td class=vrbt>01</td><td class=vrbt>02</td><td class=vrbt>01</td><td class=vrbt bgcolor=#F0F0F0>0F</td>
	</tr></table>
	<br>
	&#8226; Odczyt zawartości licznika CNT0 (DI0) w module <b>ADAM-6060</b>:<br>
	<br>
	<table cellpadding=2 cellspacing=0><tr>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>03</td><td class=vrbt>00-00</td><td class=vrbt>00-02</td>
	<td class=v width=20 align=center> -> </td>
	<td class=vlrbt>45-72-00-00-00-07</td><td class=vrbt>01</td><td class=vrbt>03</td><td class=vrbt>04</td><td class=vrbt bgcolor=#F0F0F0>00-19-00-00</td>
	</tr></table>
	<br>
	&#8226; Skasowanie zawartości licznika CNT0 (na DI0) w module <b>ADAM-6060</b>:<br>
	<br>
	<table cellpadding=2 cellspacing=0><tr>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>05</td><td class=vrbt>00-21</td><td class=vrbt>FF-00</td>
	<td class=v width=20 align=center> -> </td>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>05</td><td class=vrbt>00-21</td><td class=vrbt>FF-00</td>
	</tr></table>
	<br>
	&#8226; Wyłączenie/włączenie licznika CNT0 (na DI0) w module <b>ADAM-6060</b>:<br>
	<br>
	<table cellpadding=2 cellspacing=0><tr>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>05</td><td class=vrbt>00-20</td><td class=vrbt>00-00</td>
	<td class=v width=20 align=center> -> </td>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>05</td><td class=vrbt>00-20</td><td class=vrbt>00-00</td>
	</tr></table>
	<br>
	<table cellpadding=2 cellspacing=0><tr>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>05</td><td class=vrbt>00-20</td><td class=vrbt>FF-00</td>
	<td class=v width=20 align=center> -> </td>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>05</td><td class=vrbt>00-20</td><td class=vrbt>FF-00</td>
	</tr></table>
	<br>
	&#8226; Ustawienie wartości <b>7.000V</b> dla wyjścia analogowego <b>A03</b> w module <b>ADAM-5024</b> (slot 2 kasety <b>ADAM-5000/TCP</b>):<br>
	<br>
	<table cellpadding=2 cellspacing=0><tr>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>06</td><td class=vrbt>00-13</td><td class=vrbt>0B-32</td>
	<td class=v width=20 align=center> -> </td>
	<td class=vlrbt>45-72-00-00-00-06</td><td class=vrbt>01</td><td class=vrbt>06</td><td class=vrbt>00-13</td><td class=vrbt>0B-32</td>
	</tr></table>
	<br>
	gdzie:<br>
	<br>
	&nbsp;&nbsp;&nbsp;- adres rejestru pobrany ze schematu adresowania (40020 -> 0x0013)<br>
	&nbsp;&nbsp;&nbsp;- wartość docelowa rejestru obliczona jako 7/10*4095=2866=0x0B32<br>
	&nbsp;&nbsp;&nbsp;- wykorzystana nie opisana tutaj dotychczas funkcja 0x06 - <b>Write Single Register</b>:<br>
	<br>
	<table cellpadding=2 cellspacing=0>
	<tr><td class=vlrbt style="BACKGROUND-COLOR:#FFFF9F;COLOR:#000000;FONT-WEIGHT:bold;" colspan=4>Write Single Register - struktura zapytania</b></td></tr>
	<tr><td class=vlrb colspan=2>FUNCTION CODE</td><td class=vrb width=60>1 bajt</td><td class=vrb width=100>0x06</td></tr>
	<tr><td class=vlrb rowspan=2 width=80>DATA</td><td class=vrb width=200>Register Address</td><td class=vrb>2 bajty</td><td class=vrb>0x0000-0xFFFF</td></tr>
	<tr><td class=vrb>Register Value</td><td class=vrb>2 bajty</td><td class=vrb>0x0000-0xFFFF</td></tr>
	</table>
	<br>
	<table cellpadding=2 cellspacing=0>
	<tr><td class=vlrbt style="BACKGROUND-COLOR:#FFFF9F;COLOR:#000000;FONT-WEIGHT:bold;" colspan=4>Write Single Register - struktura odpowiedzi</td></tr>
	<tr><td class=vlrb colspan=2>FUNCTION CODE</td><td class=vrb width=60>1 bajt</td><td class=vrb width=100>0x06</td></tr>
	<tr><td class=vlrb rowspan=2 width=80>DATA</td><td class=vrb width=200>Register Address</td><td class=vrb>2 bajty</td><td class=vrb>0x0000-0xFFFF</td></tr>
	<tr><td class=vrb>Register Value</td><td class=vrb>2 bajty</td><td class=vrb>0x0000-0xFFFF</td></tr>
	</table>
	<br>
	<hr size=1>
	<p align=justify>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	Na podstawie powyższych informacji możemy już ponownie próbować zaimplementować ten protokół w naszej aplikacji. Nasza
	<b><u>bardzo prosta</u></b> procedura ustawiająca wyjście cyfrowe DO-0 w module <b>ADAM-6060</b> o adresie IP=192.168.2.130,
	korzystająca z gotowej kontrolki ClientSocket mógłaby więc wyglądać następująco:<br>
	<br>
	
	<div class="myframe" style="FONT-SIZE:12px;BACKGROUND-COLOR:#DCDCDC;COLOR:#000000;">
	<span class="ctop"><span></span></span>
	procedure <b>DO0ON</b>;<br>
	var start,aktu:word;<br>
	komenda:string;<br>
	begin<br>
	//KONFIGURACJA GNIAZDA<br>
	Clientsocket1.Address:='192.168.2.130';<br>
	Clientsocket1.Port:=502;<br>
	//NAWIĄZANIE POŁĄCZENIA<br>
	Clientsocket1.Open;<br>
	start:=gettickcount;<br>
	repeat<br>
  	&nbsp;&nbsp;&nbsp;aktu:=gettickcount;<br>
	&nbsp;&nbsp;&nbsp;Application.ProcessMessages;<br>
	until (aktu-start>500)or(Clientsocket1.Socket.Connected=true);<br>
	if aktu-start>500 then<br>
	&nbsp;&nbsp;&nbsp;begin<br>
	&nbsp;&nbsp;&nbsp;ShowMessage('Połączenie nie zostało nawiązane...');<br>
	&nbsp;&nbsp;&nbsp;exit;<br>
      &nbsp;&nbsp;&nbsp;end;<br>
	//KOMENDA=MBAP+ID+FUNCTIONCODE+DATA<br>
	komenda:=chr($AA)+chr($BB)+chr($00)+chr($00)+chr($00)+chr($06)+chr($01)+chr($05)+chr($00)+chr($10)+chr($FF)+chr($00);<br>
	//WYSŁANIE KOMENDY (ZAPYTANIA)<br>
	Clientsocket1.Socket.SendText(komenda);<br>
	//ZERWANIE POŁĄCZENIA<br>
	Clientsocket1.Close;<br>
	end;<br>
	<span class="cbot"><span></span></span>
	</div>


	
	</td>
	</tr>
</table>

	<!--
	Szablon transakcji
	<table cellpadding=2 cellspacing=0><tr>
	<td class=vlrbt>?</td><td class=vrbt>?</td><td class=vrbt>?</td><td class=vrbt>?</td><td class=vrbt>?</td><td class=vrbt>?</td><td class=vrbt>?</td>
	<td class=v width=20 align=center> -> </td>
	<td class=vlrbt>?</td><td class=vrbt>?</td><td class=vrbt>?</td><td class=vrbt>?</td><td class=vrbt>?</td><td class=vrbt>?</td><td class=vrbt>?</td>
	</tr></table>
	-->
<br><div align=left class="myframe" style="WIDTH:738px;FONT-SIZE:11px;BACKGROUND-COLOR:#EBF3F8;COLOR:#000080;">
<span class="ctop"><span></span></span>
<b>Jeśli masz jakieś uwagi - możesz dodać swój komentarz do tej strony.</b><br>
<font color=#9EC5DE>Możesz go dopisać anonimowo - ale oczywiście lepiej by było, gdyby czytający wiedzieli kto jest jego autorem.
W przypadku wykrycia treści niedozwolonych lub nic konkretnego do tematu nie wnoszących, wpis może być w późniejszym czasie usunięty (ocenzurowany) przez administratora.</font><br>
<br><table cellpadding=2 cellspacing=0 border=0><form name=fn1 method=post>
<input type=hidden name=fv0 value="204">
<input type=hidden name=fv5 value="af1fdf1b119c70fc8c96fc4fb3777d91">
<tr valign=middle><td class=v width=90><b>Autor:</b></td><td>&nbsp;&nbsp;&nbsp;<input maxlength=30 class=vlrbt type=text name=fv1 value="" style="width:200px;BACKGROUND-COLOR:#FFFFFF;"></td><td rowspan=2>&nbsp;</td><td rowspan=2><img src=img/sesssecimg.php width=140 height=35 style="BORDER-WIDTH:1px;BORDER-STYLE:dotted;BORDER-COLOR:#C0C0C0;"></td></tr>
<tr valign=middle><td class=v><b>Firma:</b></td><td>&nbsp;&nbsp;&nbsp;<input maxlength=30 class=vlrbt type=text name=fv2 value="" style="width:200px;BACKGROUND-COLOR:#FFFFFF;"></td></tr>
<tr valign=middle><td class=v><b>Twój e-mail:</b></td><td>&nbsp;&nbsp;&nbsp;<input maxlength=30 class=vlrbt type=text name=fv3 value="" style="width:200px;BACKGROUND-COLOR:#FFFFFF;"></td><td class=v width=90><b>Kod z obrazka</b>:</td><td><input maxlength=8 class=vlrbt type=text name=fv6 style="width:100px;BACKGROUND-COLOR:#FFFFFF;"></td></tr>
<tr valign=top><td class=v><b>Komentarz:</b></td><td colspan=3>&nbsp;&nbsp;&nbsp;<textarea maxlength=30 class=vlrbt name=fv4 style="width:620px;height:100px;BACKGROUND-COLOR:#FFFFFF;"></textarea></td></tr>
<tr valign=top><td class=v colspan=4><input class=vlrbt type=button onClick="javascript:WriteComment()"value=Wyślij style="WIDTH:70px;"></td></tr>
</form>
</table><span class="cbot"><span></span></span>
</div><table cellpadding=0 cellspacing=0><tr><td><img src=img/blank.gif width=10 height=3 border=0></tr></td></table>
<script language="JavaScript" type="text/javascript">
<!--
function WriteComment()
{
if (document.fn1.fv6.value.length!=8) {alert('Przepisz kod zabezpieczający - w postaci ośmiocyfrowej liczby - z umieszczonego w formularzu obrazka.');return;};
if (isNaN(document.fn1.fv6.value)) {alert('Kod zabezpieczający jest ośmiocyfrową liczbą - więc może się składać tylko z cyfr.');return;};
if (document.fn1.fv6.value<0) {alert('Kod zabezpieczający jest ośmiocyfrową liczbą większą od 0.');return;};
if (document.fn1.fv4.value.length<15) {alert('Jakiś komentarz wpisać musisz - przyjmijmy, że będzie to minimum 15 znaków.');return;};
if (document.fn1.fv4.value.length>1024) {alert('Długość komentarza nie może przekaczać 1024 znaków!');return;};
document.fn1.submit();
}
// -->
</script>
</td>
</tr></table><br><br>
</body>
</html>

