2nd Dec 2021, 10:23 PM
Replacing a dead decoder -- the hard way.
I have an Atlas U23B that cooked its factory decoder well after the warranty period. No knock on Atlas here, I have plenty of engines and they have been rock solid. Things happen. I contacted them to see if they still had replacements, and the answer is no. I highly suspect someone else offers a drop in board for these as they were sold in a DC only variant, I presume with a light board.
Anyhoo, it's been sitting on the shelf for quite a while. If you follow one of my other threads, I've recently cracked the code on how decode DCC in a PIC16 micro-processor, which means I've made 75% of mobile decoder. And while I know of many DIY accessory decoders, and one or two people who've made DIY decoders for HO or O, I am currently unaware of a hobbiest N scale decoder. (If you know of one, please let me know.)
And so, in some spare time in the past few days I whipped up a circuit. Then I took out the old board, measured it carefully, and set to work. Turns out these are actually a bit difficult. The board is quite narrow in the middle compared to some other engines, and worse the motor contacts are under the board in such a way that they take up the whole width of the board. So all traces from front to back must be squeezed on the top side.
But, with fine pitch low volume production and assembly now available to the hobbiest for a reasonable price it can be done!
I'm not sure it's the prettiest, or best decoder ever designed, but I think it's darn close to something that would work. For the electronics nerds in the house:
- The "power supply" is at the top, four diodes in a bridge, standard linear regulator to get 5v for the chips.
- U3, which doesn't have a 3D model for the chip, is a DRV8876 motor driver IC which makes driving the motor a zillion times easier. It has fault protection, and can measure current draw (which I currently don't connect, no pun intended). I've also configured it with a BackEMF tap off the motor output. Around it are the support components. The only notable one is the C8 capacitor, which is the bulk cap for the voltage going to the motor. It's a 1206, and the only large component on the board.
- U2 is a PIC16F15324 or PIC16F18324. The 18 chip is more powerful, and I know will do the job. I think the 15 chip will also do the job and save a few cents per board. They are pin compatible so the choice doesn't change the design any.
- Both IC's are UQFN-16 4x4's. Capacitors and resistors are generally 0201. LED's are 0401.
- Min trace is 0.2mm, power traces are 0.4mm.
- The board is fully single sided. The existing decoder is double sided, and I could make good use of the back real-estate -- but all the cheap assembly services are for single sided boards only, so I crammed it all on the top.
- The make "right angle" LED's...that is rather than the LED facing up on a surface mount chip it faces off to the side. The rendering doesn't show that, but I would probably spec bright white versions of those for this application.
- There is an ICSP header cleverly spaced about the processor. While it's just pads, they are in the 2.54mm pin spacing such that regular pogo pins would work nicely. They have been placed so new code could be loaded on the decoder without removing it from the locomotive.
I honestly have no idea if I'll try and have such a thing made. I was mostly curious how hard it would be to fit everything in, and the answer is not too hard! There's space out of the processor to control four more functions (F1, F2, F3, F4), but the way to drive them seems to be through a mosfet, and on this board with the narrow middle and no back traces I don't see how it could be done. It would probably be possible to drop two functions off the back end somewhere, but I don't know that such a thing would be useful.
Really, all the rest of the mumbo jumbo on the decoder sheet is software. All the CV's, options, BackEMF, it would all be code in the PIC. And while I don't think any of it is that hard or complicated, my guess is it would take several hundred hours of coding and debugging to get a basic working prototype. I'm not sure I want to put in that sort of effort.
I'm putting this out there as a conversation piece for the moment. I'll be curious to hear your comments!
The Following 13 Users Say Thank You to bicknell For This Useful Post:
Comfortably numb, Frank17913, HansKuster, Heiko, jimbo.0455, Moose2013, MoPac, reinhardtjh, Rook, Silent1961, SP-Wolf, Sumner, The Ol' Curmudgeon
2nd Dec 2021, 11:36 PM