Let's learn together - Turnout decoder for solenoids, #1! (DCC model railway with Arduino 10)
Vložit
- čas přidán 21. 08. 2024
- Let's learn together how to build a DCC Turnout Decoder with Arduino, #1.
In this tenth episode, how to build a DCC turnout/accessory decoder, based on Arduino, for controlling solenoid motors.
PROJECT
- Github repository: github.com/luc...
- Official website for our products (MosfetBoard): www.officinamo...
- Shared projects on PCBWay for PCBs: www.pcbway.com...
PREVIOUS TUTORIALS:
- DCC Decoder: • Let's learn together -...
- Configuration Variables: • Let's learn together -...
LINKS:
- Turnout Motors on DCCWiki: dccwiki.com/Tu...
- PECO point motor shown in the video: peco-uk.com/pr...
-
Music: Brighter Days by Markvard is licensed under a Creative Commons License.
creativecommon....
Support by RFM - NCM: bit.ly/2xGHypM
-
Fantastic video Luca, I'm learning more and more with every video, thank you so much for posting these videos. Well done!
Thanks Phil, comments like yours make me working on new videos ;)
Hi Luca, well done for decoding the DCC and running the turnouts. One thing I must say: After many bad experiences by using the delay, which stops the complete Arduino I always avoid it now. You can work with setting time-marks of the type unsigned long and the system time obtained by millis().
BR, Philipp
Hi! You're right... in this case because the delay time is short and the decoder cannot do other things in the meantime it should be acceptable to stop the code execution but in general your suggestion is correct (and I blogged about it in an old post www.lucadentella.it/en/2015/07/21/arduino-delay-vs-millis/ ) ;)
Hi Luca, another great video! I really find your videos really interesting and useful. Thanks and all the best. John
John, thanks a lot for your comment!
You are amazing! Great information! 👍
Thanks!!!
Great video. One option might also be solid state relays. I want to try them out in a future project of mine. 😊
Thanks! Great idea, solid-state relays should work fine... let me know if you test them!
Good with english videos also :)
Thanks Mikael!
Hi Luca, Can we use IRFZ44 N-Channel MOSFET instead of IRL530 MOSFET. Also do we need a diode to protect Back EMF current
Hi! Well, you "should" use logic-level mosfets with Arduino (the "L" in IRL stands for that), but I think also the IRF mosfets will work, even if they do not fully "open" with only 5V of Vgs. And yes, an external diode (even if the MOSFET has an internal one) can help on reducing backEMF
@@lucadentella Hi! Thank you for your reply. Would it be possible for you to show the circuit diagram on how to connect the diodes with point motors.
@@bbcsd I got you covered ;) I've just published a video on my channel about point / dc motors
Hi, can you please build a loconet version with a Capacitor Discharge ?
Hi! In my upcoming video I'll explain what a CDU is and how to build it... I personally prefer to have it as an external board (it could serve more than one outputs if they are not triggered simultaneously). I never considered developing a Loconet turnout decoder, I'm curious: what advantages do you see? A "standard" DCC decoder as the one presented in this video works with any DCC command stations regardless the comm bus it supports (Loconet, xPressNet...)
@@lucadentella true, DCC will work with any command station. However, I see that separating DCC for running trains and Loconet for running the layout, reduces the DCC traffic to only locomotives beneficial. Using Loconet allows feedback so I can query the turnouts or block detection when the layout powers up.
With a DCC turnout, you are not guaranteed that the turnout has flipped. Even adding a Led does not guarantee that the turnout coil is even connected. But having a switch on the turnout giving feedback does assure that the coil or motor is connected and working.
@@ClinchfieldModelRailroad good points! I'll add a loconet decoder to the list of my future projects! Thanks for suggesting that!
@@ClinchfieldModelRailroad I agree, I like to have loconet running all the ‘other stuff’ whilst dcc does the trains
Thanks for a fantastic video, I copied the sketch, attached but it will not comply. Could you please tell me where I have gone wrong. Thanks, Wally.
#include
#define DCC_PIN 2
#define ACK_PIN 3
#define DECODER_ADDRESS 23
#define CV_IMPULSE_DURATION 30
#define IMPULSE_DURATION 200
#define OUT1_PIN_STRAIGHT 4
#define OUT1_PIN_DIVERGING 5
#define OUT2_PIN_STRAIGHT 6
#define OUT2_PIN_DIVERGING 7
NmraDcc Dcc;
void notifyDccAccTurnoutOutput(uint16_t Addr, uint8_t Direction, uint8_t OutputPower){
//get the current decoder address
uint16_t myAddress = Dcc.getAddr();
//getimpuls duration from CV
uint8_t impulseDuration = Dcc.getCV(CV_IMPULSE_DURATION);
//Output 1
if(Addr == myAddress){
if(Direction == 0){
digitalWrite(OUT1_PIN_STRAIGHT, HIGH);
delay(impulseDuration);
digitalWrite(OUT1_PIN_STRAIGHT, LOW);
} else {
digitalWrite(OUT1_PIN_DIVERGING, HIGH );
delay(impulseDuration);
digitalWrite(OUT1_PIN_DIVERGING, LOW);
}
Serial.print("Output 1 Moved to Position") ;
Serial.print(Direction);
}
//Output 2
else if(Addr == myAddress + 1){
if(Direction == 0){
digitalWrite(OUT2_PIN_STRAIGHT, HIGH);
delay(impulseDuration);
digitalWrite(OUT2_PIN_STRAIGHT, LOW);
} else {
digitalWrite(OUT2_PIN_DIVERGING, HIGH );
delay(impulseDuration);
digitalWrite(OUT2_PIN_DIVERGING, LOW);
}
Serial.print("Output 2 Moved to Position") ;
Serial.print(Direction);
}
}
void notifyCVAck(void){
digitalWrite(ACK_PIN, HIGH);
delay(8);
digitalWrite(ACK_PIN, LOW);
}
void notifyCVResetFactoryDefault() {
//reset requested, set default address
Dcc.setCV(CV_ACCESSORY_DECODER_ADDRESS_LSB, DECODER_ADDRESS & 0xFF);
Dcc.setCV(CV_ACCESSORY_DECODER_ADDRESS_LSB, DECODER_ADDRESS >> 8);
//.....and impulse duration
Dcc.setCV(CV_IMPULSE_DURATION, DEFAULT_IMPULSE_DURATION);
}
void setup (){
Serial.begin(115200);
pinMode(ACK_PIN, OUTPUT);
Hi, I cannot see any errors... in general, you'd better download the sketch from github and not copy/paste it to avoid any problems with characters, folder names...
Thanks Luca I will download.
Thanks Luco I have downloaded the sketch and it now compiles but am not sure how to connect it to my loconet interface board, Wally.
Hi! This is a DCC board, you have to connect it to the DCC signal, not to the Loconet bus
Hi Luca sorry what is a DCC board, Wally.