{"id":2271,"date":"2025-04-15T09:25:43","date_gmt":"2025-04-15T09:25:43","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=2271"},"modified":"2025-06-11T05:35:14","modified_gmt":"2025-06-11T05:35:14","slug":"modbus-master-control-script-commands","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/","title":{"rendered":"ModBus Master control script commands"},"content":{"rendered":"\n<p><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/serial-communications\/modbus\/\">ModBus tutoria<\/a>l<\/p>\n\n\n\n<p>ModBus script commands are stored as table entries in\u00a0<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o2970\">NVEM<\/a>\u00a0page 0. In the following pages, each command consists of a 1-byte numeric command code followed by 0 to several parameters. 16 bit parameters have &#8217;16&#8217; as part of their name. Other parameters are 8-bit.<\/p>\n\n\n\n<p>Command codes less than 128 map to the same-numbered ModBus function. Codes 128 and over provide internal functions.<\/p>\n\n\n\n<p>Here are a list of equates in SPLat format:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><br>;--MODBUS function codes<br>MBkFunc_ReadCoils                EQU   1              ;ReadCoils,    SlaveAddr,  #SrcAddr,   ItemCount,   #SPLatRAM16<br>MBkFunc_ReadDiscreteInputs       EQU   2              ;ReadInputs,   SlaveAddr,  #SrcAddr,   ItemCount,   #SPLatRAM16<br>MBkFunc_ReadHoldingRegisters     EQU   3              ;ReadHReg,     SlaveAddr,  #SrcAddr,   ItemCount,   #SPLatRAM16, NumFormat<br>MBkFunc_ReadInputRegisters       EQU   4              ;ReadInputs,   SlaveAddr,  #SrcAddr,   ItemCount,   #SPLatRAM16, NumFormat<br>MBkFunc_WriteSingleCoil          EQU   5              ;WriteCoil,    SlaveAddr,  #DstAddr,   #SPLatRAM16<br>MBkFunc_WriteSingleRegister      EQU   6              ;WriteHReg,    SlaveAddr,  #DstAddr,   #SPLatRAM16, NumFormat<br>MBkFunc_WriteMultipleCoils       EQU   15             ;WriteCoils,   SlaveAddr,  #DstAddr,   ItemCount,   #SPLatRAM16<br>MBkFunc_WriteMultipleRegisters   EQU   16             ;WriteMultReg, SlaveAddr,  #DstAddr,   ItemCount,   #SPLatRAM16, NumFormat<br>MBkFunc_Goto                     EQU   128            ;Goto          NV0Ptr Addr<br>MBkFunc_Stop                     EQU   129            ;Stop<br>MBkFunc_Delay                    EQU   130            ;Delay,        10msTicks (0 - 255)<br>;--MODBUS number format codes<br>;for float labels, this is what the letters mean A=31:24, B=23:16, C=15:8, D=7:0<br>MBkFormat_Byte                   EQU   0              ;only save LSB of big endian register (hence save the second byte) (standard)<br>MBkFormat_Word                   EQU   1              ;16 bit big endian<br>MBkFormat_ByteLE                 EQU   2              ;byte, little endian (non-standard)<br>MBkFormat_WordLE                 EQU   3              ;word, little endian (non-standard)<br>MBkFormat_FloatABCD              EQU   4              ;big endian<br>MBkFormat_FloatBADC              EQU   5              ;big endian, byte swapped<br>MBkFormat_FloatDCBA              EQU   6              ;little endian<br>MBkFormat_FloatCDAB              EQU   7              ;little endian byte swapped (Modicon and Wonderware standard)<\/pre>\n\n\n\n<p>And an example of usage<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><br>   ;#Open_Serial Port( COM0 ) MODBUSMaster( 38400, n, 0, 50 )<br>   COMRunScript   pMODBUSScript<br><br><br>   NVEM0                                              ;Start of non-volatile memory<br><br>pMODBUSScript<br>   NV0Byte  MBkFunc_ReadCoils, 0, #160, 8, #asCoils<br><br>   NV0Byte  MBkFunc_WriteSingleCoil, 0, #1008, #sSingleCoil<br><br>   NV0Byte  MBkFunc_ReadHoldingRegisters, 0, #100, 1, #wCount, MBkFormat_Word<br><br>   NV0Byte  MBkFunc_ReadHoldingRegisters, 0, #103, 6, #fCount, MBkFormat_Word<br><br>   NV0Byte  MBkFunc_WriteSingleRegister, 0, #115, #wCount, MBkFormat_Word<br><br>   NV0Byte  MBkFunc_WriteMultipleRegisters, 0, #117, 6, #fCountIEEE_BER, MBkFormat_FloatCDAB<br><br>   NV0Byte  MBkFunc_Delay,10<br><br>   NV0Byte  MBkFunc_Goto<br>   NV0Ptr   pMODBUSScript<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ModBus tutorial ModBus script commands are stored as table entries in\u00a0NVEM\u00a0page 0. In the following pages, each command consists of a 1-byte numeric command code&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2263,"menu_order":6,"template":"","class_list":["post-2271","spl_knowledgebase","type-spl_knowledgebase","status-publish","hentry"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>ModBus Master control script commands - SPLat Controls<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ModBus Master control script commands - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"ModBus tutorial ModBus script commands are stored as table entries in\u00a0NVEM\u00a0page 0. In the following pages, each command consists of a 1-byte numeric command code...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-11T05:35:14+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/\",\"name\":\"ModBus Master control script commands - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"datePublished\":\"2025-04-15T09:25:43+00:00\",\"dateModified\":\"2025-06-11T05:35:14+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Programming reference\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Instructions arranged by function\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Communications instructions\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"MODBUS Instructions\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"ModBus Master control script commands\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\",\"name\":\"SPLat Controls\",\"description\":\"OEM Embedded Machine Controllers\",\"publisher\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization\",\"name\":\"SPLat Controls\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg\",\"contentUrl\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg\",\"caption\":\"SPLat Controls\"},\"image\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ModBus Master control script commands - SPLat Controls","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"ModBus Master control script commands - SPLat Controls","og_description":"ModBus tutorial ModBus script commands are stored as table entries in\u00a0NVEM\u00a0page 0. In the following pages, each command consists of a 1-byte numeric command code...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/","og_site_name":"SPLat Controls","article_modified_time":"2025-06-11T05:35:14+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/","name":"ModBus Master control script commands - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"datePublished":"2025-04-15T09:25:43+00:00","dateModified":"2025-06-11T05:35:14+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/modbus-master-control-script-commands\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/"},{"@type":"ListItem","position":2,"name":"Programming reference","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/"},{"@type":"ListItem","position":3,"name":"Instructions arranged by function","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/"},{"@type":"ListItem","position":4,"name":"Communications instructions","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/"},{"@type":"ListItem","position":5,"name":"MODBUS Instructions","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/communications-instructions\/modbus-instructions\/"},{"@type":"ListItem","position":6,"name":"ModBus Master control script commands"}]},{"@type":"WebSite","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/","name":"SPLat Controls","description":"OEM Embedded Machine Controllers","publisher":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#organization","name":"SPLat Controls","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg","contentUrl":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2024\/10\/logo.svg","caption":"SPLat Controls"},"image":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase\/2271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase"}],"about":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/types\/spl_knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/users\/1"}],"up":[{"embeddable":true,"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/spl_knowledgebase\/2263"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=2271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}