Model Rail Speed

Hi all, I wish to make what in simple terms is called a speedometer because in prototypical rail modelling speed restrictions are a necessity of both diagram [journey] timing and pure track safety. Modern railway circuits are powered as a constant 12-18Vac then converted within the engine to pwm., in order to alter the speed of the engine; direction of the locomotive is be internal current reversal. All these internal operations are carried out by a manufactured controller board, the system being known as DCC., which stands for Direct Cab Control ie., the remote controller controls the engine through this DCC., pcb. So that for those that didn't know is how a modern model 'engine' is controlled almost of whatever scale gauge. In the old days voltage at the rail would alter the speed of the loco., but would still not provide a speed recognition level as each engine would drive at a given speed using a different voltage, so there is no need to believe that this would or should be an criterion. Question: How can the speed be recognised in the most secretive of ways. ie., The occupation of a space could be recorded by magnetic reed contactor, inferred sensor, phototransistor, ldr etc., but I would like to do the recognition surreptitiously say by taking a signal feed off the rails and then configure that signal within an Arduino. This leaves the model railway looking prototypically correct. I have toyed with using the optoisolator as a recogniser, but can it be done using as a microcontroller say the ubiquitous 328 although I don't believe that is of any or much consequence? ChrisPSR

You must not have done much searching. There are several Forum threads about DCC and several regular contributors with an interest in model trains.

Am I correct to think you want to detect the train speed using ground-based detectors rather than by interpreting the DCC commands?

There are some commercially available train detection systems that integrate with DCC but I don’t know anything about them and I don’t know how you would create different sections in a DCC track withou interfering with the DCC system. In any case I thought DCC was meant to do away with track circuits.

I think a very simple detection system would be to embed Light Dependent Resistors (LDRs) into the ballast - some of them are very small - and use the Arduino to time the passage from one to another.

How many detectors do you need?

LDRs probably need to be “read” using the Arduino analog inputs and an Uno only has 6, compared with 18 digital I/O pins (assuming the analog pins are used as digital pins). An Arduino Mega has more of both - but mainly more digital pins. It should be simple enough to use a OPamps to convert the LDR outputs to drive the digital pins. But if you have to go to that much trouble it might be as easy to use photo transistors in the first place.

…R

Most of your answers were already pre-emptied in my request for help. You obviously do not understand prototypical nor model rail and in these instances it would be better if you left the subject alone. DCC., pcb's are very expensive; easily 'blown up' ask ANY user, often in difficult to get at locations; use minute components & are quite beyond the manipulation by most amateur electronics hobbyists and absolutely outside my sphere unless a diode spur is being thought of which I could accept end engineer.

The Atmel Atmega2650 is way over powerful and over out/input supplied. A PIC 12F509 is well able to handle that which is required. I can't envisage more that two inputs and one out.

Prototypical railways use much track circuiting; will use more and more as existing and futuristic driver occupied and driverless trains demand more and more on train remote recording and assistance. For instance: A driver attended engine can be brought to a stand now without the actions of a driver and all since 1924 to today. Model rail is trailing behind but desperately quickly catching up with electronic control.

The location objects you mentioned previously have been used for eons in model rail but used in what is now becoming known simply as analogue (analog in the states) electronics. I have been building successful analogue circuits for some considerable time.

As I said in onset I wish this circuit to be "secret" if not vaguely "surreptitious" and "prototypical".

Did you read the remit Mr/Ms ...R the author is a member: MMRS & MERG.

Hello ChrisPSR

I wish to make what in simple terms is called a speedometer because in prototypical rail modelling speed restrictions are a necessity of both diagram [journey] timing and pure track safety.

Are you seeking to measure continuously the speed of all locos on the layout wherever they are? Or just the speed of a loco as it passes a fixed measurement location?

What do you want to do with the measured speeds? How will it be displayed or processed?

And the locos will not be DCC, correct?

Regards

Ray

ChrisPSR: Most of your answers were already pre-emptied in my request for help. You obviously do not understand prototypical nor model rail and in these instances it would be better if you left the subject alone.

You might, then, be surprised to learn that Robin 2 has built radio controlled, battery locomotives in 'N' gauge. With your attitude, I'd be surprised if anyone else bothered to answer you.

ChrisPSR: Most of your answers were already pre-emptied in my request for help.

Pre-emptied?

An optical sensor from a mouse would work if you could figure out the optics needed to get the focal distance correct. Google “optical flow sensor” for leads.

ChrisPSR: Most of your answers were already pre-emptied in my request for help. You obviously do not understand prototypical nor model rail and in these instances it would be ibetter f you left the subject alone.

DCC., pcb's are very expensive; easily 'blown up' ask ANY user, often in difficult to get at locations; use minute components & are quite beyond the manipulation by most amateur electronics hobbyists and absolutely outside my sphere unless a diode spur is being thought of which I could accept end engineer.

Perhaps that makes two of us, then. My attempt at assistance was made in good faith and in a good humour.

You don't need to poke around in the DCC chips - the data that is sent to them can be picked up from the track and decoded by an Arduino (which I have already done). (After all, that's what the Locos do).

...R

Hi, I think ChrisPSR wants to build a SPEED TRAP, that is so that not even his fellow model railway operators know its there. Then he can be the big fat controller and tell thomas that he shouldn't be speeding. Possibly make it portable? You cannot monitor the DCC signals because each loco will have a different speed depending on motor gearing and load for a given throttle position. ChrisPSR, what scale? Tom....... :)

TomGeorge: You cannot monitor the DCC signals because each loco will have a different speed depending on motor gearing and load for a given throttle position.

I had assumed the OP wanted something for his own or his club's layout and would have access to the data for each loco. It would be simple to run each loco between points timed with a stopwatch and relate the measured speed to the DCC throttle setting.

If you want a portable system maybe you could build the equivalent of a police radar speed gun using a PING sensor?

...R

ChrisPSR: How can the speed be recognised in the most secretive of ways

It shouldn't be hard to put a speed sensor on the train itself, and I would have thought this was the obvious approach if you wanted the train to control its own speed accurately. I have no idea what DCC does but I'm sure by now somebody has thought of providing closed loop speed control and perhaps these DCC systems do it. If you want something separate from the train to just measure the speed at a single point, perhaps you could use a pair of LDRs under the track to detect when a train passes overhead and do a distance/time calculation.

Hackscribble: Hello ChrisPSR

I wish to make what in simple terms is called a speedometer because in prototypical rail modelling speed restrictions are a necessity of both diagram [journey] timing and pure track safety.

Are you seeking to measure continuously the speed of all locos on the layout wherever they are? Or just the speed of a loco as it passes a fixed measurement location?

What do you want to do with the measured speeds? How will it be displayed or processed?

And the locos will not be DCC, correct?

Regards

Ray

Hi Ray, and thanks for your interest. This question has I know got off to a bad start but it is of great interest to many and I sincerely hope that it can recover as it would be a shame not to reach a conclusion which I am sure is out there but as yet dormant.

To understand the problem it's fairly important to understand DCC., to some degree which you don't confirm or deny so I hope that I do not imply in this response that you should 'suck eggs', but to answer your queries and the other guy who quite correctly wrote "Insert Quote Hi, I think ChrisPSR wants to build a SPEED TRAP..................*/

So: The speed is to be measured over as short or longer distance as required with an accuracy of say + or - 10%. Remember, in 00 gauge as an instance, we are dealing with an object 1/76th of the prototypical size. The knowledge would be used primarily by the driver to comply mainly with 'trackside' instruction as on an incline or radius, and not provided as by a little Hitler but purely to imitate prototypical surveillance and safety. Maybe later it could be used to automatically slow or accelerate an engine/diesel-tractor but the first thing, I believe, is to be able to recognise the speed.

I understand DCC., but not fully. The messages are received through the rails/railway-lines to the engines motor by way of pwm., through a consistent uncontrolled 12 - 18volt 1500mA supply and I fancy that this could be a starter but various engines require different pwm., for the same speed so pwm., and so pwm., can not be solely utilised.

I have access to all MERG., knowledge both through personal contact and programs in use. This subject is not one on our current agenda unless passives in analogue electronics are to be the only consideration with uC's., doing the maths. There may not be any other way but at the moment I am not convinced of that. Does that help?

Cheers, Chris S Member: MMRS & MERG.

I understand DCC., but not fully. The messages are received through the rails/railway-lines to the engines motor by way of pwm., through a consistent uncontrolled 12 - 18volt 1500mA supply and I fancy that this could be a starter but various engines require different pwm., for the same speed so pwm., and so pwm., can not be solely utilised.

Could you use the DCC data and some calibration data in your code for each locomotive?

Thanks, Chris.

The knowledge would be used primarily by the driver to comply mainly with 'trackside' instruction as on an incline or radius,

So this not about a "test bed" speed measurement (which one might use to calibrate DCC commanded speed or old-fashioned control knob position). Rather, it is for permanent installation on a layout in a place where speed matters?

If so, then I think the suggestions of a pair of sensors (LDRs, photo-diodes) could be worth investigating. There are commercial products which measure speed with two sensors buried in the ballast a few inches apart. This is one of them:

http://www.trainspeed.com/products.htm

And there is at least one commercial onboard speedometer too. Can't find the link right now (always the way!) but it uses a special axle marked so its rotations can be read by an optical sensor, then a wireless pack to relay the information to a display. The idea is to build the wheelset into a dynamometer car which you attach to the train being measured.

Not suggesting you buy these, but they may give some ideas for your own project.

Regards

Ray

ChrisPSR: Maybe later it could be used to automatically slow or accelerate an engine/diesel-tractor but the first thing, I believe, is to be able to recognise the speed.

If you have any ambition at all in that direction then IMO it would make sense to look at an on-board speed sensing system which you could then incorporate into a closed loop speed control system to be built into the engine.

ChrisPSR: I understand DCC., but not fully. The messages are received through the rails/railway-lines to the engines motor by way of pwm., through a consistent uncontrolled 12 - 18volt 1500mA supply and I fancy that this could be a starter but various engines require different pwm., for the same speed so pwm., and so pwm., can not be solely utilised.

It seems to me there are two relatively simple options and everything else represents a degree of complexity that is unlikely to be justified by the requirement.

Simplest is to embed a couple of sensors in the ballast and use an Arduino to time trains as they pass over them.

And the other option (which I mentioned earlier) is to use an Arduino to decode the DCC instructions that are being sent to the loco. This requires some measurement for each loco and creating a performance table that maps the DCC speed instruction to the measured speed. It assumes a loco always runs at the same speed for a given DCC instruction and I suspect that is a reasonable assumption. Using the DCC instructions has the advantage that it can report the speed of any loco wherever it may be. If you want to go that road I can give you some code to get you started.

To avoid any confusion, while the motors in the locos are controlled with PWM the DCC controller sends "numbers" to the DCC chips in the locos and the DCC chips convert that number into an appropriate PWM signal.

...R

Hackscribble: Thanks, Chris.

The knowledge would be used primarily by the driver to comply mainly with 'trackside' instruction as on an incline or radius,

So this not about a "test bed" speed measurement (which one might use to calibrate DCC commanded speed or old-fashioned control knob position). Rather, it is for permanent installation on a layout in a place where speed matters?

If so, then I think the suggestions of a pair of sensors (LDRs, photo-diodes) could be worth investigating. There are commercial products which measure speed with two sensors buried in the ballast a few inches apart. This is one of them:

http://www.trainspeed.com/products.htm

And there is at least one commercial onboard speedometer too. Can't find the link right now (always the way!) but it uses a special axle marked so its rotations can be read by an optical sensor, then a wireless pack to relay the information to a display. The idea is to build the wheelset into a dynamometer car which you attach to the train being measured.

Not suggesting you buy these, but they may give some ideas for your own project.

Regards

Ray

Re: Model Rail Speed

« Reply #11 on: Today at 06:52:18 am » Bigger Bigger Smaller Smaller Reset Reset Reply with quoteQuote Modify messageModify Remove messageRemove

Quote from: Hackscribble on May 25, 2014, 01:10:39 pm

Hello ChrisPSR

Quote

I wish to make what in simple terms is called a speedometer because in prototypical rail modelling speed restrictions are a necessity of both diagram [journey] timing and pure track safety.

Are you seeking to measure continuously the speed of all locos on the layout wherever they are? Or just the speed of a loco as it passes a fixed measurement location?

What do you want to do with the measured speeds? How will it be displayed or processed?

And the locos will not be DCC, correct?

Regards

Ray

Hi Ray, and thanks for your interest. This question has I know got off to a bad start but it is of great interest to many and I sincerely hope that it can recover as it would be a shame not to reach a conclusion which I am sure is out there but as yet dormant.

To understand the problem it's fairly important to understand DCC., to some degree which you don't confirm or deny so I hope that I do not imply in this response that you should 'suck eggs', but to answer your queries and Georges who quite correctly wrote "Insert Quote Hi, I think ChrisPSR wants to build a SPEED TRAP..................*/

So: The speed is to be measured over as short or longer distance as required with an accuracy of say + or - 10%. Remember, in 00 gauge as an instance, we are dealing with an object 1/76th of the prototypical size. The knowledge would be used primarily by the driver to comply mainly with 'trackside' instruction as on an incline or radius, and not provided as by a little Hitler but purely to imitate prototypical surveillance and safety. Maybe later it could be used to automatically slow or accelerate an engine/diesel-tractor but the first thing, I believe, is to be able to recognise the speed.

I understand DCC., but not fully. The messages are received through the rails/railway-lines to the engines motor by way of pwm., through a consistent uncontrolled 12 - 18volt 1500mA+ supply and I fancy that this could be a starter but various engines require different pwm., for the same speed so pwm., can not, I feel, be solely utilised.

I have access to almost all MERG., knowledge both through personal contact and programs in use. This subject is not one, to the best of my knowledge, on current agenda although nothing is outside of individual stewardship unless passives in analogue electronics are to be the only consideration with uC's., doing the maths. There may not be any other way but at the moment I am not convinced of that. Does that help?

Cheers, Chris S Member: MMRS & MERG.

Some gremlin seems to have got his hands on Reply #16.

...R

Robin2:

ChrisPSR: I understand DCC., but not fully. The messages are received through the rails/railway-lines to the engines motor by way of pwm., through a consistent uncontrolled 12 - 18volt 1500mA supply and I fancy that this could be a starter but various engines require different pwm., for the same speed so pwm., and so pwm., can not be solely utilised.

It seems to me there are two relatively simple options and everything else represents a degree of complexity that is unlikely to be justified by the requirement.

Simplest is to embed a couple of sensors in the ballast and use an Arduino to time trains as they pass over them.

And the other option (which I mentioned earlier) is to use an Arduino to decode the DCC instructions that are being sent to the loco. This requires some measurement for each loco and creating a performance table that maps the DCC speed instruction to the measured speed. It assumes a loco always runs at the same speed for a given DCC instruction and I suspect that is a reasonable assumption. Using the DCC instructions has the advantage that it can report the speed of any loco wherever it may be. If you want to go that road I can give you some code to get you started.

To avoid any confusion, while the motors in the locos are controlled with PWM the DCC controller sends "numbers" to the DCC chips in the locos and the DCC chips convert that number into an appropriate PWM signal.

...R

If only DCC., & its pwm., worked that way then perhaps the query wouldn't arise. However mapping might be a way forward but linking the pwm., with a particular loco leads us right back into basic DCC., operation which is most certainly not for the faint hearted. Chris S.

Hi, I think we had better stop saying that DCC control is PWM, it isn't. It is Digital Data being sent over the power supply, a coded digital packet is put into the power supply unit. Each packet id is unique to each loco, that way they can control more than one loco on the same track at the same time. They have stop,start,direction, lights and other control over what is on board the train.

So DCC is not PWM. The decoder may control the motor by PWM in the loco.

Tom..... :)