{"id":1542,"date":"2016-03-29T20:32:06","date_gmt":"2016-03-30T00:32:06","guid":{"rendered":"http:\/\/smallmr.com\/wordpress\/?p=1542"},"modified":"2016-03-29T20:32:06","modified_gmt":"2016-03-30T00:32:06","slug":"turnout-control-with-servos","status":"publish","type":"post","link":"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos\/","title":{"rendered":"Turnout Control with Servos"},"content":{"rendered":"<p>With the building of my\u00a0new <a href=\"http:\/\/free-mo.org\/\" target=\"_blank\">Free-mo<\/a> module set &#8220;<a href=\"http:\/\/smallmr.com\/wordpress\/the-boat-yard\/\" target=\"_blank\">The Boat Yard<\/a>&#8220;, I have had to change some of my usual &#8220;go to&#8221; items. I have always used Tortoise turnout motors in the past. These have been great performers that took little time to set up and they had built it frog polarity circuits. The issue with using them in the Boat Yard was purely financial. I needed over 20 of them to complete the project, and at $15-$20 each, it was really hurting the budget.<\/p>\n<p>I decided to take a look at RC Servos. I quickly discovered that the servos themselves were not very expensive. \u00a0I purchased 10 for $18.00 (less than $2 each) but I still lacked a way to operate them. Servos require a &#8220;controller&#8221; of some type to generate a signal that tells the servo which way\u00a0to turn and how much to turn.<\/p>\n<p>For those without knowledge of how a servo works here is a very quick and dirty &#8220;How It Works&#8221;:<\/p>\n<figure id=\"attachment_1543\" aria-describedby=\"caption-attachment-1543\" style=\"width: 252px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1543\" data-permalink=\"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos\/how-servo-motors-work-fig2\/\" data-orig-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/how-servo-motors-work-fig2.jpg\" data-orig-size=\"252,154\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"how-servo-motors-work-fig2\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Inside a servo&lt;\/p&gt;\n\" data-large-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/how-servo-motors-work-fig2.jpg\" class=\"wp-image-1543 size-full\" src=\"http:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/how-servo-motors-work-fig2.jpg\" alt=\"Inside a servo\" width=\"252\" height=\"154\" \/><figcaption id=\"caption-attachment-1543\" class=\"wp-caption-text\">Inside a servo<\/figcaption><\/figure>\n<p><em>Servos have three wires, Positive, negative and Control. They\u00a0are controlled by sending an electrical pulse of variable width, or pulse width modulation (PWM), through the\u00a0control wire. There is a minimum pulse, a maximum pulse, and a repetition rate. A servo motor can usually only turn 90 degrees in either direction for a total of 180 degree movement. The motor&#8217;s neutral position is defined as the position where the servo has the same amount of potential rotation in the both the clockwise or counter-clockwise direction (that was a lot of geek speak to say &#8220;center&#8221;). The PWM sent to the motor determines position of the shaft, and based on the duration of the pulse sent via the control wire; the rotor will turn to the desired position. The servo motor expects to see a pulse every 20 milliseconds (ms) and the length of the pulse will determine how far the motor turns. For example, a 1.5ms pulse will make the motor turn to the 90-degree position. Shorter than 1.5ms moves it to 0 degrees, and any longer than 1.5ms will turn the servo to 180 degrees.<\/em><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1544\" data-permalink=\"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos\/how-servo-motors-work-fig3\/\" data-orig-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/how-servo-motors-work-fig3.jpg\" data-orig-size=\"400,207\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"how-servo-motors-work-fig3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/how-servo-motors-work-fig3.jpg\" class=\"alignnone size-full wp-image-1544\" src=\"http:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/how-servo-motors-work-fig3.jpg\" alt=\"how-servo-motors-work-fig3\" width=\"400\" height=\"207\" srcset=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/how-servo-motors-work-fig3.jpg 400w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/how-servo-motors-work-fig3-300x155.jpg 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>A servo cannot operate by just adding power like a motor. It requires a controller circuit to send the PWM signal to tell it what to do. In turn you have to tell the controller circuit what you want with a switch or other electrical signal.<\/p>\n<p>There are a few makers of servo controllers for the model train market including <a href=\"http:\/\/www.tamvalleydepot.com\/products\/octopusservodriver.html\" target=\"_blank\">Tam Valley<\/a>, <a href=\"http:\/\/megapointscontrollers.com\/megapoints\/\" target=\"_blank\">MegaPoints\u00a0<\/a>and a\u00a0servo driving kit from the\u00a0<a href=\"http:\/\/www.merg.org.uk\/\" target=\"_blank\">Model Electric Railway<\/a>\u00a0<a href=\"http:\/\/www.merg.org.uk\/\" target=\"_blank\">Group (MERG)<\/a>. Each has its benefits and liabilities. By\u00a0searching a little deeper I\u00a0found a series of servo controller boards from <a href=\"https:\/\/www.pololu.com\/category\/12\/rc-servo-controllers\" target=\"_blank\">Pololu<\/a>\u00a0called the Mini Maestro which had a very low price and afforded the\u00a0flexibility I required. They come in 6, 12, 18 and 24 channel versions, allowing you to buy only as much controller as you need.<\/p>\n<figure id=\"attachment_1547\" aria-describedby=\"caption-attachment-1547\" style=\"width: 800px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1547\" data-permalink=\"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos\/0j2330-1200\/\" data-orig-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2330.1200.jpg\" data-orig-size=\"800,731\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"0J2330.1200\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Mini Maestro 12-channel USB servo controller&lt;\/p&gt;\n\" data-large-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2330.1200.jpg\" class=\"size-full wp-image-1547\" src=\"http:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2330.1200.jpg\" alt=\"Mini Maestro 12-channel USB servo controller\" width=\"800\" height=\"731\" srcset=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2330.1200.jpg 800w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2330.1200-300x274.jpg 300w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2330.1200-768x702.jpg 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><figcaption id=\"caption-attachment-1547\" class=\"wp-caption-text\">Mini Maestro 12-channel USB servo controller<\/figcaption><\/figure>\n<p>The Mini Maestros have\u00a0a USB interface so they can attach to a computer\/laptop. Servos can \u00a0be run either directly from the downloaded Pololu software or a script can be loaded into the Maestro for automation.\u00a0This allows me to adjust the characteristics of the board or tweak the program at any time.<\/p>\n<figure id=\"attachment_1549\" aria-describedby=\"caption-attachment-1549\" style=\"width: 798px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1549\" data-permalink=\"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos\/0j2375-1200\/\" data-orig-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2375.1200.png\" data-orig-size=\"798,506\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"0J2375.1200\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;The Status tab in the Maestro Control Center&lt;\/p&gt;\n\" data-large-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2375.1200.png\" class=\"wp-image-1549 size-full\" src=\"http:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2375.1200.png\" alt=\"The Status tab in the Maestro Control Center\" width=\"798\" height=\"506\" srcset=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2375.1200.png 798w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2375.1200-300x190.png 300w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2375.1200-768x487.png 768w\" sizes=\"auto, (max-width: 798px) 100vw, 798px\" \/><figcaption id=\"caption-attachment-1549\" class=\"wp-caption-text\">The Pololu Maestro Control Center allows for configuration of the Maestro including setting inputs, outputs, servos and scripts for automation.<\/figcaption><\/figure>\n<p>The Maestro\u00a0can be configured for automation of\u00a0servo control, with inputs,\u00a0outputs or both. The Boat Yard contains\u00a0a double crossover and an interchange that should have an interlock. With the Mini Maestro I\u00a0can program the actions of the interlock directly into the board and control it with a couple toggle switches on the fascia.<\/p>\n<figure id=\"attachment_1548\" aria-describedby=\"caption-attachment-1548\" style=\"width: 600px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1548\" data-permalink=\"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos\/0j2342-1200\/\" data-orig-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2342.1200.jpg\" data-orig-size=\"600,542\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"0J2342.1200\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Mini Maestro 18-channel USB servo controller labeled top view&lt;\/p&gt;\n\" data-large-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2342.1200.jpg\" class=\"size-full wp-image-1548\" src=\"http:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2342.1200.jpg\" alt=\"Mini Maestro 18-channel USB servo controller labeled top view\" width=\"600\" height=\"542\" srcset=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2342.1200.jpg 600w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2342.1200-300x271.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><figcaption id=\"caption-attachment-1548\" class=\"wp-caption-text\">Mini Maestro 18-channel USB servo controller labeled top view<\/figcaption><\/figure>\n<p>The last issue was how to mount the servos. After much deliberation I was able to determine that the module design I\u00a0was using allowed me to use the plywood top as a fulcrum for the servos. The distance from the turnout to the plywood was just right. <a href=\"http:\/\/smallmr.com\/wordpress\/free-mo-module-design\/\" target=\"_blank\">See my other article on free-mo module Design.<\/a>\u00a0With this knowledge I acquired a piece of 3\/4\u00a0inch angle aluminum and cut it into 1.5&#8243; in lengths.<\/p>\n<p>After carefully measuring a servo, I\u00a0created \u00a0a \u00a0template in Adobe illustrator to locate the holes required to mount the servo.<\/p>\n<figure id=\"attachment_1551\" aria-describedby=\"caption-attachment-1551\" style=\"width: 455px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/Servo-Mount-to-0_75-angle-alum.bmp\" rel=\"attachment wp-att-1551\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1551\" data-permalink=\"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos\/servo-mount-to-0_75-angle-alum\/\" data-orig-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/Servo-Mount-to-0_75-angle-alum.bmp\" data-orig-size=\"455,230\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Servo Mount to 0_75 angle alum\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Template for drilling to fit Servo&lt;\/p&gt;\n\" data-large-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/Servo-Mount-to-0_75-angle-alum.bmp\" class=\"size-full wp-image-1551\" src=\"http:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/Servo-Mount-to-0_75-angle-alum.bmp\" alt=\"Template for drilling to fit Servo\" width=\"455\" height=\"230\" \/><\/a><figcaption id=\"caption-attachment-1551\" class=\"wp-caption-text\">Template for drilling to fit Servo<\/figcaption><\/figure>\n<p>The template is affixed to the aluminum angle with spray glue and the holes drilled out. The servo then mounts with two small screws and uses the same piano wire that would have been used on a\u00a0Tortoise. The end must be bent into an &#8220;S&#8221; configuration to hold position in the servo arm.<\/p>\n<figure id=\"attachment_1552\" aria-describedby=\"caption-attachment-1552\" style=\"width: 474px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1552\" data-permalink=\"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos\/img_3932\/\" data-orig-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3932.jpg\" data-orig-size=\"1156,1204\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;2.4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone 5c&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1456600307&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.12&quot;,&quot;iso&quot;:&quot;320&quot;,&quot;shutter_speed&quot;:&quot;0.058823529411765&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"IMG_3932\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Servo shown mounted in the aluminum angle.&lt;\/p&gt;\n\" data-large-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3932-983x1024.jpg\" class=\"size-large wp-image-1552\" src=\"http:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3932-983x1024.jpg\" alt=\"Servo shown mounted in the aluminum angle.\" width=\"474\" height=\"494\" srcset=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3932-983x1024.jpg 983w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3932-288x300.jpg 288w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3932-768x800.jpg 768w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3932.jpg 1156w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><figcaption id=\"caption-attachment-1552\" class=\"wp-caption-text\">Servo shown mounted in the aluminum angle.<\/figcaption><\/figure>\n<figure id=\"attachment_1553\" aria-describedby=\"caption-attachment-1553\" style=\"width: 474px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1553\" data-permalink=\"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos\/img_3933\/\" data-orig-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3933.jpg\" data-orig-size=\"1188,1212\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;2.4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;iPhone 5c&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1456600318&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.12&quot;,&quot;iso&quot;:&quot;400&quot;,&quot;shutter_speed&quot;:&quot;0.058823529411765&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"IMG_3933\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Rear of servo showing rear of mounting screws and screws holding bracket to module.&lt;\/p&gt;\n\" data-large-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3933-1004x1024.jpg\" class=\"size-large wp-image-1553\" src=\"http:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3933-1004x1024.jpg\" alt=\"Rear of servo showing rear of mounting screws and screws holding bracket to module.\" width=\"474\" height=\"483\" srcset=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3933-1004x1024.jpg 1004w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3933-294x300.jpg 294w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3933-768x784.jpg 768w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/IMG_3933.jpg 1188w\" sizes=\"auto, (max-width: 474px) 100vw, 474px\" \/><figcaption id=\"caption-attachment-1553\" class=\"wp-caption-text\">Rear of servo showing rear of mounting screws and screws holding bracket to module.<\/figcaption><\/figure>\n<h2>Sample Wiring and Code<\/h2>\n<p>The following wiring and code uses Channel 0 on the Maestro as an input and Channel 1 as a servo. These need to be configured in the\u00a0Pololu Maestro Control Center BEFORE using the wiring diagram and the sample code provided or damage may occur.<\/p>\n<p>Free-mo requires that all turnouts have controls on each side of the layout. I typically do this with toggle switches on each side. The wiring for this with a Tortoise is well documented. With the Maestro however you need to do things a little different. \u00a0You could setup two inputs on the Maestro and create code to react when ever either input changes state. this might seem the way to go but I would tie up a lot of channels with this method. Instead I used a hybrid of the Tortoise wiring. Only the negative signal needs to be carried so I use a DPDT toggle for one side of the module and a SPDT on the other (or half of a DPDT). The following diagram shows how this works. You will need to set Channel 0 as an input and upload the appropriate code.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1562\" data-permalink=\"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos\/wiring_turnouts_single-2\/\" data-orig-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/Wiring_Turnouts_Single-1.png\" data-orig-size=\"639,355\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Wiring_Turnouts_Single\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/Wiring_Turnouts_Single-1.png\" class=\"alignnone wp-image-1562 size-full\" src=\"http:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/Wiring_Turnouts_Single-1.png\" alt=\"\" width=\"639\" height=\"355\" srcset=\"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/Wiring_Turnouts_Single-1.png 639w, https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/Wiring_Turnouts_Single-1-300x167.png 300w\" sizes=\"auto, (max-width: 639px) 100vw, 639px\" \/><\/p>\n<p>The following is the code to make the Maestro operate a single turnout in conjunction with the diagram above. Before using the code the correct values for the servo positions must be obtained. You can do this by connecting the Maestro to your computer and running using the Pololu Maestro Control Center to manually operate the servo. Note the values for each position. The value entered in the code is 4X the value shown in the status tab.<\/p>\n<p><span style=\"color: #008000;\"><em># When the script is not doing anything else,<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em># this loop will listen for switch position change.<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em># When a switch is thrown it runs the corresponding sequence.<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em>begin<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em> input_0 if sequence_a else sequence_b endif<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em>repeat<\/em><\/span><\/p>\n<p><span style=\"color: #008000;\"><em># These subroutines each return 1 if the corresponding<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em># switch is thrown, and return 0 otherwise.<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em># Currently switch input is assigned to channel 0, <\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em># This channel must be configured as Input in the<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em># Channel Settings tab.<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em>sub input_0<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em> 0 get_position 500 less_than<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em> return<\/em><\/span><\/p>\n<p><span style=\"color: #008000;\"><em># These subroutines each perform a servo movement. <\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em># You should change these to fit your application.<br \/>\n<\/em><em># Value used is 4X the value shown in the status tab<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em>sub sequence_a<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em> 4000 1 servo<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em> return<\/em><\/span><\/p>\n<p><span style=\"color: #008000;\"><em>sub sequence_b<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em> 8000 1 servo<\/em><\/span><br \/>\n<span style=\"color: #008000;\"><em> return<\/em><\/span><\/p>\n<p>Next time I will review how I powered the frogs. Currently the plan is to use inexpensive low voltage relays but if that fails a SPDT micro switch may be required.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the building of my\u00a0new Free-mo module set &#8220;The Boat Yard&#8220;, I have had to change some of my usual &#8220;go to&#8221; items. I have&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1547,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3,2],"tags":[39],"class_list":["post-1542","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-modules","category-articles-on-small-layouts","tag-march-2016","wpcat-3-id","wpcat-2-id"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/smallmr.com\/wordpress\/wp-content\/uploads\/2016\/03\/0J2330.1200.jpg","jetpack_shortlink":"https:\/\/wp.me\/p4e6yk-oS","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":2564,"url":"https:\/\/smallmr.com\/wordpress\/turnout-control-with-servos-part-ii\/","url_meta":{"origin":1542,"position":0},"title":"Turnout Control with Servos &#8211; Part II","author":"Marshall Stull","date":"April 23, 2019","format":false,"excerpt":"Back in 2016 I wrote the article Turnout Control with Servos . Since then I have been using servos exclusively on all my layouts. I have learned much since then and have changed some of the ways I control and mount the servos. In this article I am going to\u2026","rel":"","context":"In &quot;Small Layout How To Articles&quot;","block_context":{"text":"Small Layout How To Articles","link":"https:\/\/smallmr.com\/wordpress\/category\/articles-on-small-layouts\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2019\/04\/650001-LF.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2019\/04\/650001-LF.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2019\/04\/650001-LF.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2019\/04\/650001-LF.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":5512,"url":"https:\/\/smallmr.com\/wordpress\/website-issues-again\/","url_meta":{"origin":1542,"position":1},"title":"Website Issues (again)","author":"Marshall Stull","date":"August 21, 2023","format":false,"excerpt":"I recently had an issue with the eCommerce software I have been using to sell the Servo Brackets. The website kept working to the public but the backend was unavailable for about two weeks. I finally had to shut down and remove the eCommerce software and the site's backend is\u2026","rel":"","context":"In &quot;TRAIN ORDERS&quot;","block_context":{"text":"TRAIN ORDERS","link":"https:\/\/smallmr.com\/wordpress\/category\/train-orders\/"},"img":{"alt_text":"Train Order","src":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/04\/Stop-Look-Listen-sign-IRM-7-7-07.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/04\/Stop-Look-Listen-sign-IRM-7-7-07.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/04\/Stop-Look-Listen-sign-IRM-7-7-07.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/04\/Stop-Look-Listen-sign-IRM-7-7-07.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":2080,"url":"https:\/\/smallmr.com\/wordpress\/boat-yard-update-august-2018\/","url_meta":{"origin":1542,"position":2},"title":"Boat Yard Update &#8211; August 2018","author":"Marshall Stull","date":"August 7, 2018","format":false,"excerpt":"Back in October 2015, I presented my new Free-mo module project, The Boat Yard. When I wrote the article I had hoped to have the module set complete enough to show at the 2016 National Train Show. Unfortunately I was unable to attend the show as planned and had to\u2026","rel":"","context":"In &quot;Modular Layouts&quot;","block_context":{"text":"Modular Layouts","link":"https:\/\/smallmr.com\/wordpress\/category\/modules\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2018\/08\/IMG_0474.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2018\/08\/IMG_0474.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2018\/08\/IMG_0474.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2018\/08\/IMG_0474.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2018\/08\/IMG_0474.jpg?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2018\/08\/IMG_0474.jpg?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1417,"url":"https:\/\/smallmr.com\/wordpress\/the-boat-yard\/","url_meta":{"origin":1542,"position":3},"title":"The Boat Yard","author":"Marshall Stull","date":"October 30, 2015","format":false,"excerpt":"This week I started a new Free-mo module set called the Boat Yard. The design was a few years in the making. I was inspired by the Norfolk Southern (ex Norfolk & Western, ex Wabash) carfloat operation across the Detroit River between Detroit and Windsor Ontario. A Brief History It\u2026","rel":"","context":"In &quot;Modular Layouts&quot;","block_context":{"text":"Modular Layouts","link":"https:\/\/smallmr.com\/wordpress\/category\/modules\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/10\/boatyard_72dpi.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/10\/boatyard_72dpi.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/10\/boatyard_72dpi.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/10\/boatyard_72dpi.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/10\/boatyard_72dpi.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":1571,"url":"https:\/\/smallmr.com\/wordpress\/2016-national-train-show-prep\/","url_meta":{"origin":1542,"position":4},"title":"2016 National Train Show Prep","author":"Marshall Stull","date":"March 29, 2016","format":"aside","excerpt":"Things are really busy around here. I\u00a0committed to have the Boat Yard operational for\u00a0the 2016 National Train Show \u00a0and things are getting tight. To date I have all module frames completed and more than half of the track completed. All the track that is completed was hand laid. That was\u2026","rel":"","context":"In &quot;TRAIN ORDERS&quot;","block_context":{"text":"TRAIN ORDERS","link":"https:\/\/smallmr.com\/wordpress\/category\/train-orders\/"},"img":{"alt_text":"Train Order","src":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/04\/Stop-Look-Listen-sign-IRM-7-7-07.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/04\/Stop-Look-Listen-sign-IRM-7-7-07.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/04\/Stop-Look-Listen-sign-IRM-7-7-07.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2015\/04\/Stop-Look-Listen-sign-IRM-7-7-07.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":832,"url":"https:\/\/smallmr.com\/wordpress\/small-layout-ideas-the-terminal-railroad\/","url_meta":{"origin":1542,"position":5},"title":"Small Layout Ideas &#8211; The Terminal Railroad","author":"Marshall Stull","date":"May 9, 2014","format":false,"excerpt":"Many larger cities at one time had a terminal railroad. These short lines were usually owned by one or more major railways. These terminal railways were very busy enterprises with many short runs, short trains and much switching to be done. A terminal railway had to service its customers (who\u2026","rel":"","context":"In &quot;Small Layout Design Ideas&quot;","block_context":{"text":"Small Layout Design Ideas","link":"https:\/\/smallmr.com\/wordpress\/category\/small-layout-ideas\/"},"img":{"alt_text":"Detroit Terminal RR","src":"https:\/\/i0.wp.com\/smallmr.com\/wordpress\/wp-content\/uploads\/2014\/05\/logo.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/posts\/1542","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1542"}],"version-history":[{"count":9,"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/posts\/1542\/revisions"}],"predecessor-version":[{"id":1564,"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/posts\/1542\/revisions\/1564"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/media\/1547"}],"wp:attachment":[{"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smallmr.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}