Hi, as new comer to your forum, (DCC-EX platform) pardon the ignorance on how to connect/operate or what is the best way install and control 11 twin solenoid switches (used in Marklin three rail systems). My configuration is Arduino mega 2560,+ DF robots mega shield, ME8874 motor shield, Makerfab wifi shield. Most of my locomotives are with 3rd party DCC hardware. And as an Appel Mac user a WIThrotle to control my trains and eventually the turnouts. Any advice/help (with wiring / connection diagram/s will be of immense help) will be greatly appreciated Cheers Jay Down under (Melbourne AU)
There’s a pretty good write up on the DCC EX website regarding coil based turnouts. https://dcc-ex.com/ex-commandstation/accessories/turnouts/solenoid-turnouts.html#gsc.tab=0 Hopefully that will get you going in the right direction and I’m sure the DCC Ex gurus will be able to help too.
i use a dr4018 no longer in production but can find them on web.... although my turn outs are single they work with double as well... easy hookup and easy working
I initially used Adafruit motor shields to throw solenoid turnouts, although I had to tweak the DCC-EX code a little bit to make it work. Each shield can control 4 solenoids. Later I built a custom board with TB6612 drivers to control up to 12 solenoids over the I2c bus.
Correction, the Adafruit shield should be able to control 8 solenoids since they are unidirectional in your case. I was using Kato turnouts with bidrectional solenoids, so needed 2 motor outputs per solenoid. Though it was easy to set up, it made a pretty awkward stack and all the turnout wires had to run from the command station. The dedicated board solution let me just run an I2c connection over two wires and locate the turnout controller nearer to the turnouts.
Thanks, Professor, any chance of getting a some details of your project, it will be an enormous help to me. Thanking you in advance
Thanks, Sidney, much appreciate your response, any chance of getting some details, I.e. connections and DCC++ code etc will be of great benefit.
At present i only have the Arduino Standard Motor shield! I wouldn't mind investing on a Adafruit shields, if i can get them to work. Thanks,
For the Adafruit motor shields, a slight modification in the DCC-EX code was necessary to have the turnouts work like the examples on the page Chris Hall linked to. This is because the Adafruit motor shields use a PCA9685 expander to control the TB6612 motor drivers. DCC-EX includes drivers for the PCA9685, but the code is written with servos and PWM in mind. It turns out the code will skip a SET() command in EX-Rail if it is followed quickly by a RESET() command. Since the turnout macros use a SET() followed by a RESET() command within 10-20 milliseconds, the pulse can be skipped entirely. The fix is to add a method to the IO_PCA9685pwm.h file, which provides simple on-off control of a PCA9685 pin. Before the _writeAnalogue function in the file, add the following code: Code: // Device-specific write function, invoked from IODevice::write(). // For this function, the configured profile is used. void _write(VPIN vpin, int value) { #ifdef DIAG_IO DIAG(F("PCA9685pwm Write VPIN:%u Value:%d"), vpin, value); #endif int pin = vpin - _firstVpin; if (value) value = 4095; writeDevice(pin, value); } This will provide simple on/off control when you issue a command to SET() or RESET() a VPIN associated with a PCA9685. Then you define each Adafruit PCA9685 in myHal.cpp, like this: Code: PCA9685::create(100, 16, 0x60); PCA9685::create(116, 16, 0x61); PCA9685::create(132, 16, 0x62); This creates 3 PCA9685 modules with VPINS 100-115; 116-131; 132-147. You will need to look at the Adafruit schematic to map the PWM, IN1, and IN2 pins on the TB6612 motor drivers to the right output pins of the PCA9685. Then add macros in myAutomation.h to control the turnouts. To pulse a turnout, you SET() the PWM pin high, then SET and RESET the pin driving your solenoid. Here is how I did it for Kato dual-coil turnouts: Code: // Adafruit motor shield driving Unitrack turnouts // Use IO_PCA9685pwm.h for simple digital control of PCA9685 outputs #define PULSE 20 // Set the duration of the pulse (ms) #define SINGLE_COIL_TURNOUT(t, pwm, in2, in1, desc) \ PIN_TURNOUT(t, 0, desc) \ AUTOSTART \ RESET(in1) RESET(in2) SET(pwm) DONE \ ONCLOSE(t) \ SET(in1) DELAY(PULSE) RESET(in1) \ DONE \ ONTHROW(t) \ SET(in2) DELAY(PULSE) RESET(in2) \ DONE // Adafruit motor shield PC9865 outputs (pwm, in2, in1): // Motor 1: 8, 9, 10 // Motor 2: 13, 12, 11 // Motor 3: 2, 3, 4 // Motor 4: 7, 6, 5 // Shield 0x60 VPIN 100 - 115; Motor 1 unused // Shield 0x62 VPIN 132 - 147; Motor 4 unused // Shield 0x61 VPIN 116 - 131 SINGLE_COIL_TURNOUT(1, 113, 112, 111, "Crossover") SINGLE_COIL_TURNOUT(2, 102, 104, 103, "Upper passing") SINGLE_COIL_TURNOUT(3, 107, 106, 105, "Lower passing") SINGLE_COIL_TURNOUT(4, 124, 126, 125, "Inner lead") SINGLE_COIL_TURNOUT(5, 129, 128, 127, "Inner ladder") SINGLE_COIL_TURNOUT(6, 118, 120, 119, "Prog lead") SINGLE_COIL_TURNOUT(7, 123, 122, 121, "Prog ladder") SINGLE_COIL_TURNOUT(8, 140, 142, 141, "Outer lead") SINGLE_COIL_TURNOUT(9, 145, 144, 143, "Outer ladder 1" ) SINGLE_COIL_TURNOUT(10, 134, 135, 136, "Outer ladder 2") You would want to modify it for your dual-coil machines, where instead of setting one pin of the motor driver high and the other one low, you pulse one pin high to turn on the right solenoid. See the example on the DCC-EX page.
Thanks, Professor Chaos, Heaps to digest over the weekend! real great stuff. I will certainly give it a (as we say in Down Under) a 'Red Hot' go. I have a few PCA9685's with me but not an Adafruit shield right now, so I will have to source a couple - may be from Amazon as they're pretty good over here with deliveries. I will keep you posted of the outcome. Once again big thank you and have a great weekend.
You're welcome! My second version was a PCB I designed with MCP23017 I/O expanders and TB6612 motor driver modules from Pololu. This connects to the EX-Command Station via I2c, and drives up to 12 turnouts and 12 bicolor indicator LEDs:
Very impressive Professor! Can someone like get my hands on one of them? If so how much are they? Cheers
It's not commercially available, but you're welcome to the design files from Diptrace. You'd export the PCB design files as Gerbers, and send them to your favorite PCB manufacturer like JLCPCB or PCBWay. Beyond the PCB, the Pololu modules (TB6612 and a 5V regulator) would run about $40, plus maybe about $20 for the other components depending on where you source them.