I was working on this reply before Neil Robinson directed us in post #16 to Dave Bodnar's great work. But I'll post this anyhow. (It?s nice to know I was on the right track.)
Theoretically a big electrolytic capacitor will provide a buffer against loss of supply due to dirty track, or allow a soft stop feature when power is suddenly removed. But electrolytics are polarity sensitive so our usual arrangement where the track power changes polarity to change direction makes their use more difficult. (You can buy non-polarised electros but only up to around 1000uF ? they are used in loudspeaker crossover networks.)
This is my simplified circuit:
C1 & C2 are electrolytics, both the same capacity and a voltage rating greater than max track volts.
NOTE the connections of negative to negative ! (You can connect positive to positive if you like as long as the diode 'bar' is connected to the capacitor positive.)
But the capacitors have to be very large to provide the sort of 'buffering' we need ? in the range 100,000 to 500,000 uF
To theoretically determine the value of C1, C2
C (Farad) = 2 x motor current (A) x time to maintain supply (sec)
acceptable voltage drop in this time
This is a very approximate equation, as the interaction of the inductive motor as it slows, and capacitor is hard to predict. Also, electrolytics usually have more capacitance than their rated value to allow for manufacturing tolerances. I?m sure it will always result in a calculated bigger capacitor than is really needed, by a factor between 2 and 4 ! I?d suggest you could leave out the factor of ?2? in the eqn above.
Example1: to allow a ?soft stop? from 12V in 2 seconds, motor taking 1 amp,
C =2 x 1 x 2s / 12V = 330,000 uF approximately!!!! (by test I needed only 100,000uF)
Example2: to allow loco to cross an insulated frog, taking 0.1 sec and only allow a 1V drop, at 1 amp
C = 2 x 1 x 0.1s/1V = 200,000 uF
I did some tests with two, 4700uF caps (the biggest I had) running a motor block with its wheels in the air taking only 140mA. When I removed power it took 0.9 sec for the voltage to reach zero, and the voltage fall was very linear (theoretically it should be more exponential) ? see pic here (which I have fudged to make it legible. The blueish line is the motor voltage). The motor would have stopped in less time probably when the volts got down to around 2 or 3V.
It is possible to buy reasonable size capacitors of this rating these days, ? see here.
http://www.hobbyking.com/hobbyking/store/__17098__Turnigy_Voltage_Protector_550000uf_1_4sec_.html
It?s 550,000 uF, size26x26x45mm and costs around $6 - you need two for the above cct.
But it's only good for a max 15V. It seems to be made up from six, 3.3Farad, 2.5V capacitors in series (C=3.3/6=0.55F)
How's the circuit work?
Say the top wire from the wheels is positive. C1 will charge via D2 to track voltage. C2 will have only minus 0.6V so it is not damaged by reverse voltage. If incoming supply from the rails is lost, C1 will
start to discharge through the motor (keeping it powering) and will start to charge C2. The current will slowly decay as the C1 capacitor charge is reduced. After a time set by the amount of motor current and the size of the capacitors, both C1 and C2 will have
half the original volts across them, but with the polarity shown by the + signs. This means there is no volts across the motor.
If track voltage is now restored, the motor will instantly have full track volts. C1 & C2 will have a large current through them until C1 is fully charged to track voltage and C2 is fully discharged.
The time taken to charge/discharge when supply is applied/restored is determined by the capacitance and the supply resistance which is quite low (maybe one to a couple of ohms) so the capacitors could carry maybe 10-20 amps for a tenth of a second.
Dave Bodnar recommends a resistor and led across each capacitor to discharge it when supply is removed. I wouldn't bother with the led, but maybe a couple of 1k resistors are worthwhile if you have the room.
Actually the energy stored in the capacitors is not all that large comparatively. In a 100,000uF charged to 15V it is just ½ x 0.1 x 15^2 = 11 joules whereas the energy in a single 2Ah, NiMH cell is 2Ah x 1.3V = 2.6 Watthours = 9360 joules.
(Although high voltage capacitors are dangerous ? I have personal experience of getting across a cap charged to 300V at work. I remember watching others initially laughing as I danced around, not being able to let go, and then rushing to my aid.)