Ttrying to build a Model Rail Point-to-Point Speedo

Hi guys, I'm very new to Arduino and have managed to play around with most of the basic projects that I have found online. I do not have the skills to figure out exactly what I need to do to create a completely new design.

I wish to make a Point-to-Point speedo for my model railway (N-Scale) that will measure the speed over a given distance.

What I am asking here is for someone to either point me in the right direction or someone who has the time/ability to help me design this speedo. I have searched all over the net but cannot find anything that can help me out.

My preferred design would have an IR detector on one side of the track and an LED on the other. This would be the trigger that would start the timer counting once a locomotive breaks the beam.

This would be duplicated further down the track to stop the timer counting (I believe this distance is crucial to the correct calculations), do some calculations and then display the speed in KMH or MPH (Switch selectable) on a 2 line LCD.

The resultant speed would be displayed for a period of X seconds where the whole thing would then reset awaiting the next occurrence of a beam break.

The design would need to be bi-directional so that a loco could pass either detector and trigger the timer.

It would also need to have a lockout for the first detector so that it would not detect anything else till the second detector is clear of the loco and all its carriages.

If anyone is willing to give this project a go, and maybe help a dummy learn more about this wonderful technology, please don't hesitate in letting me know. You never know, I may even be able to give something back to this forum one day when I have learnt enough.

Cheers,

Sugar

If anyone is willing to give this project a go, and maybe help a dummy learn more about this wonderful technology, please don't hesitate in letting me know. You never know, I may even be able to give something back to this forum one day when I have learnt enough.

What part do you need help with?

Think about how YOU would perform the speedo task. You'd simply note what time the train passed a sensor. When the train passes sensor A, record time A. When the train passes sensor B, record time B. If you have both time A and time B, compute the speed. Set time A and time B back to 0. After some period of time, clear the display.

The bi-directional issue is easy. The absolute value of the time difference is important, not the actual value.

The lockout is a little more challenging. I presume that what you mean is that you don't want each set of wheels on the engine or a car it is pulling to reset the time for a given sensor. That can be dealt with in several ways. You could, before resetting the time, see if the time for the other sensor is known (that is, the train has already passed the other sensor). If so, compute the speed and reset both times. If not, you'd need to test how long it has been since the last trigger. A short duration means that the trigger was another set of wheels on the same train.

An alternative to the IR sensor, that avoids the lockout issue, is a magnetic sensor and magnet on the train. Perhaps the motor alone would be sufficient.

PaulS:
An alternative to the IR sensor, that avoids the lockout issue, is a magnetic sensor and magnet on the train. Perhaps the motor alone would be sufficient.

The magnet(s) in model railway motors are not powerful enough to close a magnetic reed switch set below track level. I've never tried with a Hall Effect switch.

If the motor in an N gauge train is not enough to close the switch then add a magnet to one of the carriages.

You could also look at using light dependant resistors and spot the change as the train puts them in the shade.

PS If you can sense a train passing a given point then you have a start on an automatic signalling system for you layout. Of course you don't what the sensors to be to obvious.

Mark

You can also put reflective tape under the loco and bounce the IR off that.


Rob

Graynomad:
You can also put reflective tape under the loco and bounce the IR off that.


Rob

I want to do something similar. I'm trying to bounce IR off a piece of paper/card printed with black and white bars (homemade barcode with each bar 2 - 3mm wide). So far, the card I'm using isn't reflective enough to give a reading. I'm thinking of trying glossy photo paper next.

Does IR respond to the black and white the same as visual light?


Rob

Graynomad:
Does IR respond to the black and white the same as visual light?


Rob

Yes, if I can get enough IR reflected! Because I'm trying to read a small area, my 3mm IR phototransistor is in a 3mm inside dia 20mm long brass tube. It works fine if I hold a mirror, to reflect the IR, over the end of the tube (that's how I check it's working) and detects black laser printed blocks on white card in a less restricted setting. I've now tried using gloss photopaper, but that didn't work any better. To try to increase sensitivity, I've increased the pulldown resistor on the emitter from 10k to 20k. It did help a little, but not enough. Looks like I'll have to amplify the output with a transistor unless anyone has any other ideas. Shortening the tube is one way I've thought of, but as the tube is set in 18mm thick timber, it'll make fixing it in place difficult.

unless anyone has any other ideas.

Comparator?


Rob

Henry, I'm very interested in this, also for model trains. I'm guessing your barcodes are intended to identify the trains.

How are you planning to organize the logic of the Arduino that will do the reading? For example will it react to interrupts or do you plan to do polling? How many sensor locations are you thinking of? How many trains will be moving on your layout at the same time?

I had been toying with a sort-of similar idea recently (I never got round to testing anything) and I had more-or-less given up the idea of reading the IDs from trains in favour of detecting position with LDRs and inferring the train IDs from a knowledge of which train ought to be at that location.

...R

RFID? Should work.

Robin2:
Henry, I'm very interested in this, also for model trains. I'm guessing your barcodes are intended to identify the trains.

How are you planning to organize the logic of the Arduino that will do the reading? For example will it react to interrupts or do you plan to do polling? How many sensor locations are you thinking of? How many trains will be moving on your layout at the same time?

I had been toying with a sort-of similar idea recently (I never got round to testing anything) and I had more-or-less given up the idea of reading the IDs from trains in favour of detecting position with LDRs and inferring the train IDs from a knowledge of which train ought to be at that location.

...R

I'm thinking of building an automated hump shunting yard, so the barcodes will be used to identify individual wagons and there will only be one sensor location. There's not much space, even in OO, under a wagon. The barcodes will, hopefully, consist of a white (reflective) bar 4mm wide, a black (non-reflective) bar 4mm wide, another 4mm of white followed by a 2 mm black bar as the 'start' signal. The code will be 5 * 2mm bars of either black or white. As I don't know the speed of the wagons over the hump (it will obviously be dead slow, but exactly how fast is that?) the reading of each of the first three start bars will be timed and then averaged to calculate the correct time to read the following code bars. The fourth, black, start bar is there merely to indicte the end of the third, timed, white start bar.

I can laser print the barcodes from photoshop, so they will be fairly accurate. My problem, as above, is reflectivity.

I've written a draft sketch (and it compiles :)) but obviously not yet tested it.

There's no reason why this method, if it works, couldn't be used to identify whole trains. In fact, carriages have a larger area underneath for the bar codes.

Have you thought about using magnetic reed switches to detect trains? They can also be used to differenciate between a small number of trains by arranging them as AND logic switches.

Graynomad:

unless anyone has any other ideas.

Comparator?


Rob

Do you mean using an op-amp?

Do you mean using an op-amp?

A proper comparator but they are essentially the same thing and an opamp would work as well I think.

The voltage from the sensor must be modulating to some degree, just not enough for logic to read, with a comparator you should be able to set a threshold in the middle of the sensor's output range and get a full logic swing.


Rob