{"id":3684,"date":"2025-04-21T06:52:16","date_gmt":"2025-04-21T06:52:16","guid":{"rendered":"https:\/\/webprojects.cloud\/wordpress\/splatco\/?post_type=spl_knowledgebase&#038;p=3684"},"modified":"2025-06-10T07:26:13","modified_gmt":"2025-06-10T07:26:13","slug":"example-controlling-an-rc-servo","status":"publish","type":"spl_knowledgebase","link":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/","title":{"rendered":"Example: Controlling an RC servo"},"content":{"rendered":"\n<p>RC (Radio Control) servos are small devices that position a physical output, usually a rotating shaft, to a particular point under control of a digital pulse width modulated (PWM) input signal. RC servos exist primarily in the hobby sphere.<\/p>\n\n\n\n<p>This example will show you how to control a servo using an output from a&nbsp;<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o366\">SPice<\/a>&nbsp;connector on a suitably equipped SPLat&nbsp;<a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/glossary-of-terms\/#o372\">Controller<\/a>.<\/p>\n\n\n\n<p>Note: This procedure requires connecting wires directly to the pins of a SPice connector, which have no protection circuitry. Take particular care that none of the wires accidentally touches a terminal it is not supposed to. Always disconnect power before making or breaking connections, and double check wiring before applying power. Keep wires a short as possible and route away from any wires carrying high voltage (120\/240V) or current. Any damage to the SPLat attributable to careless practices will void the warranty.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Wiring<\/h6>\n\n\n\n<p>An RC servo has 3 wires. These are:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>&nbsp;<\/td><td>V+<\/td><td><\/td><td>Positive power. This needs to be wired to a power supply suitable for the servo itself. Typically servo devices require 4.5 to 6V. You need a power supply rated for the current specified by the servo manufacturer. Connect the servo V+ wire to the positive terminal of the power supply (red below).<\/td><\/tr><tr><td>&nbsp;<\/td><td>Common\/Gnd\/0V\/V-<\/td><td><\/td><td>Different servo manufacturers will use different designations. This needs to go to the negative terminal of the servo power supply (above) and also to the 0V pin of the SPLat SPice connector (Green below)<\/td><\/tr><tr><td>&nbsp;<\/td><td>Signal<\/td><td><\/td><td>This is the pin\/wire on the servo that receives the pulse width modulated control signal. It needs to be connected to a SPice pin designated as capable of being an analog output (Yellow below)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"517\" height=\"266\" src=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC.png\" alt=\"\" class=\"wp-image-3685\" srcset=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC.png 517w, https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC-300x154.png 300w, https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC-64x33.png 64w\" sizes=\"auto, (max-width: 517px) 100vw, 517px\" \/><\/figure>\n\n\n\n<p>The diagram above shows a single RC servo connected to SPice pin 8. On an MMi202 this is equivalent to analog output 9 when used with an\u00a0<code><a href=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-reference\/instructions-arranged-by-function\/analog-instructions\/fanout-c-d18\/\" target=\"_blank\" rel=\"noreferrer noopener\">fAnout<\/a><\/code>\u00a0instruction.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\">Programming<\/h6>\n\n\n\n<p>Programming is quite simple. It exploits the fact that the &#8220;analog&#8221; outputs on a SPice connector are actually pulse width modulated 5V signals &#8230; exactly what an RC servo wants. The base frequency of the PWM signal has to be adjusted away from default in order to suit the servo. That means any other analog outputs will suffer, so you can&#8217;t for example have a 0-10V analog output or thermistor drive at the same time off the same controller.<\/p>\n\n\n\n<p>Here is some sample code: This small program will control 2 RC servos connected to an MMi202 SPice connector.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">* Set PWM output repetition frequency to 125 Hz. This gives us a PWM pulse width range of\n* 0 - 8ms. The servo used in this example accepts 0.6ms --&gt; 2.4ms. \n* Using the floating point Fanout instruction,\n* this gives an allowable range of value of 0.6\/8.0 = 0.075 --&gt; 2.4\/8 = 0.30. As the normalised\n* range of 0 --&gt; 1 is realised with a PWM resolution of 10 bits (0 - 1023), this gives us a \n* control range of (0.3 - 0.075) * 1024 = 230 counts or 1\/230 = 0.43% \n        \n        setu            0,7             ;select 125 Hz PWM operation\n        SpxCmd1         0,!cpu\n        \n        setu            0,0             ;set up SPICE pin 4 as a PWM output\n        setu            1,0\n        setu            2,0\n        setu            3,0\n        setu            4,4             ;SPICE pin 4 set up as a PWM output\n        setu            5,0             ;SPICE pin 5 is already a PWM output\n        spiceconfigu\n\nloopy   floadw          0.075           ;go to one extreme of the travel\n        fAnout          8               ;Spice pin 9 on an MMi202\n        fAnout          9               ;Spice pin 8 on an MMi202\n        pause           200             ;wait...\n        \n        floadw          0.30            ;go to the other extreme of the travel\n        fanout          8\n        fanout          9\n        pause           200             ;wait...\n        goto            loopy<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>RC (Radio Control) servos are small devices that position a physical output, usually a rotating shaft, to a particular point under control of a digital&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":887,"menu_order":1,"template":"","class_list":["post-3684","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>Example: Controlling an RC servo - 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=\"Example: Controlling an RC servo - SPLat Controls\" \/>\n<meta property=\"og:description\" content=\"RC (Radio Control) servos are small devices that position a physical output, usually a rotating shaft, to a particular point under control of a digital...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/\" \/>\n<meta property=\"og:site_name\" content=\"SPLat Controls\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-10T07:26:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC.png\" \/>\n\t<meta property=\"og:image:width\" content=\"517\" \/>\n\t<meta property=\"og:image:height\" content=\"266\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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=\"2 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\/programming-examples\/example-controlling-an-rc-servo\/\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/\",\"name\":\"Example: Controlling an RC servo - SPLat Controls\",\"isPartOf\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC.png\",\"datePublished\":\"2025-04-21T06:52:16+00:00\",\"dateModified\":\"2025-06-10T07:26:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/#primaryimage\",\"url\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC.png\",\"contentUrl\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC.png\",\"width\":517,\"height\":266},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Programming examples\",\"item\":\"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Example: Controlling an RC servo\"}]},{\"@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":"Example: Controlling an RC servo - 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":"Example: Controlling an RC servo - SPLat Controls","og_description":"RC (Radio Control) servos are small devices that position a physical output, usually a rotating shaft, to a particular point under control of a digital...","og_url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/","og_site_name":"SPLat Controls","article_modified_time":"2025-06-10T07:26:13+00:00","og_image":[{"width":517,"height":266,"url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/","name":"Example: Controlling an RC servo - SPLat Controls","isPartOf":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/#primaryimage"},"image":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/#primaryimage"},"thumbnailUrl":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC.png","datePublished":"2025-04-21T06:52:16+00:00","dateModified":"2025-06-10T07:26:13+00:00","breadcrumb":{"@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/#primaryimage","url":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC.png","contentUrl":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-content\/uploads\/2025\/04\/Controlling-an-RC.png","width":517,"height":266},{"@type":"BreadcrumbList","@id":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/example-controlling-an-rc-servo\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/"},{"@type":"ListItem","position":2,"name":"Programming examples","item":"https:\/\/webprojects.cloud\/wordpress\/splatco\/knowledgebase\/programming-examples\/"},{"@type":"ListItem","position":3,"name":"Example: Controlling an RC servo"}]},{"@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\/3684","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\/887"}],"wp:attachment":[{"href":"https:\/\/webprojects.cloud\/wordpress\/splatco\/wp-json\/wp\/v2\/media?parent=3684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}