{"id":1945,"date":"2025-04-14T11:44:39","date_gmt":"2025-04-14T11:44:39","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=1945"},"modified":"2025-06-10T08:51:21","modified_gmt":"2025-06-10T08:51:21","slug":"sx10506-programming","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/","title":{"rendered":"SX10506: Programming"},"content":{"rendered":"\n<p>The following table shows how the Xwire data block needs to appear in memory. The Receive data block consists of 4 bytes.<\/p>\n\n\n\n<p>Xwire receive data block:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Memory<\/th><th>Description<\/th><th>Format<\/th><\/tr><tr><td>3<\/td><td>Pressure data<\/td><td>24 bit floating point number normalised to 1.0000<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>*Note that this data block does not need to start at memory location 0. The data block can be moved anywhere in memory as long as it stays together, is in the order above and is defined in the\u00a0<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o2970\">NVEM<\/a>\u00a0Xwire table in the program code.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Example program demonstrating how to interface with a SX10506<\/h6>\n\n\n\n<pre class=\"wp-block-preformatted\">*    Program written for a MMI202a with a 2x16 LCD.<br>*    The MMI202a communicates to the SX10506 over the XWire peripheral interface.<br>*    MMI202a controller is the XWire master and the SX10506 is the XWire slave.<br> <br> <br>** Setup **<br> <br>* The SX10502 is interfaced to the MMI202a over <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o3808\">X<\/a>-Wire protocol by setting the communications jumper to the X position.<br>* No board ID jumpers are installed as the X-Wire slave address for the SX10506 is address 0.<br>* The X-Wire cable is connected from the CN12 connector on the MMI to the X1 connector on the SX10506. <br> <br>** Program operation **<br> <br>* X-Wire is set up to return pressure data to the MMI202a. <br>* Pressure from the SX10506 is continually updated on the LCD.<br>* If at any time there are Xwire communications errors the front panel LED on output 15 will light.<br>* The user presses and holds iBTN_Calibrate for 10 seconds to enter calibration mode.<br>* At power on if the pressure calibration has not been previously set the program will enter calibration mode.<br>* Once calibrated, the calibration values are stored to shadow memory so they survive power off.<br>  <br> <br>   * XWire Equates *<br> <br>XW_Address:       EQU            0                    ;Xwire Address of slave.  <br> <br> <br>   * XWire Receive data block *<br><br>   * Data block of 4 bytes *<br> <br>XW_RxRAMstart:    EQU            100                  ;The starting memory location of the Xwire receive data block.<br>XW_RxRAMlength:   EQU            4                    ;The size of the returned data in bytes.<br>XW_fPressure:     mEQU           100,4                ;Location where the SX10506 Pressure reading is returned.<br> <br> <br>   * XWire Transmit data block *<br><br>   * Data block of 0 bytes *<br>  <br>XW_TxRAMstart:    EQU            120                  ;The starting memory location of the xwire transmit data block.<br>XW_TxRAMlength:   EQU            0                    ;There are no bytes to send to the SX10506.<br> <br> <br>   * Input Equates *<br> <br>iBTN_Calibrate:   iEQU           12                   ;User presses and holds for 10 seconds to enter calibration mode.<br>iBTN_Poffset:     iEQU           11                   ;When button is pressed the current pressure reading is saved as the offset. (Calibration only)<br>iBTN_Pspan:       iEQU           10                   ;When button is pressed the span is calculated and saved.                    (Calibration only)<br> <br> <br>   * Output Equates *<br> <br>oXW_XWireError:   oEQU           15                   ;LED turns on when there is an Xwire communication error.\t<br> <br>   * Pressure sensor calibration constants SHADOW memory *<br> <br>CalFlag:          EQU            'AA                  ;Value of the valid calibration flag.<br>ShadowLength:     EQU            9                    ;Length of shadow memory.<br>ShadowStart:      EQU            200                  ;Start of shadow memory buffer.<br>fPoffset:         mEQU           200,4                ;Floating point pressure calibration offset value.<br>fPspan:           mEQU           204,4                ;Floating point pressure scale factor.<br>bCalibratedFlag:  mEQU           208                  ;Byte that is set to 'AA when the pressure sensor is calibrated.<br> <br>   * defFOAT Directives *<br>    <br>fCalc:            defFLOAT                            ;Where the current calculated water height is stored.<br>    <br> *******************<br> ** Program start **<br> *******************<br> <br>   XwireMaster    XwireTab                            ;Start xwire going.<br>   LaunchTask     MSQ_Start                           ;Start the Main Sequencer task running.<br>   LaunchTask     Xwire_Task                          ;Start the XWire error checking task running.<br>   RunTasksForever<br> <br> <br>MSQ_Start:<br>   ShadowRead     ShadowStart,ShadowLength            ;Recall calibration data (if present) from shadow memory.<br>   GoIfMNE        bCalibratedFlag,CalFlag,Calibrate   ;If the calibration flag is 'AA then calibration is already set. Otherwise calibrate the pressure sensor.         <br><br>MSQ_Display:<br>   YieldTask<br>   GoSub          MSQ_Sub0_CalcHeight                 ;Calculate the current water level.<br>   GoSub          MSQ_Sub1_DispHeight                 ;Display current water level.<br>   GoIfInOFF      iBTN_Calibrate,MSQ_Display          ;Test if the user wishes to enter Calibration mode.<br>   MarkTime                                           ;Start the timer running.<br> <br> * Enter this state if the user has pressed and holds *<br> * the iBTN_Calibrate button *<br>   <br>MSQ_Display_T:  <br>   YieldTask<br>   GoSub          MSQ_Sub0_CalcHeight                 ;Calculate the current water level.<br>   GoSub          MSQ_Sub1_DispHeight                 ;Display current water level.<br>   GoIfInOFF      iBTN_Calibrate,MSQ_Display          ;Is the user still holding the iBTN_Calibrate button ?<br>   LoopIfTiming   1000,MSQ_Display_T<br>   GoTo           Calibrate                           ;If the user holds the iBTN_Calibrate button for 10 seconds enter Calibration Mode.<br> <br> * Subroutines *<br><br>MSQ_Sub0_CalcHeight:<br>   fRecallQ       XW_fPressure                        ;Calculate water height. Water height = (PressureSensorReading - Poffset) \/ (Pspan)<br>   fRecallW       fPoffset   <br>   fSub<br>   fRecallQ       fPspan   <br>   fSwap<br>   fDiv<br>   fStore         fCalc                               ;Store the calculated value temporarily.<br>   Return<br> <br>MSQ_Sub1_DispHeight:<br>   fRecallW       fCalc                               ;Recall value to display.<br>                  ;0123456789012345<br>   OBLCD_SetCur   0,0<br>   OBLCD_Text     \"  Water height  \"<br>   OBLCD_SetCur   1,0                                 ;Display result on the LCD.<br>   OBLCD_fDispW   7,2<br>   OBLCD_Text     \"m        \"<br>   Return<br>    <br>*******************************\t\t<br>* Pressure sensor calibration *<br>*******************************<br>                  <br>* We are now in pressure calibration mode. We now wait for iBTN_Poffset button to be pressed before<br>* we store the low point value. Water depth is assumed to be at minimum.<br>  <br>Calibrate:        ;0123456789012345<br>   OBLCD_SetCur   0,0<br>   OBLCD_Text     \"Water level = 0m\"<br>   OBLCD_SetCur   1,0                                 ;Display message.<br>   OBLCD_Text     \"Press Poffset   \"<br><br>   WaitOn         iBTN_Poffset                        ;Has iBTN_Poffset button been pressed ?<br>   fRecallW       XW_fPressure                        ;Get current pressure sensor reading.<br>   fStore         fPoffset                            ;Store to Poffset.<br>                 <br>* We are now waiting for the iBTN_Pcal button to be pressed before we calculate the span. <br>* Span is calculated as Pressure at 1m of water - fPoffset.<br>  <br>Calibrate_0:      ;0123456789012345<br>   OBLCD_SetCur   0,0<br>   OBLCD_Text     \"Water level = 1m\"<br>   OBLCD_SetCur   1,0                                 ;Display message.<br>   OBLCD_Text     \"Press Pspan     \"<br>   <br>   WaitOn         iBTN_Pspan                          ;Has iBTN_Pcal button been pressed ?<br>   fRecallQ       XW_fPressure                        ;Get current pressure sensor reading.<br>   fRecallW       fPoffset                            ;Calculate span.<br>   fSub<br>   fStore         fPspan                              ;Store to Pspan.<br>   SetMem         bCalibratedFlag,CalFlag             ;Set a flag to show at startup calibration has already been done.<br>   ShadowWrite    ShadowStart,ShadowLength            ;Save calibration parameters and flag.<br>   GoTo           MSQ_Start<br><br> <br> ****************************<br> ** Xwire Error Check Task **<br> ****************************<br> <br>Xwire_Task:<br><br>XW0:<br>   YieldTask<br>   XwireGetErrCount                                   ;Get the xwire error count.<br>   GoIfF          XW1<br>   On             oXW_XWireError                      ;Turn on error LED if there are XWire errors.<br>   Pause          1<br>   GoTo           XW0<br>XW1:\t\t<br>   Off            oXW_XWireError\t<br>   GoTo           XW0<br><br> <br><br>   NVEM0<br> <br>XWireTab:         ;Slave address, transmit data block, Tx bytes, receive data block, Rx bytes.<br><br>   NV0Byte        XW_Address,XW_TxRAMstart,XW_TxRAMlength,XW_RxRAMstart,XW_RxRAMlength<br>   NV0Byte\t   255\t\t\t\t\t     ;End of table sentinel.    <br><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The following table shows how the Xwire data block needs to appear in memory. The Receive data block consists of 4 bytes. Xwire receive data&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1933,"menu_order":6,"template":"","class_list":["post-1945","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>SX10506: 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=\"SX10506: Programming - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"The following table shows how the Xwire data block needs to appear in memory. The Receive data block consists of 4 bytes. Xwire receive data...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-10T08:51:21+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\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/\",\"name\":\"SX10506: Programming - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"datePublished\":\"2025-04-14T11:44:39+00:00\",\"dateModified\":\"2025-06-10T08:51:21+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-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: Xwire peripherals\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"SX10506: Pressure Sensor\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"SX10506: 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":"SX10506: 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":"SX10506: Programming - SPLat Controls","og_description":"The following table shows how the Xwire data block needs to appear in memory. The Receive data block consists of 4 bytes. Xwire receive data...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/","og_site_name":"SPLat Controls","article_modified_time":"2025-06-10T08:51:21+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\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/","name":"SX10506: Programming - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"datePublished":"2025-04-14T11:44:39+00:00","dateModified":"2025-06-10T08:51:21+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-programming\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/sx10506-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: Xwire peripherals","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/"},{"@type":"ListItem","position":4,"name":"SX10506: Pressure Sensor","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-xwire-peripherals\/sx10506-pressure-sensor\/"},{"@type":"ListItem","position":5,"name":"SX10506: 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\/1945","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\/1933"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=1945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}