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

@Dave debugging

Dave,

You should not have had to change the 0 to a 1; if you built the same circuit it has the right pull up resistor. The message you listed was a speed message not a function message. Try putting a loco on track with the same address as the decoder (I explained how to set the decoder address upon loading). And make sure you are setting some function correctly like F0 headlight on. You will have to look through the long string of messages as they come by quickly. Perhaps we could carry this on off list-- send me your info via PM. Also, did you change anything else in the code at all? & did you download & install the specific libraries I provided? Also make sure you're using only short addresses. What DCC controller are you using?

Best regards,

Geoff

 

geoffb's picture

@Dave again

Dave,

If you used the 10K resistors for the LEDs, try changing them to something lower like 1K as I was using those ultrabright green LEDs for my indicators and likely yor are not!

Let me know how it goes.

Best regards,

Geoff

 

Dave O's picture

Parts ordered ...

I ordered the Pro Mini atmeg328 (x10) and the USB cable as well as the boards from the sources Geoff listed ... free shipping!  Whoot!!!  That is HUGE for me as Sri Lanka charges duty (115%) on the entire invoice, including shipping and insurance costs ....

I also sourced the OptoCoupler, the Voltage Regulator, and Schottky Diodes from another supllier that offered free int'l shipping.

I did look at Digikey, but $75 for shipping was a non-starter.  I contacted them about using USPS First Class International (~$16); so might have a fall-back if I can't find the rest of the stuff here locally.

For Geoff ... couple more basic questions.

1. From an earlier comment, seems the voltage drop resistor for the LED's depend on the LED?  Ultra-bright ~10K while a "normal" intensity would be ~1K ... guessing this is something that I may have to play around with on my own to find a good combination?  (I will attempt to find the ultra-brights and use the 10K per the schematic; but asking in case these are not so easy to find here?)

2. For the (as described) DCC Function Tester, I understand the LED's are required for indication/confirmation of the signal.  Would these LED's also be included in a decoder that was being used for another function (i.e., a dcc controlled building)?  I *think* that what I am asking is: "Will all dcc decoder projects start with this basic module assembly including the LED's?  Or will the LED's be omitted from decoders that are designed for other applications (open close doors/gates, trigger sounds, etc.)?"

3. Probably a really silly question ... I see on the schematic that the inputs are coming from each of the rails ... and then there is a "ground".  Am I correct in assuming that the "ground" is simply a common connection between those four points?  I only see two wires being used (both connected to the track).

Thanks again.  Dave O

LED 101s...

Dear Dave,

LED 101

- LEDs are current-driven devices, it's the Amps rather than the Volts which dictate the visual brightness result. (although, increasing the Volts appears to change the brightness, as per Ohms Law, see below).

- According to our old friend Ohms Law

E = I x R

Volts = Current (Amps) x Resistance (Ohms

we know the Volts
(how many Volts are we feeding to the LED, 
minus the stated "forward voltage drop" accross the LED-in-question)

and we can control the Resistance
(IE we choose the appropriate resistor)

so the variable we want to predictably-set is the Current.

- Now, it's a reasonably safe assumption that most LEDs can electrically handle,
and output max visual brightness at around 20milliAmps, or 0.020 Amps

- The variable is that a "High Brightness" LED when driven by 20milliAmps may well output 1000s of milliCandela (mcd) brightness

http://www.satisled.com/3mm-water-clear-round-ultrabright-red-led-1000pc...
(2000-3000mcd @ 20mA)

whereas an equivalent "typical/normal/cheapo" LED may only output 10s of milliCandela (mcd) on the same current supply

http://www.jaycar.com.au/productView.asp?ID=ZD0100
(40mcd @ 15mA)

IE Same Voltage and approx same current applied, but visually very-definite difference in brightness due to and design of the LED in use

SO

- from an electrical P.o.V, the pat "1K ohm resistor, and you'll be good" answer is a good catch-all starting point, in the sense that most LEDs available will visibly "turn on" under most conditions 5V <> 12V,
(they may not be "full rated brightness", but they will be "obviously ON"),

and will be able to survive being connected to 16 or even 24V.
(a 1K resistor gives a degree of "safety net" headroom... ;-) ).

EG Assume
- 12V supply
- 1.5V drop accross the LED
= 10.5V working value

Assume a 1K (1000 Ohm) resistor

10.5 = ??? x 1000Ohms

= 0.0105 Amps
= 10.5 milliAmps

= about half the "max brightness" current for the average LED
(but still more than enough for the average person to say, "ah yes, the LED just turned on and is visible").

- However, such "pat answer" doesn't address the altogether-more-specific/critical aesthetic issue of whether a given current results in a "too bright (or dim)" result for the application. 
(a 10K ohm resistor on the above-mentioned High-brightness LED would give a pleasing "dim red",
but on the "basic LED" would likely fail to give a "obvious visual turn-on" at all....)

Hope this helps...

Happy Modelling,
Aim to Improve,
Prof Klyzlr

 

...

You built a 17 function decoder out of $5 of parts...

Why should we ever want to pay a premium for a commercial company to do what they do professionally?

Have you considered porting an HDMI connector to the board?  it would remove any need to solder to the board, and a wired HDMI connector offers an expansive number of leads...

---------------------------------------------------------------------------------------------------------

Benny's Index or Somewhere Chasing Rabbits

Dave O's picture

Thanks Prof ...

... clear as mud ... but, not a problem.  :)

I had thought that as the resistor is in series with the diode its true purpose is to drop the voltage (which by Ohm's Law) will also drop the current; had it been in parallel, it would have acted as a current divider ... but, six of one, half a dozen of the other?

Went to a local electronic parts store a couple of blocks from my home (my daughter had pointed it out to me when I was looking for a small speaker).  Nice place, sort of like a Radio Shack (on a budget).  They actually stocked all the remaining parts with the exception of the Bridge Rectifier.  They had a 50V 1A available, but not a 1.5A.  They will see if they can get some for me ... wouldn't think that it would be a big problem.

I bought a set of ultra-bright LED's with 10K resistors and a set of "normal" LED's with 1K resistors ... figured I'd give them both a look-see and decide which I prefer.  ;)

I did substitute a 272 pf 50V capacitor for C8 (270 pf 25V) ... hopefully it will work?  If not, wasn't a lot of money and I'll look for the proper cap. 

The rest of the stuff is expected in about 3 weeks(?) free shipping is slow, but I have the time.  :)

I could probably use a few tips on soldering these components ....  I have a 60W iron, thinking that may be too hot?  Any recommendations for this?  Thanks again for all the good info ... really excited about this project.  :)

 

geoffb's picture

@DaveO questions

Hi Dave,

Re:1 The Prof's conclusion is correct, a typical LED will be barely on with a 10k resistor, but "ultrabright" is not a technical spec, just a description. I get those green LEDs from SurplusGizmos.com and there're just SG's normal green 3mm LED! I use them because they are bright with less than 1ma! LEDs vary in color and brightness all over the place-- so experiment with resistor values.

Re:2 I put the LEDs on the board ONLY for demo purposes. When I use one to switch building lights the LEDs are obviously off-board and not all functions may be used. It was a happy discovery that the demo with all the LEDs on board became a diagnostic tool, using it in parallel with another decoder with the same address! Strangely enough I am starting to use it as a diag tool more and more! This decoder like commercial ones, does not consider the LEDs as part of the decoder itself, and likely neither will future decoder projects. But they may very well drive LEDs in some way.

Re:3 You are correct-- the "ground" in this case is merely a circuit "common" not an "earth ground."

Have Fun.

Best regards,

Geoff Bunza

 

geoffb's picture

@Benny

Hi Benny,

In many ways, this decoder is simpler than a commercial one, not as neat, or small, and the cost does not include my labor, nor shipping, documentation, inventory carrying costs, advertising costs, and profit. 

I probably won't use any kind of connector at all, simply because all my connections would be point to point soldered. If you use connectors when you build one, I'd really like to hear how yours turned out.

Best regards,

Geoff Bunza

 

LKandO's picture

DIY electronics

Why should we ever want to pay a premium for a commercial company to do what they do professionally?

Same question I asked about circuit breakers and block detectors.

I probably won't use any kind of connector at all

Connectors (terminal blocks) are the most expensive individual item on the RR circuits I have built so far. Amazing that one can buy a fully functional microprocessor for less money than a strip of plastic with 12 screws in it.

Glad to see a lot of MRH reader interest in your creation Geoff.  

Alan

All the details: www.LKOrailroad.com        Just the highlights: MRH blog

When I was a kid... no wait, I still do that. HO, 28x32, double deck, 1969, RailPro

Michael T.'s picture

Thought I posted this already....

...but either I made some type of error or it was accidently deleted in some way.  A 60 watt soldering iron is too big for this type of work. The max I would recommend is 30 watts and I'd probably go smaller than that depending on what is available to you Dave.

Michael

Michael

Original member of the "Gang of Six"

R.I.P. Verne Niner. The time I got to know you was way too short my friend.

"We all model the prototype, to suggest otherwise is ridiculous"

My Pike, https://mrhmag.com/blog/MichaelT

 


>> Posts index


Journals/Blogs

Recent Blog posts: