# Arduino Forum

## Using Arduino => Project Guidance => Topic started by: devmin_a on Nov 15, 2017, 06:01 am

Title: Measuring speed/distance of model train set
Post by: devmin_a on Nov 15, 2017, 06:01 am
Hi I am working on an university project and my group is making an automated train control system. I am using a nRF24l01 module to establish a communication link between the train and train stations and I'm using RFID tags to get the ID of the next train station. I want to know if there is any way to get the distance between the train and the next station so that I can dynamically show the time it will take for the train to reach the station. Thank you!
Title: Re: Measuring speed/distance of model train set
Post by: Mdmassey on Nov 15, 2017, 06:21 am
You could use a system of IR leds and receivers placed an inch or so apart that are set to detect the train and measure the time between blocking the first sensor to the second. Then use the formula d/t=s, where t is time, d is distance and s is speed. Then if you know the distance to the next station it can be accurately calculated based on the initial speed recording. This is only accurate if the speed doesn't change from point a to b. Now if you want this to be more accurate you can use station 2 as the reference to station 3 and recalculate (maybe making the new distance a foot or so away) and so on down the line. This will cause the arrival estimates to change and adapt according to changes in train speed. This type of system was used by real railroads up to the use of GPS to relay speed and location data back to the CTC.
Title: Re: Measuring speed/distance of model train set
Post by: Robin2 on Nov 15, 2017, 09:31 am
You won't be able to determine the distance using wireless. On a real train you could use GPS but the distances on a model train would be too small for GPS to be useful.

Can you measure the speed of the train by measuring the speed of its motor?

I am building an 00 gauge model train using nRF24's for radio control and I have an optical detector that registers a pulse for every revolution of the motor. That is used for speed control and also I am hoping to be able to use the pulse count for reasonably accurate short term movements together with optical detectors under (or beside) the track for the larger distances.

...R
Title: Re: Measuring speed/distance of model train set
Post by: AWOL on Nov 15, 2017, 10:39 am
A small magnet glued to the underside of the loco, and some Hall effect switches in the track?
Title: Re: Measuring speed/distance of model train set
Post by: Robin2 on Nov 15, 2017, 10:42 am
A small magnet glued to the underside of the loco, and some Hall effect switches in the track?
If the position knowledge needs to be on the train then that may need to be reversed.

...R
Title: Re: Measuring speed/distance of model train set
Post by: ardly on Nov 15, 2017, 12:18 pm
Rather than measuring the velocity over a short distance I would use the Hall effect switches or IR sensors, that have been suggested by others, to determine when the train is entering or leaving key sections of track. That is probably how a train driver thinks e.g 'I  am at the tunnel 3 minutes ahead of normal'.

instead of having LEDs right at the track perhaps a single LED/Sensor pair in the scenery could monitor a train passing several points such as entering and then leaving a bend - that depends on track layout.

Another idea might be to have the train blow its whistle at key points e.g. entering tunnel, crossing bridge. If you could detect the whistle then you would know where the train was.