{"id":3311,"date":"2025-04-18T04:45:35","date_gmt":"2025-04-18T04:45:35","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=3311"},"modified":"2025-06-10T09:23:36","modified_gmt":"2025-06-10T09:23:36","slug":"multitrack-advanced-measuring-elapsed-time-with-a-supertimer","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/","title":{"rendered":"MultiTrack (Advanced): Measuring elapsed time with a SuperTimer"},"content":{"rendered":"\n<p>There are times when you will want to measure how much time has elapsed since some event. Maybe you want to display an elapsed time on the fly or determine how long it took to get up to temperature. To achieve this you need to capture the start time using&nbsp;<code>STStart<\/code>&nbsp;(which means you need to declare a 3-byte timer variable using&nbsp;<code>defTIME24<\/code>), and subsequently get the amount of elapsed time using&nbsp;<code>fSTTimeSince<\/code>. What&nbsp;<code>fSTTimeSince <\/code>does is to calculate the amount of time that has elapsed since the moment captured by&nbsp;<code>STStart<\/code>&nbsp;and leave the result in floating point register&nbsp;<code>W<\/code>. The number in&nbsp;<code>W<\/code>&nbsp;will be in units of 10mS.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Example:<\/h6>\n\n\n\n<p>The following example is a stop watch written as a MultiTrack task to run in an MMi201 with LCD. The complete program file is located in the directory path Examples&gt;MultTrk under SPLatPC in Program Files. The file name is MulTrk02.SPT.<\/p>\n\n\n\n<p>There are a few interesting features in this program:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The stop watch task is written as a Finite State Machine (SPLatMap).<\/li>\n\n\n\n<li>There are three states: Waiting for the start button, Timing (waiting for the stop button) and waiting for the reset button. The line labels reflect the state numbers, which is all part of a scheme for producing consistent labeling.<\/li>\n\n\n\n<li>In the timing state (state 1, SW_1) the display is updated every 100mS. This will produce enough display activity to satisfy the user that the watch is running, without burdening the processor too much. Cunning use is made of a\u00a0<code><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/timing-instructions\/waitonkt-iitttt\/\">WaitOnKT<\/a><\/code>\u00a0instruction to monitor the stop button and time the 100mS display refresh interval in one single instruction.<\/li>\n\n\n\n<li><code><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/input-and-output-instructions-digital\/resetk\/\">ResetK<\/a><\/code>\u00a0is used in each state to guard against inadvertently stored, latched button presses.<\/li>\n\n\n\n<li>The actual elapsed time determination and display is done in a subroutine. There is a simple floating point calculation to scale SuperTimer counts (10mS increments) into seconds.<\/li>\n<\/ul>\n\n\n\n<p><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/cutting-and-pasting-code-from-the-splat-knowledge-base\/\">(Click here<\/a>\u00a0for some tips for working around problems with copy and paste out of Internet Explorer and HTML-help\u00a0<code>(.chm)<\/code>\u00a0files)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">        LaunchTask      StopWatch<br>        RunTasksForever<br><br>;----- StopWatch task ---------<br>;I\/O is set up for an MMi201<br>iSW_StartButton         iEQU    12<br>iSW_StopButton          iEQU    11<br>iSW_ResetButton         iEQU    10<br><br>SW_Timer        defTIME24       ;Reserve <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o414\">RAM<\/a> for the stopwatch timer<br><br>StopWatch:<br>SW_Set0:<br>        <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/product-documentation\/product-documentation-onboard-peripherals\/onboard-lcd\/oblcd-programming\/oblcd-programming-the-cursor-clearing-the-screen\/oblcd_setcur-rc\/\">OBLCD_SetCur<\/a>    0,0<br>        <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/onboard-lcd-oblcd-instructions\/oblcd_text-message\/\">OBLCD_Text<\/a>      \"  0.00\"                ;Clear stopwatch display<br>SW_0:<br>        <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/input-and-output-instructions-digital\/resetk\/\">ResetK<\/a>                                  ;Clear Key latches<br>        <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/input-and-output-instructions-digital\/waitonk-ii\/\">WaitOnK<\/a>         iSW_StartButton         ;Wait for start command<br>SW_Set1:<br>        STStart         SW_Timer                ;Start timing<br>        ResetK                                  ;Clear Key latches<br><br>;Main timing..<br>;While the SuperTimer takes care of the actual timing, we monitor<br>;the stop button, breaking off every 100mS to update the display.<br>SW_1:   <br>        <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/timing-instructions\/waitonkt-iitttt\/\">WaitOnKT<\/a>        iSW_StopButton,10       ;100mS<br>        <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/fasttrack-instructions\/goift-llll\/\">GoIfT<\/a>           SW_Set2                 ;G\/ button was pressed<br>        <a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/goto-gosub-and-related-instructions\/gosub-llll\/\">GoSub<\/a>           SW_Display              ;Update the display<br>        GoTo            SW_1                    ;Keep watching the button<br><br>;Here when user hits the stop button<br>SW_Set2:<br>        ResetK                                  ;Clear Key latches<br>        GoSub           SW_Display              ;Display final time<br>SW_2:<br>        WaitOnK         iSW_ResetButton         ;Wait for reset<br>        GoTo            SW_Set0                 ;Repeat<br><br>;Subroutine to grab and display elapsed stopwatch time<br>SW_Display:<br>        fSTTimeSince    SW_Timer                ;Get time<br>        fLoadQ          0.01                    ;10mS increments<br>        fMul                                    ;Scale to seconds<br>        OBLCD_SetCur    0,0<br>        OBLCD_fDispW    6,2<br>        Return<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>There are times when you will want to measure how much time has elapsed since some event. Maybe you want to display an elapsed time&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":3299,"menu_order":8,"template":"","class_list":["post-3311","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>MultiTrack (Advanced): Measuring elapsed time with a SuperTimer - 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=\"MultiTrack (Advanced): Measuring elapsed time with a SuperTimer - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"There are times when you will want to measure how much time has elapsed since some event. Maybe you want to display an elapsed time...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-10T09:23:36+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\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/\",\"name\":\"MultiTrack (Advanced): Measuring elapsed time with a SuperTimer - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"datePublished\":\"2025-04-18T04:45:35+00:00\",\"dateModified\":\"2025-06-10T09:23:36+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tutorials, application notes and white papers\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Tutorial: MultiTrack\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"MultiTrack (Advanced): Measuring elapsed time with a SuperTimer\"}]},{\"@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":"MultiTrack (Advanced): Measuring elapsed time with a SuperTimer - 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":"MultiTrack (Advanced): Measuring elapsed time with a SuperTimer - SPLat Controls","og_description":"There are times when you will want to measure how much time has elapsed since some event. Maybe you want to display an elapsed time...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/","og_site_name":"SPLat Controls","article_modified_time":"2025-06-10T09:23:36+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\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/","name":"MultiTrack (Advanced): Measuring elapsed time with a SuperTimer - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"datePublished":"2025-04-18T04:45:35+00:00","dateModified":"2025-06-10T09:23:36+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/multitrack-advanced-measuring-elapsed-time-with-a-supertimer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/"},{"@type":"ListItem","position":2,"name":"Tutorials, application notes and white papers","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/"},{"@type":"ListItem","position":3,"name":"Tutorial: MultiTrack","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/tutorials-application-notes-and-white-papers\/tutorial-multitrack\/"},{"@type":"ListItem","position":4,"name":"MultiTrack (Advanced): Measuring elapsed time with a SuperTimer"}]},{"@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\/3311","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\/3299"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=3311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}