This controller is the first one I built; I have refrained from publishing it here, because the original circuit is not my idea. I came across it at http://home.cogeco.ca/~rpaisley4/TTRThrottle.html (But I notice that address is no longer available)
As I have recently modified it, I thought for completeness I should post I there to go with my other controllers.
(https://farm1.staticflickr.com/900/41415255951_c2869170da_z.jpg) (https://flic.kr/p/266J1H6)LM317-based train controller (https://flic.kr/p/266J1H6) by H Norwood (https://www.flickr.com/photos/hnorwood/), on Flickr
(https://farm1.staticflickr.com/818/40519645545_459935f7d9.jpg) (https://flic.kr/p/24JzLWn)LM317 (https://flic.kr/p/24JzLWn) by H Norwood (https://www.flickr.com/photos/hnorwood/), on Flickr
[Figure 1]
The controller uses the LM317 three-terminal adjustable voltage regulator integrated circuit. The device has three pins, labelled Input, Output and Adjust. It is short-circuit proof and over-temperature proof (it may get hot but it won't be damaged!) It can supply up to 1.5 amps, which makes it ideal for "our" range of locos. The output voltage is determine by the ratio of two external resistors. The figure shows the basic circuit. The unregulated voltage Vin is applied to the Input pin; the regulated output, Vout, is determined by the formula:
V(out) = 1.25 (1 + R2/R1)
What is immediately obvious is that if R2 is zero (i.e. the Adjust pin is at ground or zero volts) then Vout is 1.25 volts. This means the device cannot supply an output lower than 1.25V. This is not a problem as I shall show there is a workround. {There is also a small error caused by a current of typically 50 micro amps that flows out of the Adjust pin to ground. This produces a voltage of around 50 milli-volts per 1000 ohms in R2 and is of no consequence in our circuit.}
So, how do you make it into a variable voltage supply? You replace R2 with a variable resistor (also called a potentiometer).
(https://farm1.staticflickr.com/815/41372876712_5137f55080_b.jpg) (https://flic.kr/p/262YNQy)LM317 based train controller (https://flic.kr/p/262YNQy) by H Norwood (https://www.flickr.com/photos/hnorwood/), on Flickr
Going from left to right, the 16V ac from the transformer is rectified, then smoothed by the 2200 micro Farad capacitor before going to the Input pin of the LM317T. The small value capacitor (shown as 4.7 nano Farads) is to prevent high frequency noise upsetting the device. There are two 1N4001 diodes that act to prevent damage to the LM317 in the case of some types of short-circuit. The 10 micro Farad capacitor between the Adjust pin and ground improves ripple rejection (i.e. it makes the output smoother).
The 1k ohm resistor (R1 in fig 1) and the 4k7 potentiometer (R2 in fig 1) as shown will give a maximum output to the tracks of 6V. I have added a double-pole centre off switch that allows the user to decrease this resistance and so increase the maximum voltage. Putting a 1k8 resistor in parallel with the 1K will produce 9V, and putting a 910 ohm resistor in parallel with the 1K will produce 12V. The idea here is that lower-voltage motors will still benefit from the full throw of the potentiometer - hence more control.
As for the two 1N5401 diodes - these provide a voltage drop that counters the 1.25V minimum voltage produced by the LM317. The output to the tracks does now go from zero to the maximum set by the value of R1. As an alternative you can use 4 1N4001 diodes thus
(https://farm1.staticflickr.com/879/27543908178_5bd6cc4cd6_b.jpg) (https://flic.kr/p/HXXJhA)LM317-based train controller (https://flic.kr/p/HXXJhA) by H Norwood (https://www.flickr.com/photos/hnorwood/), on Flickr
I have also put in a LED (and dropper resistor) to light up when power is applied to the tracks.
The centre-off double-pole double-throw switch acts as the reversing switch, with the centre position isolating the tracks.
(https://farm1.staticflickr.com/871/40519646085_3261957836_b.jpg) (https://flic.kr/p/24JzM6F)LM317-based train controller (https://flic.kr/p/24JzM6F) by H Norwood (https://www.flickr.com/photos/hnorwood/), on Flickr
The majority of the small parts can be soldered to a small piece of matrix board, as seen in the photo of the controller opened up. Matrix board is a sheet of insulating material which is drilled on a 0.1" square matrix and on one side of which are copper tracks linking the holes together in rows. The LM371T and the bridge rectifier are fixed to the inside of the lid of the diecast aluminium enclosure. In the case of the LM317T, this allows the enclosure to be used as a heatsink for the device. It should be mounted with an insulating kit as the "tab" on it is at Vout. The device is also used to hold the small circuit board fixed. The two switches, the potentiometer and the LED are also mounted on the lid.
Here's a couple of close-up photos of a completed controller, showing where the major components are. (Of course, you don't have to stick with this setup!)
(https://farm1.staticflickr.com/876/27543907418_78a25c229e_z.jpg) (https://flic.kr/p/HXXJ4u)LM317-based train controller (https://flic.kr/p/HXXJ4u) by H Norwood (https://www.flickr.com/photos/hnorwood/), on Flickr
(https://farm1.staticflickr.com/896/27543907798_b8b4bed03b_z.jpg) (https://flic.kr/p/HXXJb3)LM317-based train controller (https://flic.kr/p/HXXJb3) by H Norwood (https://www.flickr.com/photos/hnorwood/), on Flickr
Notes
Over the years, I have built a number of these controllers, so I offer a few jottings concerning this controller.
The integrated circuit
The LM317 comes in a number of "types"; I have used the LM317T and this has a metal tab which is used to fix the device in place, and to help dissipate any heat generated in the chip. However, the tab is electrically connected to the centre "leg" of the device (which is the Output) and so you have to be careful not to accidentally connect it to somewhere it shouldn't go! Hence the use of an isolating kit when fixing it to the enclosure.
There is another type, called the LM317P, which has this tab fully enclosed in plastic, so that it is electrically isolated, and an isolating kit is not required for this device. However, it would be a good idea to put some form of thermal transfer material between the device and its heatsink.
The enclosure.
I have used a diecast metal box for the controller; it is a comfortable size and, being metal acts as a convenient heat sink to dissipate the heat that is generated by the LM317. There's no reason why a plastic box cannot be used, but you will need to mount the LM317 on a piece of metal (a heatsink) to take away the aforementioned heat. OK, the LM317 has an internal thermal overload which will prevent it overheating, but allowing it to run at a high temperature may shorten its life.
One drawback of a metal case is that there is the possibility of components or the underside of the circuit board touching the metal and causing problems. I have slipped a piece of thin card or thin styrene sheet under the boards in my controllers; the card is visible in the photos.
The potentiometer
I have found that the actual resistance of a variable resistor my be quite far from what it says it is; use a multimeter to find out what value it is, then adjust the values of the resistors used to set the maximum output (the 1k, 1k8 and 910 in the diagram) to suit.