{"id":1855,"date":"2025-04-14T08:35:13","date_gmt":"2025-04-14T08:35:13","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=1855"},"modified":"2025-06-10T08:41:32","modified_gmt":"2025-06-10T08:41:32","slug":"spice10218-programming","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/","title":{"rendered":"SPice10218: Programming"},"content":{"rendered":"\n<p>Once installed on a SPLat controller, the SPice10218 appears as one analog input and 3 digital outputs. The following table shows the mappings for all the I\/O on the board. Numbers in parenthesis are the numeric analog channel numbers used with&nbsp;<code><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/analog-instructions\/fanin-c-d18\/\">fAnIn<\/a><\/code>. You should use&nbsp;<code>fAnIn<\/code>&nbsp;to get the full benefit of 10-bit resolution.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>&nbsp;<\/th><th><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/\">SPice<\/a>&nbsp;cnctr pin<\/th><th>SLXXX<\/th><th>MMiXXX<\/th><th>MS12x<\/th><\/tr><tr><th>Analog input<\/th><th>4<\/th><td>AnInC (2)<\/td><td>AnInE (4)<\/td><td>AnInC (2)<\/td><\/tr><tr><th>Channel select 2<\/th><th>5<\/th><td>DO 9<\/td><td>DO 17<\/td><td>DO 13<\/td><\/tr><tr><th>Channel select 1<\/th><th>6<\/th><td>DO 10<\/td><td>DO 18<\/td><td>DO 14<\/td><\/tr><tr><th>Channel select 0<\/th><th>7<\/th><td>DO 11<\/td><td>DO 19<\/td><td>DO 15<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The SPice10218 is a multiplexer. That means it has the ability to select any one of its 8 analog input lines and route that through to a single analog input on the main SPLat controller board, where it can be read by an analog input instruction, e.g.&nbsp;<code>fAnIn<\/code>. The channel to be read is selected by sending a binary coded channel number to 3 &#8220;channel select&#8221; outputs. The analog input channel used, and the 3 channel select outputs, vary between SPLat controller boards according to the table above.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Channel select patterns<\/h6>\n\n\n\n<p>The following table defines the bit patterns for the 3 channel select outputs and the corresponding input channel numbers.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>&nbsp;<\/td><th colspan=\"3\">Channel select out<\/th><\/tr><tr><th>Ch<\/th><th>0<\/th><th>1<\/th><th>2<\/th><\/tr><tr><th>0<\/th><td>Off<\/td><td>Off<\/td><td>Off<\/td><\/tr><tr><th>1<\/th><td>On<\/td><td>Off<\/td><td>Off<\/td><\/tr><tr><th>2<\/th><td>Off<\/td><td>On<\/td><td>Off<\/td><\/tr><tr><th>3<\/th><td>On<\/td><td>On<\/td><td>Off<\/td><\/tr><tr><th>4<\/th><td>Off<\/td><td>Off<\/td><td>On<\/td><\/tr><tr><th>5<\/th><td>On<\/td><td>Off<\/td><td>On<\/td><\/tr><tr><th>6<\/th><td>Off<\/td><td>On<\/td><td>On<\/td><\/tr><tr><th>7<\/th><td>On<\/td><td>On<\/td><td>On<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>You may recognize this as a simply binary count, which indeed it is. Note however that the the least significant channel select bit is in the most significant of the three outputs.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Initializing the SPice connector<\/h6>\n\n\n\n<p>Because the pins of the SPice connector, to which the SPice10218 is connected, can be configured for different functions (analog\/digital, input\/output), you need to have some code in your program that configures them to the correct settings for the SPice10218.<\/p>\n\n\n\n<p>The following section of code should be run by your program just once, at the beginning, before your program attempts to do anything else with the SPice10218.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">         <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/splat-expansion-framework-generic-instructions\/clru\/\">ClrU<\/a><br>         <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/splat-expansion-framework-generic-instructions\/setu-ni\/\">setu<\/a>         0,3         ;set spice connector pin 4 as analogue input<br>         setu         1,1         ;set spice connector pin 5 as digital output<br>         setu         2,1         ;set spice connector pin 6 as digital output<br>         setu         3,1         ;set spice connector pin 7 as digital output<br>         setu         4,0         ;set spice connector pin 8 as unchanged<br>         setu         5,0         ;set spice connector pin 9 as unchanged<br>         <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/splat-expansion-framework-generic-instructions\/spiceconfigu\/\">SpiceConfigU<\/a><\/pre>\n\n\n\n<h6 class=\"wp-block-heading\">Reading an analog value (example program)<\/h6>\n\n\n\n<p>Once the SPice connector has been initialized (which you would do early in your program using the code above), reading a channel requires setting the channel select outputs to the right pattern, allowing the analog voltage to settle, and then executing an analog input instruction.<\/p>\n\n\n\n<p>The analog settling time must be taken into account.&nbsp;<em>It cannot be ignored<\/em>. The settling time constant is up about 0.5mS. It takes 7 time constants to settle to 10 bits. Hence the multiplexer requires at least 3.5mS to settle to 10 bits.<\/p>\n\n\n\n<p>The following is a MultiTrack task that will automatically scan all 8 channels. To use it copy and paste the code into your program and edit the&nbsp;<code>SP218_MUXStart <\/code>and&nbsp;<code>SP218_AnIn<\/code>&nbsp;constant values to match your controller type. To start it up simply&nbsp;<code><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/multitrack-instructions\/launchtask-lllljj-d16\/\">LaunchTask<\/a> Scan218. <\/code>To access a reading load&nbsp;<a href=\"https:\/\/www.splatco.com\/skb\/352.htm#o3808\">X<\/a>&nbsp;with the required channel number 0-7 and&nbsp;<code>GoSub Get218Reading.<\/code>&nbsp;The latest reading for the required channel will be returned in W as a normalized number 0-1.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">* The following equates select the base address for the MUX select lines on the<br>* SPICE connector based on the board type:<br>*<br>* SL99, SL100                           SP218_MUXStart =  9, SP218_AnIn = 2<br>* <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/\">MMi99<\/a>, MMi200, MMi201, MMi202         SP218_MUXStart = 17, SP218_AnIn = 4<br>* MS12, MS120                           SP218_MUXStart = 13, SP218_AnIn = 2<br><br>SP218_MUXStart  equ     17      ;MMiXXX<br>SP218_AnIn      equ     4<br><br><br>Ch218           defBYTE<br>Readings218     defFLOAT        8       ;Result holding variables<br><br>;The scanner stores readings in an array of 8 floating point numbers.<br>;Because of the bit reversal that takes place on the 218 board, the <br>;order of readings in memory will be scrambled. This gets sorted out<br>;by bit reversing the index used during readout, in Get218Reading.<br>Scan218:<br>                Recall          Ch218<br>                LoadX           7<br>                OutputM         SP218_MUXStart<br>                Pause           2\t         ;Guarantee 10mS minimum settling delay.<br>                fAnIn           SP218_AnIn<br>                Recall          Ch218<br>                Push<br>                XtoI<br>                IasJ:fStore     Readings218<br>                IncX<br>                LoadX           7<br>                AndM<br>                Store           Ch218<br>                GoTo            Scan218<br><br>;Return the latest reading for the channel number in X<br>Get218Reading:<br>                GoSub           ReverseBits012<br>                XtoI<br>                IasJ:fRecallW   Readings218<br>                Return<br><br>ReverseBits012: ;Reverse bit order 0, 1, 2 in X         <br>RB_X1           defBYTE<br>RB_X2           defBYTE<br><br>RB_Y0           SetMem          RB_X2,0<br>                Store           RB_X1<br>                GoIfSF          0,RB_X1,RB_Y1<br>                SetS            2,RB_X2<br>RB_Y1           GoIfSF          1,RB_X1,RB_Y2<br>                SetS            1,RB_X2<br>RB_Y2           GoIfSF          2,RB_X1,RB_Y3<br>                SetS            0,RB_X2<br>RB_Y3           Recall          RB_X2<br>                Return<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Once installed on a SPLat controller, the SPice10218 appears as one analog input and 3 digital outputs. The following table shows the mappings for all&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1849,"menu_order":4,"template":"","class_list":["post-1855","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>SPice10218: Programming - 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=\"SPice10218: Programming - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"Once installed on a SPLat controller, the SPice10218 appears as one analog input and 3 digital outputs. The following table shows the mappings for all...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-10T08:41:32+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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/\",\"name\":\"SPice10218: Programming - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"datePublished\":\"2025-04-14T08:35:13+00:00\",\"dateModified\":\"2025-06-10T08:41:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Product documentation\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Product documentation: SPice add-on boards\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"SPIce 10218 &#8211; 8 channel analog input multiplexer\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"SPice10218: Programming\"}]},{\"@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":"SPice10218: Programming - 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":"SPice10218: Programming - SPLat Controls","og_description":"Once installed on a SPLat controller, the SPice10218 appears as one analog input and 3 digital outputs. The following table shows the mappings for all...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/","og_site_name":"SPLat Controls","article_modified_time":"2025-06-10T08:41:32+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/","name":"SPice10218: Programming - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"datePublished":"2025-04-14T08:35:13+00:00","dateModified":"2025-06-10T08:41:32+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/spice10218-programming\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/"},{"@type":"ListItem","position":2,"name":"Product documentation","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/"},{"@type":"ListItem","position":3,"name":"Product documentation: SPice add-on boards","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/"},{"@type":"ListItem","position":4,"name":"SPIce 10218 &#8211; 8 channel analog input multiplexer","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-spice-add-on-boards\/spice-10218-8-channel-analog-input-multiplexer\/"},{"@type":"ListItem","position":5,"name":"SPice10218: Programming"}]},{"@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\/1855","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\/1849"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=1855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}