{"id":1224,"date":"2020-12-02T21:22:23","date_gmt":"2020-12-02T21:22:23","guid":{"rendered":"http:\/\/mattzobricks.com\/?page_id=1224"},"modified":"2024-06-18T13:47:51","modified_gmt":"2024-06-18T11:47:51","slug":"mattzoswitchcontroller","status":"publish","type":"page","link":"https:\/\/mattzobricks.com\/de\/automation\/mattzolayoutcontroller\/mattzoswitchcontroller","title":{"rendered":"MattzoLayoutController with Switches"},"content":{"rendered":"\n<p>Please read the <a type=\"page\" href=\"https:\/\/mattzobricks.com\/controllers\/general\" id=\"1213\">general section<\/a> first!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"562\" src=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/01\/cropped-ds-scaled-1-1024x562.jpg\" alt=\"\" class=\"wp-image-9\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/01\/cropped-ds-scaled-1-1024x562.jpg 1024w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/01\/cropped-ds-scaled-1-300x165.jpg 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/01\/cropped-ds-scaled-1-768x422.jpg 768w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/01\/cropped-ds-scaled-1-1536x843.jpg 1536w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/01\/cropped-ds-scaled-1-2048x1124.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Switch Field<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">General information about switches<\/h2>\n\n\n\n<p>This video contains general information about automated switches in the Mattzobricks Train Automation System:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Automatic switches for the LEGO train system\" width=\"819\" height=\"461\" src=\"https:\/\/www.youtube.com\/embed\/_5MJDCL1E-s?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Purpose<\/h2>\n\n\n\n<p>The MattzoLayoutController (MLC) is designed to receive switch commands from Rocrail via the MQTT broker and flip a switch into the requested direction.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Functional Description<\/h2>\n\n\n\n<p>When Rocrail request a switch to turn into a specific direction, it communicates this as a command via the MQTT broker. The MattzoController receives this command and evaluates, if the command is relevant for the specific controller (i.e. if the switch is connected to this controller).<\/p>\n\n\n\n<p>The switch command contains the following data:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>the MattzoControllerId<\/li>\n\n\n\n<li>the Rocrail port to which the switch motor (servo) is connected to<\/li>\n\n\n\n<li>the requested direction of the switch (straight or thrown)<\/li>\n<\/ol>\n\n\n\n<p>The number of switches that can be attached to one MattzoController depends of the number of servos that the switch requires:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A standard switch has one servo, and needs one Rocrail port.<\/li>\n\n\n\n<li>A triple switch has two servos, and needs two Rocrail ports.<\/li>\n\n\n\n<li>A double slip switch has four servos, and needs two Rocrail ports (two servos share one Rocrail port).<\/li>\n<\/ul>\n\n\n\n<p>The number of switches that can be controlled by a MLC depends on the number of servos that the MLC can control. This number depends on version of the MLC that you want to build.<\/p>\n\n\n\n<p>A MLC mini can control by fault 2 servos, thus it can control 2 standard switches or one triple switch. The MLC mini configuration can be changed so that it can control up to 8 servos, and the corresponding number of switches.<\/p>\n\n\n\n<p>A MLC mega controls up to 16 servos, thus it can control 16 standard switches, 8 triple switches or 4 double slip switches (or any combination of it).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wiring<\/h2>\n\n\n\n<p>The following sketch shows the wiring of the MattzoLayoutController with 8 switch motors attached:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"525\" src=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/12\/Wiring-Diagram-MLC-with-8-switches-0.5-1024x525.png\" alt=\"Wiring Diagram MLC with 8 switches\" class=\"wp-image-4195\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/12\/Wiring-Diagram-MLC-with-8-switches-0.5-1024x525.png 1024w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/12\/Wiring-Diagram-MLC-with-8-switches-0.5-300x154.png 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/12\/Wiring-Diagram-MLC-with-8-switches-0.5-768x394.png 768w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/12\/Wiring-Diagram-MLC-with-8-switches-0.5-1536x787.png 1536w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/12\/Wiring-Diagram-MLC-with-8-switches-0.5-2048x1050.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Wiring Diagram MLC with 8 switches<\/figcaption><\/figure>\n\n\n\n<p>As you can see, you simply connect the PWM wire (usually orange) of the servos to the output pins D0 to D7, connect the red wire (plus) to VIN and the black wire to GND (ground).<\/p>\n\n\n\n<p>Required components:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I\/O board with micro controller. We have used a NodeMCU Amica Modul V2 ESP8266 ESP-12F. Similar modules should work as well.<\/li>\n\n\n\n<li>Basic stuff like bread board, wires etc.<\/li>\n<\/ul>\n\n\n\n<p>An optional LED can be installed on pin D8 to monitor the correct operation of the controller. It is indeed a good idea to connect the LED to D8, because this pin must necessarily be pulled down or the controler will not boot correctly.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"http:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3904-1024x768.jpg\" alt=\"\" class=\"wp-image-1644\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3904-1024x768.jpg 1024w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3904-300x225.jpg 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3904-768x576.jpg 768w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3904-1536x1152.jpg 1536w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3904-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Power Supply<\/h2>\n\n\n\n<p>Sufficient power supply is crucial because the servo motors require some power to flip the switches. If the power supply is to weak, the voltage in the micro controller goes down, which can cause a crash of the controller. We have made pretty good experiences with power supplies that deliver 2 amps.<\/p>\n\n\n\n<p>The controller can be powered up with a simple USB charger over USB or some other power supply of similar voltage that is connected to the VIN and GND pins of the controller. If you use a different power source, voltage should be in the range between 4.5V and 6V.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"http:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3905-scaled-e1610018290591-1024x768.jpg\" alt=\"\" class=\"wp-image-1643\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3905-scaled-e1610018290591-1024x768.jpg 1024w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3905-scaled-e1610018290591-300x225.jpg 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3905-scaled-e1610018290591-768x576.jpg 768w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3905-scaled-e1610018290591-1536x1152.jpg 1536w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2021\/01\/IMG_3905-scaled-e1610018290591-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">Firmware Configuration<\/h1>\n\n\n\n<p>Please read the <a href=\"https:\/\/mattzobricks.com\/controllers\/mattzolayoutcontroller\" data-type=\"page\" data-id=\"1983\">MLC general page<\/a> first.<\/p>\n\n\n\n<p>To configure the firmware configuration, you need to edit the controller configuration file (controller_config.h).<\/p>\n\n\n\n<p>MLC mini and MLC mega have standard configurations that do not need to be changed to standard switches and triple switches. You need to change the standard configuration only if you are using double slip switches (see below).<\/p>\n\n\n\n<p>The configuration file has two relevant sections:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SERVO WIRING CONFIGURATION, and the <\/li>\n\n\n\n<li>SWITCH CONFIGURATION.<\/li>\n<\/ul>\n\n\n\n<p>The sections are clearly marked in the standard configuration file, and the different parameters are explained (as of firmware V1.1 in file MLC_types.h) with code comments.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Servo wiring configuration<\/h2>\n\n\n\n<p>In this section, the servos are defined that are attached to the controller. It is the <strong>physical <\/strong>part of the switch definition.<\/p>\n\n\n\n<p>The following example stems from the MLC mini standard configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ SERVO WIRING CONFIGURATION\n\/\/ Servos are used for motorizing switches and form signals\n\/\/ Number of servos\n#define NUM_SERVOS 2\n\nTServoConfiguration servoConfiguration&#91;NUM_SERVOS] =\n{\n    {\n        .pin = D3,\n        .pinType = 0,\n        .detachAfterUsage = true\n    },\n    {\n        .pin = D4,\n        .pinType = 0,\n        .detachAfterUsage = true\n    }\n};\n<\/code><\/pre>\n\n\n\n<p>In the example, two servos are defined. The first one is attached to pin D3, the second one to D4. The servos are attached directly to the controller (pinType = 0), and after having moved the servo, the servo will be &#8220;detached&#8221; (switched off).<\/p>\n\n\n\n<p>Please note that the NUM_SERVOS constant must equal the number of defined servos in the array.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Switch configuration<\/h2>\n\n\n\n<p>In this section, the switches operated by this controller are defined. The definition contains the mapping of the switch to the servos defined in the servo wiring configuration, and their port in Rocrail. It is the <strong>logical <\/strong>part of the switch definition.<\/p>\n\n\n\n<p>The following example stems from the MLC mini standard configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ SWITCH CONFIGURATION\n\/\/ Number of switches\n#define NUM_SWITCHES 2\n\nTSwitchConfiguration switchConfiguration&#91;NUM_SWITCHES] =\n{\n    {\n        .rocRailPort = 1,\n        .servoIndex = 0,\n        .servo2Index = -1,\n        .servo2Reverse = false,\n        .triggerSensors = false,\n        .sensorIndex = { -1, -1 }\n    },\n    {\n        .rocRailPort = 2,\n        .servoIndex = 1,\n        .servo2Index = -1,\n        .servo2Reverse = false,\n        .triggerSensors = false,\n        .sensorIndex = { -1, -1 }\n    }\n};\n<\/code><\/pre>\n\n\n\n<p>NUM_SWITCHES constant must equal the number of defined switches in the array. In the example, two standard switches are defined. The first one relates to rocrail port 1 in rocrail, the second one to rocrail port 2.<\/p>\n\n\n\n<p>The first one uses the first servo (servoIndex 0) in the servo wiring configuration, the second one the second servo (servoIndex 1).<\/p>\n\n\n\n<p>All other parameters are described further below.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Rocrail Setup<\/h1>\n\n\n\n<p>For general setup instructions please refer to the &#8220;General&#8221; section.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Standard Switch<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"1024\" src=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2270-768x1024.jpg\" alt=\"Standard Switch\" class=\"wp-image-7630\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2270-768x1024.jpg 768w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2270-225x300.jpg 225w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2270-1152x1536.jpg 1152w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2270-1536x2048.jpg 1536w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2270-scaled.jpg 1920w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><figcaption class=\"wp-element-caption\">Standard Switch<\/figcaption><\/figure>\n\n\n\n<p>To setup a <strong>standard switch<\/strong> in Rocrail, locate the switch on the plan, click it with the right mouse button and select &#8220;Properties&#8221;. Then navigate to the interface tab of the switch properties dialog.<\/p>\n\n\n\n<p>The MattzoControllerID must be entered as &#8220;Address&#8221; parameter, and the rocrail port to which the switch is connected as &#8220;Port&#8221;.<\/p>\n\n\n\n<p>In Rocrail, we also define the required rotation angles of the servo to achieve the &#8220;straight&#8221; and &#8220;thrown&#8221; direction of the switch. This is very handy, because these values are different for each servo. 75 and 85 are good starting values for Trixbrix servos.<\/p>\n\n\n\n<p>Enter the minimum angle of the switch servo motor into the &#8220;Parameter&#8221; field, and the maximum angle into the &#8220;Value&#8221; field. Then test the switch (leave the dialog and click on the switch to operate it). Good values require a bit of trial and error<\/p>\n\n\n\n<p>ALL OTHER INFORMATION ON THIS PAGE CAN BE NEGLECTED AND HAS NO MEANING!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"896\" height=\"717\" src=\"http:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-1-standard.png\" alt=\"\" class=\"wp-image-651\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-1-standard.png 896w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-1-standard-300x240.png 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-1-standard-768x615.png 768w\" sizes=\"auto, (max-width: 896px) 100vw, 896px\" \/><figcaption class=\"wp-element-caption\">Switch configuration in Rocrail: Standard Switch<\/figcaption><\/figure>\n\n\n\n<p>After setting up everything, you should test the switch. Simply set Rocrail in the &#8220;operate&#8221; mode and click the switch symbol. If the switch orientation is incorrect (switch is thrown when the symbol shows straight), simply exchange the values for &#8220;Parameter&#8221; and &#8220;Value&#8221; in the Rocrail configuration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Triple Switch<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"1024\" src=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2265-768x1024.jpg\" alt=\"Triple Switch\" class=\"wp-image-7634\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2265-768x1024.jpg 768w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2265-225x300.jpg 225w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2265-1152x1536.jpg 1152w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2265-1536x2048.jpg 1536w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2265-scaled.jpg 1920w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><figcaption class=\"wp-element-caption\">Triple Switch<\/figcaption><\/figure>\n\n\n\n<p>To setup a <strong>triple switch<\/strong> in Rocrail, navigate to the interface tab of the switch definition. A triple switch can be seen as a combination of two switches. They require two logical switch objects in the MLC configuration, each using a different servo.<\/p>\n\n\n\n<p>The MattzoControllerID must be entered as &#8220;Address&#8221; parameter, and the ports of the two switches are defined in the MLC configuration<\/p>\n\n\n\n<p>As for standard switches, enter the minimum angle of the switch servo motors into the &#8220;Parameter&#8221; fields, and the maximum angle into the &#8220;Value&#8221; fields.<\/p>\n\n\n\n<p>ALL OTHER INFORMATION ON THIS PAGE CAN BE NEGLECTED AND HAS NO MEANING!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"896\" height=\"713\" src=\"http:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-2-triple.png\" alt=\"\" class=\"wp-image-652\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-2-triple.png 896w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-2-triple-300x239.png 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-2-triple-768x611.png 768w\" sizes=\"auto, (max-width: 896px) 100vw, 896px\" \/><figcaption class=\"wp-element-caption\"><em>Switch configuration in Rocrail: Triple Switch<\/em><\/figcaption><\/figure>\n\n\n\n<p>After setting up everything, you should test the switch. The idea is similar to the standard switch, just that you have two servos to care about.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Double Slip Switches<\/h1>\n\n\n\n<p>Setting up a <strong>double slip switch<\/strong>es is a bit more tricky.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2269-1024x768.jpg\" alt=\"Double Slip Switch\" class=\"wp-image-7629\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2269-1024x768.jpg 1024w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2269-300x225.jpg 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2269-768x576.jpg 768w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2269-1536x1152.jpg 1536w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2269-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Double Slip Switch<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Principle<\/h2>\n\n\n\n<p>Rocrail considers a double slip switch (dss) as two switches that are logically combined. Each side of the double slip switch has its own Rocrail port. Each side has two servos. The servos of each side are always used synchronously.<\/p>\n\n\n\n<p>The following picture illustrates the idea (with example values):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The left side (green) has Rocrail port 1001, and the associated servos 0 and 1. When switching, both servos move synchronously.<\/li>\n\n\n\n<li>The right side (red) has Rocrail port 1002, and the associated servos 2 and 3. When switching, both servos move synchronously.<\/li>\n<\/ul>\n\n\n\n<p>The overall switch direction results from the settings of both Rocrail port 1001 and 1002. In the example below, the switch is set to &#8220;straight&#8221; (vehicles may pass straight from left to right and vice versa).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/dss-servo-combinatino-1024x768.jpg\" alt=\"\" class=\"wp-image-7655\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/dss-servo-combinatino-1024x768.jpg 1024w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/dss-servo-combinatino-300x225.jpg 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/dss-servo-combinatino-768x576.jpg 768w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/dss-servo-combinatino-1536x1152.jpg 1536w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/dss-servo-combinatino.jpg 2016w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The idea is a bit tricky to understand at first glance, but you&#8217;ll get behind it once you use it in practice.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Firmware configuration for double slip switches<\/h2>\n\n\n\n<p>If you use an MLC mega with a recent firmware, no configurationi change is required. Double slip switches are defined in the MLC mega standard configuration by default (Rocrail ports 1001 to 1008).<\/p>\n\n\n\n<p>MLC minis require a configuration change. First, you need to extend the servo wiring configuration so that you have four servos.<\/p>\n\n\n\n<p>A double slip switch requires two logical switch objects in the MLC configuration. Each of them has a Rocrail port as described above.<\/p>\n\n\n\n<p>This is an example (imagine, four servos were defined in the servo wiring configuration):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ SWITCH CONFIGURATION\n\/\/ Number of switches\n#define NUM_SWITCHES 2\n\nTSwitchConfiguration switchConfiguration&#91;NUM_SWITCHES] =\n{\n    {\n        .rocRailPort = 1001,\n        .servoIndex = 0,\n        .servo2Index = 1,\n        .servo2Reverse = false,\n        .triggerSensors = false,\n        .sensorIndex = { -1, -1 }\n    },\n    {\n        .rocRailPort = 1002,\n        .servoIndex = 2,\n        .servo2Index = 3,\n        .servo2Reverse = false,\n        .triggerSensors = false,\n        .sensorIndex = { -1, -1 }\n    }\n};<\/code><\/pre>\n\n\n\n<p>The second servo of each logical switch is defined with the &#8220;servo2index&#8221; parameter. As the &#8220;servoIndex&#8221; parameter, it contains the index of the servo in the servo array as defined in the servo wiring configuration.<\/p>\n\n\n\n<p>If the second servo turns into the wrong direction when flipping the switch, set the &#8220;servo2Reverse&#8221; flag to true. If both turn wrong, exchange the &#8220;Parameter&#8221; and &#8220;Value&#8221; parameters in the Rocrail configuration (as for standard and triple switches).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Rocrail setup for double slip switches<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2272-1024x768.jpg\" alt=\"Double Slip Switch\" class=\"wp-image-7632\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2272-1024x768.jpg 1024w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2272-300x225.jpg 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2272-768x576.jpg 768w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2272-1536x1152.jpg 1536w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/IMG_2272-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Double Slip Switch<\/figcaption><\/figure>\n\n\n\n<p>The MattzoControllerID must be entered in both &#8220;Address&#8221; fields.<\/p>\n\n\n\n<p>The MattzoControllerID must be entered as &#8220;Address&#8221; parameter, and the ports of the two switches are defined in the MLC configuration (1001 and 1002 in this example).<\/p>\n\n\n\n<p>As for standard switches, enter the minimum angle of the switch servo motors into the &#8220;Parameter&#8221; fields, and the maximum angle into the &#8220;Value&#8221; fields. Please note that the setting can only be done for a servo pair and per logical switch, not individually for each servo. It is recommended or even required to use identical type of servos within a single logical switch.<\/p>\n\n\n\n<p>ALL OTHER INFORMATION ON THIS PAGE CAN BE NEGLECTED AND HAS NO MEANING!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"891\" height=\"712\" src=\"http:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-3-ds.png\" alt=\"\" class=\"wp-image-653\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-3-ds.png 891w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-3-ds-300x240.png 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2020\/05\/Rocrail-config-switches-3-ds-768x614.png 768w\" sizes=\"auto, (max-width: 891px) 100vw, 891px\" \/><figcaption class=\"wp-element-caption\"><em>Switch configuration in Rocrail: Triple Switch<\/em><\/figcaption><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\">Switch Sensors<\/h1>\n\n\n\n<p>As in reality, Rocrail can deal with switches that have location sensors. Location sensors help to check if a switch is in the correct position.<\/p>\n\n\n\n<p>In this example, a switch has been thrown in Rocrail, but its correct position has not been confirmed:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"243\" height=\"147\" src=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/image-5.png\" alt=\"\" class=\"wp-image-7660\"\/><figcaption class=\"wp-element-caption\">Switch with unconfirmed position<\/figcaption><\/figure>\n\n\n\n<p>If a switch has not been confirmed, the switch may still be used by Rocrail to allocate it and to set routes, but it will not start the train to make it travel over the route.<\/p>\n\n\n\n<p>Unfortunately, location sensors would be quite complicated to build for LEGO and compatible switches, but we can at least check if the switch command was received by the MLC and if the controller has converted the command into a servo setting.<\/p>\n\n\n\n<p>The MLC has a feature called &#8220;virtual sensors&#8221;. These sensors can be defined in the sensor wiring configuration section in the MLC configuration.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#define NUM_SENSORS 2\nTSensorConfiguration sensorConfiguration&#91;NUM_SENSORS] =\n{\n    {\n        .pin = -1,\n        .pinType = VIRTUAL_SENSOR_PIN_TYPE,\n        .remoteMattzoControllerId = -1\n    },\n    {\n        .pin = -1,\n        .pinType = VIRTUAL_SENSOR_PIN_TYPE,\n        .remoteMattzoControllerId = -1\n    }\n}<\/code><\/pre>\n\n\n\n<p>These sensors can then be used in the switch definition:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ SWITCH CONFIGURATION\n\/\/ Number of switches\n#define NUM_SWITCHES 1\n\nTSwitchConfiguration switchConfiguration&#91;NUM_SWITCHES] =\n{\n    {\n        .rocRailPort = 1,\n        .servoIndex = 0,\n        .servo2Index = -1,\n        .servo2Reverse = false,\n        .triggerSensors = <strong>true<\/strong>,\n        .sensorIndex = {<strong>0, 1<\/strong>}\n    },\n}<\/code><\/pre>\n\n\n\n<p>To make the MLC create sensors events when a switch was thrown, the &#8220;triggerSensors&#8221; parameter must be set to &#8220;true&#8221;. The &#8220;sensorIndex&#8221; array contains the indexes of the two virtual sensors from the sensor wiring configuration (array are zero-based in C++, so the values are 0 and 1).<\/p>\n\n\n\n<p>In order to use the feature in Rocrail, create two sensors in the Rocrail plan. One is for the &#8220;straight direction, one for the &#8220;thrown&#8221; direction. Configure them as if they were physical sensors.<\/p>\n\n\n\n<p>Then navigate to the &#8220;Wiring&#8221; section of the switch property page. Enter the sensors in the &#8220;Sensor turnout&#8221; and &#8220;Sensor straight&#8221; fields as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"986\" height=\"689\" src=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/image-6.png\" alt=\"\" class=\"wp-image-7663\" srcset=\"https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/image-6.png 986w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/image-6-300x210.png 300w, https:\/\/mattzobricks.com\/wp-content\/uploads\/2024\/05\/image-6-768x537.png 768w\" sizes=\"auto, (max-width: 986px) 100vw, 986px\" \/><\/figure>\n\n\n\n<p>Chances are 50\/50, that you mixed up the two sensors&#8230; just flip them in the dialog above if required.<\/p>\n\n\n\n<p>As soon as the sensors are selected correctly for the switch, a route will not be cleared for a train before the sensors have reported the switch to be in the correct position.<\/p>\n\n\n\n<p>The feature works for all types of switches. For triple switches and double slip switches, four virtual sensors must be created and selected in the switch configuration in Rocrail.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Tipps and Tricks<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">Flattering servos<\/h3>\n\n\n\n<p>Some users have experienced flattering servos in some deployment scenarios. This is usually caused by a &#8220;brown-out&#8221;, which happens when the power supply for the servos is insufficient and breaks down.<\/p>\n\n\n\n<p>To overcome this problem, you need to make sure that the MattzoSwitchController has enough power. If you power up the controller with USB (4,65V), you should use a charger with 2 Amps minimum. Using higher voltage also helps.<\/p>\n\n\n\n<p>Other countermeasuers include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reduce the length of your cables.<\/li>\n\n\n\n<li>Use drilled cables.<\/li>\n\n\n\n<li>Reduce the number of servos attached to the controller.<\/li>\n<\/ul>\n\n\n\n<p>We are also investigating an idea to change the servo control frequency.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Please read the general section first! General information about switches This video contains general information about automated switches in the Mattzobricks Train Automation System: Purpose The MattzoLayoutController (MLC) is designed to receive switch commands from Rocrail via the MQTT broker and flip a switch into the requested direction. Functional Description [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1983,"menu_order":20,"comment_status":"open","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"class_list":["post-1224","page","type-page","status-publish","hentry"],"translation":{"provider":"WPGlobus","version":"3.0.2","language":"de","enabled_languages":["en","de"],"languages":{"en":{"title":true,"content":true,"excerpt":false},"de":{"title":false,"content":false,"excerpt":false}}},"_links":{"self":[{"href":"https:\/\/mattzobricks.com\/de\/wp-json\/wp\/v2\/pages\/1224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mattzobricks.com\/de\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mattzobricks.com\/de\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mattzobricks.com\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mattzobricks.com\/de\/wp-json\/wp\/v2\/comments?post=1224"}],"version-history":[{"count":46,"href":"https:\/\/mattzobricks.com\/de\/wp-json\/wp\/v2\/pages\/1224\/revisions"}],"predecessor-version":[{"id":7692,"href":"https:\/\/mattzobricks.com\/de\/wp-json\/wp\/v2\/pages\/1224\/revisions\/7692"}],"up":[{"embeddable":true,"href":"https:\/\/mattzobricks.com\/de\/wp-json\/wp\/v2\/pages\/1983"}],"wp:attachment":[{"href":"https:\/\/mattzobricks.com\/de\/wp-json\/wp\/v2\/media?parent=1224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}