Controlling a dc model train layout via arduino

Hello fellow arduinoites,

I am building a lengthy n scale model rail layout. The width of the layout calls for a wireless controller. My arduino literate friend said that making an interface to control speed (voltage) and direction (polarity) would be very easy for him so I could use my iPhone to control the little dc engines on my layout. The problem he has is the electrical side of how a power supply would exactly be used or controlled via arduino.

Basically the track plan is split into blocks, each block is turned on at a control panel with spst switches to send power to the selects blocks. I have an mrc dual throttle desktop controller that offers up to 12v dc. I need to look at the current specs.

There are radio controlled systems that are fairly expensive so I thought a homebrew solution may be nice and a fun project.

So I ask of you, how would one go about trying to get a regulated power source to a train layout via arduino? The radio systems generally have a pulse width modulation control (I am unsure really what this means and am trying to learn on the Internet).

Maybe someone has done something similar in controlling little dc motors?

I searched this forum and thought I found something similar but I didn't really see the final solution to the gentlemans problems.

Thank you,

Mike

Pulse Width Modulation is a system in which the current is turned off and on several hundred or several thousand times per second. The width of the pulses is varied so, for example if the off period is much longer than the on period the average power seen by the electric motor is low and if the on period is much longer the average power is high.

The Arduino has a special command analogWrite(nnn) to produce a PWM output. NNN can vary between 0 and 255 with 255 corresponding to full ON.

The Arduino cannot supply the amount of power an electric motor needs so you need something like an L298 driver chip to allow the Arduino to control the high current. The L298 also has the ability to reverse the current to make the train move backwards. A single Arduino could create 6 PWM outputs (for 6 trains) but you need an L298 for each train.

You could get the Arduino to control relays to carry out the section selection that is done with the switches

...R

If you are using a PWM signal then any Radio Control Electronic Speed Controller will (ESC) do the job for you.

They are used in RC cars and quad copters to control the speed and direction of motors based on a radio transmitted PWM signal

You can if you want to use an Arduino, but why ? when it has already been invented.

something like this perhaps http://www.ebay.co.uk/itm/261414605285

Cheers Pete.

Bainesbunch:
If you are using a PWM signal then any Radio Control Electronic Speed Controller will (ESC) do the job for you.

I suspect you are confusing the signal used to control servos and ESCs (which is produced using the Arduino servo library) with the use of PWM to vary the power to an electic motor (which is produced using the Arduino analogWrite() command).

...R

Robin2:
Pulse Width Modulation is a system in which the current is turned off and on several hundred or several thousand times per second. The width of the pulses is varied so, for example if the off period is much longer than the on period the average power seen by the electric motor is low and if the on period is much longer the average power is high.

The Arduino has a special command analogWrite(nnn) to produce a PWM output. NNN can vary between 0 and 255 with 255 corresponding to full ON.

The Arduino cannot supply the amount of power an electric motor needs so you need something like an L298 driver chip to allow the Arduino to control the high current. The L298 also has the ability to reverse the current to make the train move backwards. A single Arduino could create 6 PWM outputs (for 6 trains) but you need an L298 for each train.

You could get the Arduino to control relays to carry out the section selection that is done with the switches

Everything Robin2 wrote plus...
There are ready-made motor shields, which plug straight onto an Arduino, that can control up to four trains.
Not only can you use an Arduino to switch the power to the sections, you can also use it to control point [switch] motors, signals and for train detection.

FYI,
What Robin said about controlling the servos .. that's called PPM (Pulse-Position- Modulation)

with a pulse width of about 900 to 2000 uS.
PWM (AKA analogWrite) is a completely different animal:

raschemmel:
What Robin said about controlling the servos .. that's called PPM (Pulse-Position- Modulation)

Some people call it that, mainly to try to avoid confusion with the Arduino PWM analog output, but it's not a particularly accurate name. The servo control signal is a form of pulse width modulation, just not the same form that analogWrite() produces.