# How to determine a car's direction of travel



## dbodnar (Jan 2, 2008)

Good day - at the ECLSTS a gentleman who attended my presentation asked if I could come up with a way to determine the direction of travel of a passenger car.

He had a USA Trains (I think!) observation car that had directional lighting. It worked properly when operated by standard track power but he was using constant track power with a radio control system so the lights never changed. The same issue would come up with DCC or battery operated trains.

He had installed with a mechanical solution but it created a great deal of drag on the wheels and was looking for a non-contact method of direction determination.

I was unable to come up with a circuit at that time but have given it a good bit of thought over the last few days and have a circuit that uses three magnets and a reed switch that does the trick!

While a rotary encoder would do the trick the 3 magnet / one reed switch solution seems simpler to me. It works with any Arduino and I plan on converting the code for the PICAXE.

I have documented how it works on my web page here:

http://www.trainelectronics.com/Articles/Wheel_CW-or-CCW/ 

I still have to do some additional testing and see if I can get it to work reliably with smaller scales (clear down to HO, perhaps). I thought it might be of interest to some of you who have similar issues with direction detection.

dave


----------



## Paul Burch (Jan 2, 2008)

Dave, good solution, but a caution on magnet location. As located it works fine in your test rig but on a layout they would probably foul on guard rails at turnouts.


----------



## dbodnar (Jan 2, 2008)

Right you are, Paul - I plan on testing the unit with much smaller magnets placed closer in on the wheel - if really small magnets are used they might be placed on the axle..... lots of options!

thanks

dave


----------



## toddalin (Jan 4, 2008)

You can simply drill a 1/4" diameter hole in the side of the wheel to mount the magnets. That is how I made the horse "gallop" within the hamster wheel. 










Here you can see where I doubled up on the magnets, but it wasn't necessary and I ended up removing one. One magnet sits flush within the plastic of the wheel. A metal wheel could also be used.


----------



## dbodnar (Jan 2, 2008)

You can also replace the reed switch with a hall sensor or just go with an IR sensor that reacts to lines painted on the inside of the wheel.... lots of options!

dave


----------



## Semper Vaporo (Jan 2, 2008)

Could you use a low Voltage relay from the wires to the motor through a diode? Relay is unenergized when going one way, and energized when going the other way. May need a Zener diode on the relay coil to limit the voltage when running fast (higher voltage).


----------



## dbodnar (Jan 2, 2008)

Semper Vaporo said:


> Could you use a low Voltage relay from the wires to the motor through a diode? Relay is unenergized when going one way, and energized when going the other way. May need a Zener diode on the relay coil to limit the voltage when running fast (higher voltage).


Absolutely, but that is not the way things are set up - we are trying to determine the direction of travel from a car at the back of the train with no electrical connection to the engine... thus the need for an independent sensor.

dave


----------

