Magnetic Speed Control of Trains

by MikeTheMaker in Circuits > Arduino

4851 Views, 14 Favorites, 0 Comments

Magnetic Speed Control of Trains

magnetic sensor - 10.jpg

For "Santa's Shop," an animated Christmas display window (https://www.instructables.com/id/The-Story-Santas-Shop-2016/) getting multiple trains to start and run (not too slow and not too fast) is complicated by the fact that everything must start, run and stop at night (controlled only by a master on/off timer switch). The business (not mine) allows use of their window, but I can only access it during business hours--and not make too much noise or disturbance then.

Using two hall effect sensors (and a magnet on the train), an Arduino can sense speed and adjust the voltage up or down to stay in a desirable range. If the train is "stuck" (dirty track, rollers--train needs oil), the Arduino can sense this (no sensor activity for 15 seconds) and give a full voltage start up jolt for one second, while gradually increasing the base voltage to get it running until I can get in to service the system.

I used a 3d printer to create the brackets that hold the hall effect sensors.

Supplies

PARTS:

Arduino Uno

Two Hall Effect Sensors

Motor Speed Controller

16 volt dc power supply

USB power supply and cable

Breadboard

Wire

Heat shrink tubing

Solder

Magnet

Wood screws

Four 3mm screws (6 mm long)

magnetic sensor - 1.jpg
magnetic sensor - 2.jpg

I secured the hall effect sensors using 3mm screws (6 mm long).

magnetic sensor - 3.jpg

I spliced extra wire to the sensors so that they would reach the Arduino (which is ultimately one layer down beneath the trains).

magnetic sensor - 4.jpg

The sensor bracket is fastened to the wood base using wood screws.

magnetic sensor - 5.jpg

The sensors are placed nine inches apart.

magnetic sensor - 6.jpg

The hall effect sensor will only react to one pole of the magnet--if the magnet is turned the wrong way, it will never be detected.

magnetic sensor - 7.jpg
magnetic sensor - 8.jpg

With the magnet I am using, the sensor will detect proximity within about 3/4 inch or less. Results will vary depending on the strength of the magnet.

magnetic sensor - 9.jpg
schematic27012020.jpg

Wire the assembly according to this schematic.

software logic27012020_1.jpg
software logic27012020_2.jpg

Although it seems like a simple enough task to "get the train rolling and maintain speed," I had to consider that the train (on startup and during running) could be anywhere and moving or not moving. At any time, the train could change speed or stop moving.

The train engines (about 95 years old) are colorful and fun to watch, but their performance is not entirely predictable--this system should keep them running with a decent level of reliability.

Downloads