{"id":665,"date":"2008-03-16T09:47:20","date_gmt":"2008-03-16T08:47:20","guid":{"rendered":"https:\/\/www.domedia.net\/?p=665"},"modified":"2017-07-18T09:48:04","modified_gmt":"2017-07-18T07:48:04","slug":"easy-modbus-interface-with-hvac-system-of-sauter","status":"publish","type":"post","link":"https:\/\/www.domedia.net\/?p=665&lang=en","title":{"rendered":"Easy Modbus interface with HVAC system of Sauter"},"content":{"rendered":"<p>So today I went on site for interfacing a NetLinx AMX system with Sauter HVAC system. The HVAC system is interfaced through a PC that translates internal bus to more regular Modbus\/Jbus protocol.<br \/>\n<!--more--><br \/>\nModbus is a pretty simple protocol but its implementation is not so simple due to three facts:<\/p>\n<ol>\n<li>It uses a pretty complex system to calculate a mandatory checksum at end of each message. But with help of a friend Jon, and also piece of code made by Crestron for their Modbus module, I was able to automate creation of Modbus messages in my NetLinx program. Here is result for exemple for a read command:<\/li>\n<blockquote><p>STACK_VAR<br \/>\nCHAR TEMP[6]<br \/>\nCHAR INTERRO_A_ENVOYER[8]<br \/>\nLONG TEMP_1<br \/>\nLONG XFLG<br \/>\nLONG I<br \/>\nLONG J<br \/>\nLONG CRC<br \/>\n{<br \/>\nTEMP = \u00ab\u00a01,3,0,((ETAPE-1)*4),0,2\u00a0\u00bb<br \/>\nCRC = $FFFF<br \/>\nFOR(I=1;I&lt;7;I++)<br \/>\n{<br \/>\nTEMP_1 = TEMP[I]<br \/>\nFOR(J=1;J&lt;9;J++)<br \/>\n{<br \/>\nXFLG = (CRC^TEMP_1) &amp; $0001<br \/>\nCRC = CRC &gt;&gt; 1<br \/>\nIF(XFLG&lt;&gt;0)<br \/>\n{<br \/>\nCRC = CRC ^ $A001<br \/>\n}<br \/>\nTEMP_1 = TEMP_1 \/ 2<br \/>\n}<br \/>\n}<br \/>\nI = CRC \/ 256<br \/>\nJ = CRC &#8211; (I*256)<br \/>\nINTERRO_A_ENVOYER = \u00ab\u00a0TEMP,J,I\u00a0\u00bb<br \/>\nSEND_STRING dvCLIM,INTERRO_A_ENVOYER<br \/>\n}<\/p><\/blockquote>\n<p>That sample computes automatically checksum for a read message of two bytes \ud83d\ude42<\/p>\n<li>Second problem is for answer you get back from HVAC as temperature value is coded with IEEE system. I looked at it on internet but it looks pretty complex to encode, so for now I just do a comparison between know values and it allows me to get correct value, at price of extra comparison work but it functions perfect \ud83d\ude42 If someone already did a piece of code in NetLinx to encode\/decode IEEE value, I&rsquo;m interested in !<\/li>\n<li>Last point very important with Modbus protocol is that it doesn&rsquo;t speak by itself \ud83d\ude41 So each time you want to know something you have to issue a read command. So best way is to use a timeline you run in background that continuously asks values at system so you keep always value up to date \ud83d\ude42<\/li>\n<\/ol>\n<p>Hope it helped you, and feel free to ask questions you might have in comments !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So today I went on site for interfacing a NetLinx AMX system with Sauter HVAC system. The HVAC system is interfaced through a PC that translates internal bus to more regular Modbus\/Jbus protocol.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[46],"tags":[],"class_list":["post-665","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.domedia.net\/index.php?rest_route=\/wp\/v2\/posts\/665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.domedia.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.domedia.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.domedia.net\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.domedia.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=665"}],"version-history":[{"count":1,"href":"https:\/\/www.domedia.net\/index.php?rest_route=\/wp\/v2\/posts\/665\/revisions"}],"predecessor-version":[{"id":666,"href":"https:\/\/www.domedia.net\/index.php?rest_route=\/wp\/v2\/posts\/665\/revisions\/666"}],"wp:attachment":[{"href":"https:\/\/www.domedia.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.domedia.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.domedia.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}