Hi Steve, Having implemented the Latched Switching version mentioned in the first method you describe, I noticed that power to the servos is constantly applied, which can lead to servo "chatter". Using the ideas mentioned in the second method, I have now solved the problem by using code in this form (spaces added for readability) for a servo that is thrown when the switch is "on" :- IF(SWITCH1) IFCLOSED(TURN1) THROW(TURN1) ENDIF ELSE IFTHROWN(TURN1) CLOSE(TURN1) ENDIF ENDIF This only moves the servo when the switch is changed, and then power to the servo is off until the switch position is changed again. This also has the benefit that the values of Thrown and Closed can be played with in the Android DCC-EX Toolbox App without having to disable the sequence. Hope this helps Thanks again for a very helpful video. Stephen
Steve, Great video tutorial, just what I need to help me convert from DCC++ to DCC EX. I look forward to the I/O expansion video you mentioned.... looks like I will have over 100 switches on my layout. Thanks!!
Thank you for these great videos on servo-controlled turnouts. The momentary button controls with LED indications is exactly what I want to do with my planned small switching layout. I may have been able to make a small amount of progress toward a solution on my own, but I don't think I would have ever been able to get there without a tutorial like you've now provided. Bravo!
Exactly what I have been looking for, brillient vid, thank you. Easy to follow and very well explained. I will watch in here for sure, keep up the good work.
lets see this all done with the expansion boards!! I'm trying to set up a switching panel myself using led's and momentary switches but it would be a cleaner look to have a few cables ran into the panel with a dedicated PCA9685 instead of running all the buttons and leds out of the panel to the Arduino itself. Loving this video and can't wait for more!!
Excellent, another idea for servo control is semaphore signals, but how can you return the semaphore to danger after a train has gone past? Keep the videos coming, thank you.
This is a very helpful video, thank you for explaining the code and hardware so well. I have a question, in (SEQUENCE 02) you use IFTHROWN to test the position of the turnout, the servos do not return any positional data so how does DCC EX know where the turnout is when you initially power up the layout. I'd like to attach a small relay to switch a turnout's frog polarity when it is thrown or closed so it's important to know the servos position at power up to avoid a short circuit. Thanks again for the video, I look forward to the next one.
DCC-EX defaults to the closed position of all servos on startup. You can add some Sequences or macros to run at startup if you want certain turnouts in the thrown position. To test, put a turnout in the thrown position then reboot your DCCEX. your turnout SHOULD close on startup. Anytime you throw or close a turnout. Dccex keeps track of this.
When you have a chance, Can you show how to add a green light on the other side of the button to show when the servo is in the other state. I want to add the buttons and two LED's for each to a control panel. Ultimately I will have 16 servos, 16 red LED's and 16 green LED's on the control panel. This would be so cool to be able to control my layout through the control and/or through JRMI. Thanks!!
To add the green LED, just duplicate the SET(x) command, but have it set when you CLOSE the turnout, and RESET the red LED, i.e. THROW(turnout_address) RESET(green_LED_address) SET(red_LED_address) and CLOSE((turnout_address) RESET(red_LED_address) SET(green_LED_address)
Nice video. I was able to expand to the maximum digital pins for switches and LEDs but I fall seven short of what I need. Is there any way to use the ANALOG pins to light LEDs?
Excellent, just what I needed for my next development of my DCC-Ex, could you provide downloadable examples of the sketches involved to allow examining and being able to modify for my own requirements. Thanks you
Hi Steve thank you for dropping the files, it's very good of you to assist the novice that I am. Unfortunately the myAliases.h is not shown and myAutomation dies not have the SEQUENCES included. I'd be grateful if you could add those for me/us and I hope it is not too much of an inconvenience. Thank you@@SPKPRR
The pins on Arduino are set to be input signals. The command AT(pin#) Automatically watches the pin# for a signal (HIGH or LOW). Commands like ONTHROW(turnout) or IFTHROWN(turnout) use "Counters" set up by DCCEX to monitor the state of a turnout, not the status of a pin.
Hi Steve, thank you for this - I was just at the point of using DCC-EX to control points on my friend's layout, and had already wired the latching switches to pins 22-34, and tried this and it worked! However, I was expecting to have to declare the pins as sensors or as INPUT_PULLUP to make sure they didn't drift. So I guess DCC-EX has already defined this somewhere - I have tried reading the code but it is complex! Also, I saw you have used pins 61 - 63 for your virtual pins, but pins 54-69 are used as the digital definition for pins A0 to A15 on the Mega, so would it be better to use numbers in the range 70 - 99 instead? Similarly I was a bit puzzled as to where the LED output pins are defined as outputs? But as you have shown it works, and is so simple to program! Thank you too for showing how to create and use the "myTurnouts.h" and aliases - it really does make identification so easy!
I wasn't even thinking about the Analog pins as digital, so yes it would probably be a good idea to shift the Virtual pins up to 70 or higher. DCC EX takes care of all the defining for you, so you don't need to worry about setting up pins as sensor or output, the command IF(pin#) tells DCC EX to treat it as INPUT, and the SET(pin#) tells it to treat the pin as an output. Yes it really is easy to program, once you get the gist of it.
I am wondering, how many digits can be used for the alias turnout ? I think it would simplify things, if turnout 01, could be alias turnout 1001. You could have 999 turnouts, and match names to 1999
HELP PLEASE.......I HAVE ENTERED THE CODE FOR ONLY 3 SWITCHES AND NONE OF MY HARDWARE WORKS. LEDs DO NOT CHANGE STATE, THEY STAY ON), NOR DO ANY SWITCHES. HOWEVER ENGINE DRIVER THROWS THE SERVOS ONLY. Am I missing something???????? I hate codeing
I found the problem. you use SERVO_TURNOUT(116, 116, 300, 450, Fast, "Test1") instead of SERVO_TURNOUT(116, 100, 300, 450, Fast, "Test1") This changed the pin number on the PCA9685 to 116 instead of 100.....@@SPKPRR
The UNO doesn't have much memory. You definitely won't be able to do the WiFi connection, you would have to connect through jmri. Even then, there is very little memory for automation and you would not be able to add much. That's why the Mega is the choice.
I use the ESP-01 WiFI module, there are others that work. see this link for WiFi boards. dcc-ex.com/ex-commandstation/advanced-setup/supported-wifi/wifi-config.html#gsc.tab=0 I know there are issues with the firmware on current boards that may need to be updated. I have not needed to, my boards still have the good firmware.