# DIY Model Train controller project

Model trains are fun toys which every one of us used to play with in our childhood. Many sophisticated and attractive model trains are available in the market now a days yet the basic principle in build a controller for it remains the same. I built a Model train controller which is equipped with Acceleration and deceleration control using the PWM technique. And also Forward reverse button to control the direction.

## WORKING OF CIRCUIT DIAGRAM:

Please refer to Controller unit circuit for this discussion. The heart of the oscillator is U1A, R1-R5, and C2. R1 and R3 divide the V1 supply voltage in half and their combined resistance is R1*R3/(R1+R3) = 50K. Since R2 = 100K, when the output of U1A switches from ground to 15 volts (+V1), the junction of U1A+, and R1, R2, R3, switches from 5 volts to 10 volts. R5 starts charging C2. When C2 charges above 10 volts, the input of U1A- is higher than U1A+. That causes the output of U1A to switch to 0 volts. In turn, the junction of U1A+, and R1, R2, R3, switches from 10 volts to 5 volts. R5 begins to discharge C2. When C2 discharges below 5 volts, the input of U1A- is lower than U1A+.

The output of U1A switches from 0 volts to 15 volts (+V1), the junction of U1A+, and R1, R2, R3, switches from 5 volts to 10 volts. R5 begins to charge C2 and the cycle keeps repeating. C2 is constantly ramping up and down between +V1*1/3 (5V) and +V1*2/3 (10V). The really cool thing is that this circuit oscillates at the same frequency even if the supply voltage +V1 changes! The oscillator frequency chosen for the train controller is about 50 Hz (20 mS period).

The low frequency was chosen so that the motor armature could turn slowly, one segment at a time for control at very slow speeds. Train motors generally have a 2 mS to 5 mS time constant and therefore the PWM period must be at least five to ten times as long in order to have good slow speed control.

U1B acts as a comparator to provide the 0% to 100% PWM output. R6, R7, and R8 form a resistive divider. Notice that R6 and R8 are 10% lower resistance than potentiometer R7. Doing the math 15*(R7+R8)/(R6+R7+R8) = 15*19.1K/(28.2K) = 10.16 volts at full clockwise (100% ON), and 15*R8/(R6+R7+R8) = 15*9.1/28.2 = 4.84 volts at full counter-clockwise (0% OFF). The U1B- input is connected to the junction of R5 and C2 which ramps up and down between 5 and 10 volts. U1B+ is connected to the wiper on potentiometer R7.

Whenever the oscillator ramp voltage is lower than the wiper reference voltage, the output of U1B goes high and whenever the oscillator ramp voltage is higher than the wiper reference voltage, the output of U1B is low. Since the wiper reference voltage can be set lower than the lowest ramp voltage, 100% ON time is possible. Additionally, since the wiper reference voltage can be set higher than the highest ramp voltage, 0% ON time (100% OFF) is possible. This cannot be done with a 555 timer. So OFF can really be OFF and ON can be full ON.

The output of U1B is connected to a switch to power the load. In Figure 1, the output is connected via R10 to the gate of Q1, which is an IRLZ44 MOSFET transistor. D3 and R11 protect the gate of Q1 from being over-driven with voltage. R12 provides a light resistive load to Q1, while D4 protects Q1 from inductive load, voltage spikes.

S1, R9, and C3 provide the ACCEL/DECEL function for the train controller. When switch S1, Accel/Decel ON/OFF, is open, R9 and C3 cause the wiper reference voltage, at the input of U1B+, to change very slowly as R7 is adjusted up or down. This provides a slow acceleration or a momentum effect for a model railroad train. The ACCEL/DECAL time constant, set by R9 and C3, is around 30 seconds. That is the time needed to accelerate to full speed or decelerate to a stop. Switch S2, a DPDT slide switch, is wired to provide the Forward/Reverse polarity function.

The above circuit was designed for a two channel, track or train control. However you can expand this circuit to control up to 3 channels. In order to do that Duplicate R6-R12, C3, U1B, D3-D4 and Q1, use IC LM324 quad Op-amp for 2 or 3 channels. Channel 2 designations = U1C, R6=R13, R7=R14, R8=15, R9=R16, C3=C4, R10=R17, R11=R18, D3=D5, R13=R19, D4=D6,Q1=Q2,S1=S3,S2=S4. Doing this you will get extra channels in your project.

## BUILT CONTROLLER:

Internal Circuit board of controller

Dual Channel Train controller

## NOTE:

1. Up to three total speed controls can be connected to U1A+, R5, C2 to run separate track loop functions.
2. T1 may need more amp ratings to accommodate the multiple tracks and trains.

## JLCPCB - Prototype 10 PCBs for \$2 + 2 days Lead Time

Get quote online easily: https://jlcpcb.com/quote

The following two tabs change content below.

#### Ron Hoffman

Ron Hoffman is the President of Hoffman Electronics Inc. He is a veteran in the field of Electronics and Embedded Systems. Also honored and listed in “Who’s Who of American Inventors” 1996-1997;1998-1999 for patented inventions (see WEBsite http://www.RJHEINC.com/. Other than this he loves swimming, tennis, teaches guitar, and hiking. Read his articles in our site here.

#### Latest posts by Ron Hoffman (see all)

3 Followers

Most reacted comment
7 Comment authors
Recent comment authors
Subscribe
Notify of
Guest
ilium007

Hi – how does the circuit handle one PWM driver output feeding in to another ? I am thinking about the situation when a train goes from one segment being controlled by PWM driver #1 and the wheels cross over onto the tracks being controlled by PWM driver #2 ? This would effectively join the PWM outputs together and could cause shoot through / short to ground.

Guest
Brant

Hi Ron – I like the design ! Would it be possible to grab the PCB Gerber files ? Also, do you get any low frequency PWM motor noise ? I have contemplated building a circuit that uses 20kHz PWM to remove the high pitch motor winding noise. Cheers !

Guest
Ron Hoffman

Hi Brant. The Gerber files are available. The motor growls at very low speeds which actually sounds really cool. at 30% or more duty cycle, the motor noise is only like a motor on a DC supply. A 20 kHz PWM will act the same as a DC supply. The train will sit still and all of a sudden start moving. The 50 Hz rate, allows you to control the motor at very low speeds. Send me your e-mail address if you would like the Gerbers.

Guest
Maxi

Hi, very interesting circuit, a question … no protection against short circuits? Thank you

Guest
Ron Hoffman

The IRFZ44 can withstand 60 A. The transformer only puts out 3 A, and the fuse would blow if a short circuit lasts too long. Current limiting of the IRFZ44 would actually cause it to heat up more than having it on hard during the short.

Guest
MARTIN GRIMMETT

Guest
Ron Hoffman

you can send the gerber files to PCB 123 or Sunstone circuits and they will make you a circuit board. Send me your e-mail address and I will send the Gerber files to you.

Guest
Tom

Ron, I was wondering how much current the output stage can handle. I like to run more than one engine on a train and wondered if this would handle it. Also, I have several 5k one watt pots and was wondering if I could change the voltage divider of R6,R7 and R8 to accommodate a 5K pot.

Guest
Keith

Ron, I like the controller! I was wondering what diode D2 is. Is it the same as D4? Thanks!