# Build a Track Powered Adjustable DC Power Supply



## gunrunnerjohn (Nov 10, 2010)

Here's all you need to fabricate a variable voltage DC supply from track power. This design is good for at least 200-300 milliamps of DC, maybe more under the right circumstances.

Although this was created for use primarily for O-gauge trains with AC track power, it will work for any command system with constant track power, AC or DC. It also includes provisions for jumpering for isolated ground with full-wave rectification or common ground with half-wave rectification. This flexibility is needed for certain applications with O-gauge trains, and may be useful for other gauges as well.

*Here's how I make them.*

I use this DC-DC switching module from eBay for the regulator section, currently around 37 cents each on eBay.

2PCS New Mini 3A DC-DC Adjustable Converter Step down Power Supply LM2596S









I sandwich that under my PCB to create this power supply module.









Attached are the Gerber files to create the PCB, the schematic of the board, and the BOM for the parts needed.

Gerber files for PCB Fabrication:
View attachment AC-PS Gerber.zip


Bill of Materials








Schematic Diagram


----------



## wvgca (Jan 21, 2013)

should be good for those who want [or need] to pull power off the rails...


----------



## gunrunnerjohn (Nov 10, 2010)

Yep, that's what it was designed for. I sometimes have the need to power stuff that's a bit more power hungry than a linear regulated supply will do.

I even laid out the same style with a large capacitor to increase the filtering so it could supply more current. I haven't build this one yet, but there's no reason to believe that it won't work, it is the same design as the one above.  The only downside is the larger cap makes it less likely to fit in a lot of situations, it's a 680uf cap, giving me over twice the filtering of the 300uf on the existing one. The additional capacitance comes at the expense of the height of the package.


----------



## gregc (Apr 25, 2015)

what don't i understand?

if you pass DCC thru a bridge, how much capacitance do you really need? (peak to average is practically 1, unlike a sinusoid)

wouldn't the coil be more useful, if needed at all, on the output where there's DC instead of the input where there's AC. (doesn't the coil on the input make the voltage across the bridge more sinusoidal)?


----------



## gregc (Apr 25, 2015)

gregc said:


> what don't i understand?


sorry, i assumed it was for DCC


----------



## gunrunnerjohn (Nov 10, 2010)

Well, I pass 60hz AC through the bridge, so I need a bit more filtering.  For DCC, you don't need as much filtering as it's higher frequency.


----------



## gregc (Apr 25, 2015)

gunrunnerjohn said:


> Well, I pass 60hz AC through the bridge, so I need a bit more filtering.  For DCC, you don't need as much filtering as it's higher frequency.


while i'm sorry I was careless in misreading your post, i believe for DCC you would need very little filtering not because it's higher frequency but because it's square waves (peak-to-average ~1).


----------



## gunrunnerjohn (Nov 10, 2010)

Well, you'd be wrong.  The switching power supply wants to see pure DC, not square waves. Depending on the frequency, you'd need less filtering, but for a 60hz square wave or a 60hz sine wave, you'd need pretty much the same amount of filtering to make the switching power supply happy.


----------



## gregc (Apr 25, 2015)

gunrunnerjohn said:


> but for a 60hz square wave or a 60hz sine wave, you'd need pretty much the same amount of filtering to make the switching power supply happy.


if you rectify a sinusoid, the voltage is less than half the average voltage for a significant amount of time.

if you rectify a bipolar, +/- not +/0, waveform the output is + and only dips during the slew period (<< 1 usec) when the voltage changes polarity. how much capacitance does a decoder have to provide dc power for the processor that is very susceptible to momentary drops?


----------



## gunrunnerjohn (Nov 10, 2010)

Good point Greg, I don't do DCC, so I haven't considered it. However, you will need some filtering, hard to say how much.


----------



## gregc (Apr 25, 2015)

i saw a 1uf (105) tantalum cap on a picture of a decoder. I think it's overkill for maintaining DC, but excessive to handle momentary loss of power that inertia can ride thru to prevent a decoder processor reset.

i can't find a spec for how quickly DCC needs to change polarity.


----------



## wvgca (Jan 21, 2013)

gregc said:


> i can't find a spec for how quickly DCC needs to change polarity.


it varies due to data in the stream .. spec is listed on many sources


----------



## gregc (Apr 25, 2015)

S-9.1 describes the period between polarity changes: nominally 56 usec for a "1" bit and <= 100 usec for a "0".

i don't see a spec for how quickly it must change from + to - polarity, that vertical edge in the diagram, the slew rate.

it's that small time that rectified DCC would dip and may require filtering.


----------



## wvgca (Jan 21, 2013)

it doesn't show a value for that time, but based on the 'scope reading, it -probably- is around two millisecond ..
by the way , DCC actually doesn't change polarity, it's just where you happen to set zero on the 'scope ..
also, the 'bit' includes both halves [in your terms positive and negative], so the actual bit length is double what you stated


----------



## gunrunnerjohn (Nov 10, 2010)

In any case, the supply should work fine with DCC, assuming the voltages are sufficient for the output desired. Since this is a buck supply, you need a couple more volts of DC going in that you'll be able to get coming out.


----------



## gregc (Apr 25, 2015)

wvgca said:


> by the way , DCC actually doesn't change polarity, it's just where you happen to set zero on the 'scope ..


_The NMRA baseline digital command control signal consists of a stream of transitions between two equal voltage levels that have opposite polarity_​
i understand that a unipolar power supply is being used. But mosfet switches of an h-bridge are alternately connecting the supply leads to opposite rails so that from the track perspective, the polarity is changing.



wvgca said:


> it doesn't show a value for that time, but based on the 'scope reading, it -probably- is around two millisecond ..


considering that the "1" bit is nominally 58 usec, the transition has to be much less than than 58 usec.

when you look at that rising (or falling) edge on a scope at high resolution (ns/cm), you can measure the time it takes to change level. In the trace below (not for DCC) there's a 3 usec rise time that would show up as a dip in a rectified waveform that a relatively small capacitor can filter.

This Allan Gartner page says the rise time is 240 ns.


----------



## wvgca (Jan 21, 2013)

whoops .. entered millisecond when i should have used usec .. sorry about that ..


----------



## gunrunnerjohn (Nov 10, 2010)

One of the features of my power module is having a common frame ground capability if you use the half-wave option. This is required when you are using TMCC and early Legacy if you power something interfacing to the Lionel electronics. The full-wave option was to provide more power, assuming that the output would be totally isolated from frame ground.

I don't know if the ability to reference to frame ground is an issue with DCC, one would assume it might not be, but I can't say.


----------



## Millstonemike (Aug 9, 2018)

gunrunnerjohn said:


> Here's all you need to fabricate a variable voltage DC supply from track power. This design is good for at least 200-300 milliamps of DC, maybe more under the right circumstances.
> 
> Although this was created for use primarily for O-gauge trains with AC track power, it will work for any command system with constant track power, AC or DC. It also includes provisions for jumpering for isolated ground with full-wave rectification or common ground with half-wave rectification. This flexibility is needed for certain applications with O-gauge trains, and may be useful for other gauges as well.
> 
> ...


John, I have to pick your brain a bit (sorry, I know your busy).

It so happens I had one of these buck regulators in my parts bin - purchased last year. Nearly identical board as in your pic., but labeled version 1; two passive resistors missing or so, all else the same.

I just tested it with a DC feed (at variable voltages). Works ok but I noticed this: If the input voltage isn't high enough to support the the module's set output voltage, it was erratic, sometimes going to 0 until you reset the output voltage low enough it could operate with the given input voltage; sometimes doing the best it could given the input voltage. I'm wondering if you noticed that and if you thought there were any ramifications for conventional operation: stop the train, no voltage, etc. This is in contrast to the linear regulators that consistently provide the best output they can given a insufficient input. I ordered the exact same module you have so maybe there's a difference between the two.

Also, in your rectifier module, what is the purpose of the inductor before the bridge (forgive me, I forgot the stuff I learned some 40 years ago as my design career went all digital).


----------



## gunrunnerjohn (Nov 10, 2010)

There's no defined behavior with some switchers if you violate their input/output limitations, I've seen that before. 

The inductor is for DCS compatibility, obviously this is primarily for O-gauge operation. Without the inductor, the circuit can degrade the 3mhz DCS carrier on the tracks.


----------



## Millstonemike (Aug 9, 2018)

Some unpleasant updates from my testing.

I fronted the buck regulator with a 19 volt "brick" via a linear regulator module. At 17.5 volts the input cap shorted and linear regulator stayed in protect mode. Removing the input cap solved that issue. 

I then fronted ended it with a 6 amp bridge and a 3600 uf cap. I wanted conventional throttle control so I used a basic Marx 0 then 6.5 - 12.5 AC no load.

Set at 3.4 V it put 200 ma amps into a 5 V 90-LED string. It was hot, but ok. Upping the voltage over 6 V it put 1 amp into the string. Both the LM2596 and the inductor were sizzling. As expected, the higher the transformer setting, the hotter it got.

Then the trim pot took a dive. It would only switch between two voltage settings through it's full rotation: ~3.4 and ~6.8 V.

Heat could be problem sandwiched under your regulator module for the your high current design.

I had ordered 5 from Ali. I'll test again when they arrive. An I can borrow an infrared digital temp gun.


----------



## gunrunnerjohn (Nov 10, 2010)

Mike, that's why I mentioned a couple hundred milliamps. The 3A rating of these is a fantasy!

Also note that I added copper to both sides of my PCB to act as a heatsink and help with power dissipation.


----------



## Millstonemike (Aug 9, 2018)

On another note, I reviewed TI's specs for the LM2596 and TI's design documents and they call for inductors well above 4.7 uH (see pic below). Neither the inductor in my test unit nor the inductor in your first post's picture is labeled. But I do see many offerings where the inductor is clearly labeled 4.7 uH including the 5 I have on order and the eBay link in your first post.

While not my forte, the inductor does store energy to support the regulation scheme. Having an inductor 1/10th the recommended size is likely causing serious inefficiencies.

I have just ordered *This *similar module with a 100 uH inductor for testing.


----------



## gunrunnerjohn (Nov 10, 2010)

That one you posted it 10uh, not 100uh. I just measured one.

You might also take note that the module I'm using, as well as the one you just pictured, are using the MP1584 3A Step-Down Converter, not the TI part.  A giant clue is the TI part doesn't come in the 8-pin package. Probably be best to be looking at the right data sheet.


----------



## Millstonemike (Aug 9, 2018)

Including the Monolithic Power's MP1584. Lowering the inductance requires an inductor with a higher current rating and saturation threshold. And the efficiency goes down the drain. In the model below the 47 uH inductor has a current rating of 0.49 A. If I replace that with a 4.7 uH inductor with a 2 A rating, the efficiency is becomes incalculable.


----------



## gunrunnerjohn (Nov 10, 2010)

I'm guessing the designers of my module know something we don't. I just pulled one out, I put 10V from a bench supply in, and I have 5V out with a 10 ohm resistor across it. measured current through the resistor is 460ma, and the bench supply is indicating 275ma at 10 volts. So, the switching efficiency is around 82-83%, not too bad IMO. At 20 volts in, I'm at 140ma in for my 460ma out.


----------



## gunrunnerjohn (Nov 10, 2010)

FWIW, the board is loafing at 90F as the highest reading of the parts on the board. It's not even breaking a sweat to give me 500ma at 5V.


----------



## wvgca (Jan 21, 2013)

500ma seems pretty good, wasn't this board designed for an output around 200ma ??


----------



## gunrunnerjohn (Nov 10, 2010)

It actually claims 3A, but that's pretty much a pipe dream. The limitation I have with AC power is the size of the filter caps, which is why I am thinking about a module with larger caps. Of course, my Super-Chuffer has a little switching module on it that's pretty small and is rated at 500ma. Again, my limitation is the size of the caps I can put on the board, but I only need around 100-125ma out of it, so it's always worked fine.


----------



## Millstonemike (Aug 9, 2018)

gunrunnerjohn said:


> FWIW, the board is loafing at 90F as the highest reading of the parts on the board. It's not even breaking a sweat to give me 500ma at 5V.


Well empirical results don't lie. A lot different than my experience.

Were you testing the module in your first pic or the one from the eBay link? In the pic, the inductor doesn't seem to be labeled. In the link it's 4.7 uH.


----------



## gunrunnerjohn (Nov 10, 2010)

I was testing the one that says 4R7 on the inductor. I think the markings on the picture are just faded and don't show up at the camera angle, I bought all the boards at the same time. FWIW, I had tested these on the bench before I made the little top board, and I was happy with the performance.

I never spent any time analyzing the circuit or the parts they used, I just wanted a working small board. The first one that was even smaller was a problem as they rated it at 23 volts, and I did cook one. So I went with this board rated at 28 volts, and I've never had any issues with it.


----------



## Millstonemike (Aug 9, 2018)

John,

Thanks for the info and being patient. Not sure what was up with my module. The offer's picture showed the 1584 chip and 4.7 uH inductor but neither is marked on the actual board. And it wouldn't be the first time I received small electronic modules populated with the wrong parts.

I'll revisit when my new orders arrive.


----------



## gunrunnerjohn (Nov 10, 2010)

Hard to say, but since I have another 15-20 of them, I can afford to change if one takes a dump.


----------



## wvgca (Jan 21, 2013)

gunrunnerjohn said:


> Hard to say, but since I have another 15-20 of them, I can afford to change if one takes a dump.



it's been a month .. do you have a layout up to see if these will last ??


----------

