SMA10 – Build a 17-Function DCC Decoder for about $5

geoffb's picture

My activities in Scale Model Animation often lead me to use DCC as a control method for sequencing. This could include building and street lights, even sparking welders and twinkling camp fires. Timing can be done with JMRI scripts (Like this: http://youtu.be/RXpvp5mIXvU?list=PL4dHfZjHc9t-pvctGQzSuOXBLG1M42xbS) or with programmatic control (Like this: http://youtu.be/zlcdJKXj_YI?list=PL4dHfZjHc9t-pvctGQzSuOXBLG1M42xbS). Control switches for such projects are a must. Using 4 or 6 function DCC decoders in this regard, can get costly, quickly. But with a little effort, and some low cost components one can build a DCC decoder supporting 17 independent functions for about $5.00, or less, depending what you have on hand.  This version has no CV’s, uses no DCC programming, can be set for any short address in CV1, and controls 17 Function Lines (which I am using to drive the green LEDs in the example below). Interested? Read on! (Latest Rev for this work can be found here: http://model-railroad-hobbyist.com/node/19446 )

Comments

geoffb's picture

@Paul re:Questions

Hi Paul,

With regard to the code for your basic 17 function decoder, one comment states "You MUST call the NmraDcc.process() method frequently from the Arduino loop() function for correct library operation".
I mentioned before that the complexity in the decoder sketches is largely in getting the timing correct for 17 arbitrary functions. But there is also the timing for decoding the actual DCC command packets received from the DCC bus/track. This is almost entirely done by Alex Shepherd's terrific NmraDcc library. This referes to collecting the bits off the DCC bus, examining them based on the initialization of the decoder including the address, and then routing them to the appropriate routine for actionable activities -- like moving a servo or switching a LED. But in oorder to allow the library to do all of its activity it must be called regularly so it can look for updates -- like did it get a valid command packet. If you do not call it often enough, via NmraDcc.process() it may miss a DCC command packet because it was not looking at the bus from the beginning of the command. So if the decoder sketch hogs the processor for too long, it doesn't give the library enough time to do its job. Speed command packets are resent periodically by base stations. Function and accessory commands are often repeated once or twice and then stopped, but there is no official standard for how often command packets are resent over a long period of time. Resending DCC commands at all was implemented to account for a decoder misreading a command while moving over dirty track or rail gaps. Thus, there is no specific time for how often you must call NmraDcc.process() other than "as often as possible." You might also note that if you added a bunch more functions to the Pro Mini processor via an extender chip, you might very well increase the likelihood of missing a command packet, since you would be tending to more internal functions.
 
regarding  the notifyDccFunc void, how does it get called?
You don't call notifyDccFunc, it calls the decoder sketch whenever any DCC function command is received and validated for the addressed mobile decoder. Remember, that this is called for every DCC function command received, including the duplicates sent by the command station. So to turn on let's say F7, you might actually get 2 command packets from the base station in a short time to turn on F7, and it could be more or less depending on the base station and track/bus conditions, as well as how busy your decoder sketch is.
 
'Hope this makes things a bit clearer. Never be afriad to ask a question. I have told my students and sons this for years: it's how we all learn. Also please direct future questions to the current entry in this series: SMA20 New Low Cost 17 Channel DCC Decoders & Dual Motor,LED, & Servo Control Updated: 6 Fntns/Pin & New Featureshttp://model-railroad-hobbyist.com/node/24316which also has the most up to date info and library for these decoders, and it makes it a bit easier for me too!  surprise
Have fun!  smiley
Best regards,
Geoff

Re Answers to questions

Hi Geoff

Many thanks for taking the time to provide detailed and succinct answers above. Very much appreciated. Your answers do make sense. Last post here as requested. 

Kind regards

Paul

Substitute for a Component not found at Digikey

Geoff:

What would be a good substitute for:

LM78L05ACZXCT-ND          IC REG LDO 5V 0.1A TO92-3  

Can't find it at Digikey.

Is this OK, from Amazon?

https://www.amazon.com/gp/product/B00VPAF5Q8/ref=ox_sc_act_title_1?smid=...

Thanks,
Jordan

 

Geoff: What would be a good

Geoff:

What would be a good substitute for:

LM78L05ACZXCT-ND          IC REG LDO 5V 0.1A TO92-3  

Can't find it at Digikey.

Is this OK, from Amazon?

https://www.amazon.com/gp/product/B00VPAF5Q8/ref=ox_sc_act_title_1?smid=...

Thanks,
Jordan

 

geoffb's picture

@Jordan re: Regulator substitution

Hi Jordan,

The part you referred to:  https://www.amazon.com/gp/product/B00VPAF5Q8/ref=ox_sc_act_title_1?smid=...  should work just fine as a substitute for the original one I specified.

Here is another one from Digikey.com:  https://www.digikey.com/en/products/detail/texas-instruments/LM78L05ACZ-LFT3/12324749

I no longer use this version of the regulator since it will only provide 100ma output, which barely powers the Arduino let alone LEDs and other devices connected to the decoder. You would do a little better with:
https://www.digikey.com/en/products/detail/stmicroelectronics/L4931CZ50-AP/1506450  which provides 250ma output in the same package.

However, even the 250ma is not enough to power servos, so I have switched entirely to using the DCC_Decoder3P version with the larger voltage regulator described here: SMA20 Low Cost 17 Channel DCC Decoders Ver 6.01 with Sound,Triggered Sound,Stepper,Dual Motor,LED and Servo Control  https://model-railroad-hobbyist.com/node/24316  versions of which can be found yielding 1A, 1.5A and 2Amp output (read this newer version).

Have fun!  smiley
Best regards,
Geoff Bunza


>> Posts index


Journals/Blogs

Recent Blog posts: