Hi Guys n Girls I have just re-started up (from 2018) and built the basic DCC-ex environment with great success. I have some Bachmann solenoid (3 cable) turnouts and would like to use a relay board to change the state of the switches. I already wrote (2018) code to do this using a dedicated MEGA. How would I incorporate the code into my Base? Are there any examples? regards Aubrey - South Africa, Cape Town
You can most likely do it totally on the Mega running DCC EX and a couple of resistors and a L293. I use solenoid turnouts and plan to eliminate track connected decoders and implement something like below... Unless you have four solenoid turnouts like the Kato double crossover, the L293 should handle with no problem. https://dcc-ex.com/ex-commandstation/accessories/turnouts/solenoid-turnouts.html
Thank you Mark, I was more thinking of connecting the relay directly onto the Mega as per my "test" web-environment I built in 2018. (Jeez, I forgot all this stuff!) I would like to integrate this directly into the DCC-EX software and pick it up as an "accessory" in JMRI. Hope this makes sense :=) Anyone out there who has done this to give me a pointer to the sketch? Regards Aubrey
If you haven't been there yet you might want to check out the DCC-EX Discord channel... ( HERE ). Sumner
Good morning Guys. I finally got this going and it was quite easy to define. Anyone who can give me some kind of pointer how I will define these within a controller? I now have 2 switches (relays) for every turnout defined... My code (in myAutomation.h) so far: PIN_TURNOUT( 401, 22 , "One OPEN" ) PIN_TURNOUT( 402, 23 , "One CLOSED" ) PIN_TURNOUT( 403, 24 , "Two OPEN" ) PIN_TURNOUT( 404, 25 , "Two CLOSED" ) SEQUENCE(1) ONTHROW(401) DELAY(500) CLOSE(401) DONE SEQUENCE(2) ONTHROW(402) DELAY(500) CLOSE(402) DONE SEQUENCE(3) ONTHROW(403) DELAY(500) CLOSE(403) DONE SEQUENCE(4) ONTHROW(404) DELAY(500) CLOSE(404) DONE This then shows up as 4 POINTs - How do I combine these into one SWITCH?:
I think I got it... I did this by creating a macro: // Turnout 1: t=105, p1=22(pin 1) p2=23(pin 2) desc="Turnour 1" alias=Turn_1 #define PULSE 500 #define TURNOUTone(t, p1, p2, desc, ali) \ PIN_TURNOUT(t, 0, desc) \ ALIAS(ali, t) \ DONE \ ONCLOSE(t) \ RESET(p1) \ DELAY(PULSE) \ SET(p1) \ SET(p2) \ DONE \ ONTHROW(t) \ RESET(p2) \ DELAY(PULSE) \ SET(p2) \ SET(p1) \ DONE TURNOUTone(105, 22, 23, "Turnout 1", Turn_1) // Define the "Turnout ONE" turnout with turnout ID 105 using MEGA pins 22/23, and create alias Turn_1