What can feedback in a railway throttle do for you?

What do I mean by feedback?

When a DC motor is running the voltage applied to it can be considered to be 'used' for two separate things: Overcoming back-EMF, and causing a current to flow. The back-EMF is a generated voltage caused by the motor windings moving in the magnetic field.

The back-EMF is proportional to the speed the motor is turning, the number of turns in the coils, and the magnetic field strength. As the number of turns wound on the motor can be considered fixed for a given motor (apart from the effects of commutation), and if we assume that the magnetic field strength is constant then the back-EMF is directly proportional to motor speed, which is directly proportional to train speed (ignoring wheel slip).

If we can measure this back-EMF then that value can be used to measure, or to control train speed. Thus back-EMF is the feedback signal used by a 'feedback throttle'.

How can I get feedback?

If you know the resistance of the motor, and can measure the current through it then the IR losses (current through the motor times resistance) can be calculated. The back-EMF is simply the difference between the IR losses and the applied voltage.

Whenever power is not applied to the motor, the back-EMF becomes a generated voltage - the motor turns into a generator. The generated voltage has the same amplitude as the back-EMF. If you interrupt the power momentarily then the generated voltage (and hence the back-EMF) can be measured.

If your throttle uses PWM (pulse width modulation) then the power is being switched on and off all the time. The generated voltage can be measured in any of the power interruptions. In the unlikely event that 100% power is applied then no interruptions exist, and so further measurements become impossible. In this instance it is normal to limit power to perhaps 99% to leave some scope for measuring feedback.

If your throttle uses unsmoothed DC then it naturally reduces close to zero 100 times a second (120 times in the U.S.) Feedback measurements can be made in these periods.

If your throttle uses smoothed (or even regulated) DC then some small (one millisecond or less) interruptions could be made to permit measurements to be taken. These interruptions do not have to be terribly frequent, even once a second is probably adequate.

If you are concerned about the effect that such interruptions could have on your motors then I ask how you manage to get absolutely perfect pickup from the loco wheels. All normal model railway locos lose pickup periodically from dirt on the wheels and track. Even locos with multi-wheel pickup will suffer some interruptions - take the case when one pickup is isolated by a plastic frog, another wheel is lifted by slight imperfections in the track and the other pickup goes over a small piece of grit or grime on te track. Such power interruptions (from dirty tracks) are only short and do not affect train speed, but are essentially the same as artificially introduced interruptions used for feedback measurement.

Feedback speed control

The most obvious use for the data collected from measuring back-EMF is to regulate speed. Several things affect a train's speed, including loading, gradient, curvature and temperature. We have all had slow moving trains stall on a gradient or a curve. Add feedback speed control and that disappears. As locos warm up during an operating sessions they run considerably faster. All of these effects can be a considerable problem if your trains are controlled automatically.

Integrating feedback

If back-EMF is integrated over time then a measure of distance is available. By integration I do not mean that fancy mathematics you probably didn't understand at school, and really cannot be bothered to understand now, but simply the arithmetic sum of all samples. This can be calculated using either digital or analogue techniques.

If, for some particular period of time, or distance along the track, all the feedback samples are added together then this is the integral of feedback.

Remember that the back-EMF (which feedback measures) is directly proportional to motor speed so if the train travels faster, the feedbck voltage is greater, and the train traverses a given distance in less time. Whatever speed the train travels at the integral over a given distance will be constant.

If, while a train is passing through a track section of known length, the integral is calculated, then a calibration constant for the train can be calculated:

      calibration-constant = integral / distance

The calibration constant is in units of integral per unit distance.

Distance can be measured in any convenient units. Inches, centimetres, sleepers, furlongs, whatever - just decide on your units and stick with it.

This value must be discovered (or stored) for each loco before the integral is used for other things. Each loco will have different calibration constants unless they use the same type of motor, gear ratios and wheel sizes.

Note that the integral, and the calibration constant will not be affected by the speed of the train. If the train runs twice as fast then the feedback signal will have exactly twice the amplitude and be collected for half the time, and so integral will be the same (for the same length of track it is calculated over).

Stopping the train

Lets suppose we want to stop a train automatically (the mark-one eyeball might be occupied for more important duties such as watching spectators of the opposite sex at an exhibition).

Many ways exist to do this:

Cut the track where the back of the loco should stop.

Fit an infrared sensor, or reed relay, or LDR where the front of the train should stop.

Unfortunately none of these mechanisms are very good for stopping a train centrally in a station (unless all your trains are the same length).

If you know the distance from the start of the section to the centre of the platform (a tape measure might suffice as this tends to be a relatively constant value) and if you also know the length of the train then you can calculate how far the train should travel before it stops.

We can then calculate the value the integral will have when the loco is in that position:

      target-integral = calibration-constant * loco-stop-distance

All that is required now, is to slow the train down as the integral approaches target-integral. This is stopping the train by dead-reckoning.

This slowing and stopping could be done in many ways:

Manually: If feedback integral is displayed on your control panel then you can slow and stop the train even if you cannot see it. Useful perhaps in hidden sidings, or larger layouts.

By computer: If you have computer controlled throttles that measure feedback and report this value (or the integral) to the computer then the computer could be programmed to stop the train for you.

By the throttle: If your throttle measures feedback and calculates the integral then you could tell it where to stop the train, and let it do the job while you concentrate on other things.

In a DCC decoder: A DCC decoder is just a throttle in the loco, so it can measure feedback (probably even better than a DC throttle could). Add a CV telling the decoder where to stop the train and let it take over that station stop.

Measuring train length

Train length is a useful value. It can be used to stop a train centrally at a station platform, or it might be used to decide whether a train might fit into a siding.

If we have an optical sensor somewhere in the layout, then the amount that the integral increases while the train passes that sensor gives us the train length from:

      train-length = (end-integral - start-integral) / calibration-constant

Finding where the loco is in a train

It might be useful to know how much train there is in front of the first pickup. This might modify the calculation of where to stop the train centrally at a station, or stopping trains at the end of a siding.

A current detector will trigger when the loco enters a section. More accurately it will trigger when the first item of rolling stock that draws current enters the section. If there is an optical sensor at a known distance from the track-break (and is further away than the unpowered front of the train) then we can deduce the length of that unpowered head:

      travelled-distance = (integral-at-optical - integral at pickup) / calibration-constant

      unpowered-head = optical-sensor-distance - travelled-distance

Naturally we could do the same for the unpowered tail of the train.

Detecting wagons becoming uncoupled

If your layout uses several optical sensors, then the train length could be calculated as the train passes each and every sensor. If the train suddenly becomes shorter than it was, then there is a fair chance that one or more wagons have become detached.

Either an alarm could be raised, or perhaps the train could be stopped automatically to allow the problem to be fixed before a crash ensues.

Calibrating train speed

If we measure the time it takes the train to pass along a track of known length (perhaps at the same time we are deducing the calibration constant), we can measure the speed of the train. Note that the train must travel at a fairly constant speed for this calculation to be valid.

      sample-speed = distance / time

As the feedback voltage is proportional to train speed, and we know the train speed, we now know the relationship between feedback value and speed.


      speed-calibration-constant = sample-feedback-value / sample-speed


Monitoring train speed

The instantaneous speed of the train can now be deduced from the feedback value at that moment:

      speed = feedback-value / speed-calibration-constant

Observing speed limits

Naturally we can also deduce the feedback value that matches a given target speed. If a curve has a particular speed limit then a feedback throttle could be told to run the train at a feedback value to match that speed limit:

      feedback-value = speed-limit * speed-calibration-constant

Naturally the extents of such a speed limit do not have to align with track section breaks - the integral will tell you when to slow the train, and when it can speed up again.

Minimising the number of optical sensors required in an automatic layout

Once we can stop trains by dead-reckoning, we no longer need many optical (or other position oriented) sensors to allow us to manage the trains accurately. As we know the length of each train we can decide if they can fit in the current track section. If the train needs to stop and it fits, then once it has travelled far enough we know that the previous section is clear. If not then we keep the previous section marked in-use for as long as our train remains stopped.

How well does this work in practice?

My QTU calculates feedback integral and I have used it to repeatedly stop a train each time around a loop. Repeatability is quite fair - within an inch or so on my test track.

The only drawback I have noticed thus far is that when a loco is crawling very slowly the feedback value is difficult to measure as it is so small. Thus a train running at dead-slow is not seen as moving. But for all normal speeds the integral is very constant over any given distance.

I have updated Tcc so it can read the integrals from a QTU, calculate the speed-calibration-constant and train lengths. The QTU can also slow and stop the train at a specified integral value. I am in the process of updating my automatic script generator to drive trains by dead-reckoning and results so far are very encouraging. Now I plan to explore many of the possibilities discussed above, but given a reliable integral value everything else should work as all the relationships are simple mathematics. Reports on progress will be issued as time permits.

What do you need in order to use feedback integral?

Either a throttle that measures (and integrates) feedback, or a feedback monitoring unit added to a standard throttle.

The data produced by such a unit probably requires a computer or microcontroller (PIC or AVR) to coordinate the data as each loco needs its own calibration coefficient.

For DCC you need to modify your home-brew (or MERG kit) decoder. If the command station (or programming track) can then tell the decoder when the train has travelled a known distance the decoder can deduce the calibration-coefficient. Further messages can then tell the decoder to stop the train after a given distance.

What else can this information be used for?

These ramblings are merely my ideas to-date. If you can think of anything else that can be deduced from monitoring feedback and/or integrating the result, then please let me know and I'll update this document.