DIY decoder

Hi,

Did anyone try to build own decoder? It would be interested to know how it looks like.

Regards

Walid

recent threads got me thinking about the this. can you build one small enough?

The question is, can i build one in the first place?

As for the size, it depends how small it should be. I guess the size of a cab unit, drop in decoder is feasible. However, to be compatible with everything from legacy equipment to the latest standards and DC, is a bit pain in the neck to extract the information from NMRA documents.

Therefore I was asking is someone ever did [:D]

The interesting thing about building your own, it can be a custom sized to fit a particular engine. Some parts in the front, some in the back connected by wires.

Sounds like a nightmare though.

Yes.

Maybe I am stupid, but when it comes to NMRA documents, yes, it is like a nightmare.

pretty straight forward …

did one for HO a few years ago, no sound, but with BEMF and keep alive connections

Interesting… more details, please.

Possible probably, but I can’t imagine it being cost effective unless you like doing that sort of thing for its own sake.

used freely available public domain code, pcb in eagle, cost was $10 each in lots of 10 [pre assembled]

Well, consider lighting cars interior. A train contains 8 - 10 cars x 20$ each, you end with 160-200$/ train. If you cut the costs by 50 or 60% you can save cash.

Regards

http://model-railroad-hobbyist.com/node/19070

http://model-railroad-hobbyist.com/blog/geoff-bunza

Several, if you google diy dcc decoder. Don’t know if anyoone’s tried sound - that’s orders of magnitude more complex that a motor only decoder, just because you have to ALSO code the sound playback, and you need a powerful enough microcontroller (that’s the problem with early Digitrax sound decoders and why they slow down when playing sounds if BEMF is turned on - the micro is not powerful enough to handle reproducing sounds AND calculating BEMF in real time.). All of the popular sound decoders use custom or semi-custom chips, probably FPGAs.

A motoor decoder is fairly simple, there is a bridge rectifier, a voltage regular to get the 5 or 3.3v for the micro, an transistor array for function drives, and an H bridge for motor drive. It’s mostly software. A few passives for filtering and so forth. To get it small enough requires skill with surface mount components. I doubt many is any motor only decoders are more than a 2 layer board.

NMRA DCC decoder firmware is available for PIC and Atmel processors at least, as open source software. You just have to write the part that does somethign when the device sees packets addressed to it.

–Randy

i wonder about simply reprogramming an existing decoder, since i’m curious about changing the behaviour (momentum, speed curve, BEMF).

if the chip is locked and unable to be reprogrammed, i wonder if it could be replaced and in circuit programming (ICP) leads added

Oh goody, this has been a long time question for me. I have done some looking, and my results are as following: either the decoder project did not have very clear instructions and info about it, or it was to big to actually fit in a locomotive, like the first link in the earlier post. Haven’t really found anyone who made a budget friendly sound decoder yet either. Anybody know if there are instructions for those out there?

The problem with sound decoders is… the sound. You have to pay someone (or go yourself) to go out and record the (insert what you want), or license the files from someone else.

Do you mean an official NMRA version? If yes, where can I get it?

Walid

There is no official NMRA software. Just people who write software that decodes the NMRA packet standards. It can be convoluted in places because they tacked stuff in later as they added features, but mostly it’s all just bit pattern matching to determine the next step in decoding a given packet - in the standards I’m referring to sections where it says for example if bits 7 and 8 are set then it’s X type of packet and it directions you to the next section for the meaning of the other bits, or if bit 7 is 1 and bit 8 is 0, then look to a different section for what the rest of the packet is.

And you don’t try to do it all in one decoder - if you are building a mobile decoder you can completely ignore all stationary decoder packets and vice versa.

While a decent and potentially fun project if that’s your thing, I doubt you could ever save money over commercial decoders. Even if you value your time at 0.

As for replacing an existing one - if you can determine which micro is used, I’m sure you could. Need to do a little circuit tracing to determine which pin gets the DCC signal to decooder, which are hooked to the function outputs, and which are hooked to the H bridge for motor drive, but that’s shouldn;t be too difficult. I wouldn’t doubt that some decoders which are not field updatable use mask rom versions of the micros, so you may need to find a pin compatible programmable one for a replacement rather than a direct replacement. If would be very unlikely that the manufacturer would leave the micro unlocked so that you could read the source code, and by letter of the DMCA that would be illegal anyway.

–Randy

Randy,

Main problem was/is to understand the NMRA documents. I could achieve some progress, but the backward compatibility (who needs 14, or even 28 speed steps??), especially the programming (of the decoder), are really stupid. There four ways to manipulate the CVs and do the programming. Perhaps there are even more. I am at the stage to build circuits and perform testing (well, each time I thought I am done I found other things to do). My idea is to start with a function only decoder, essentially for interior lighting, and move to motor decoder later.

Regards

Walid

if you look thru these links, you’ll find a zip file containing NmraDcc.cpp/h which presumably receive and decode DCC packets

Thanks, I will have a look.