The ideas below describe what I've come up with in the last couple of months. Please let me know if you've seen them elsewhere.

DCC loco position detector

Many of the proposals I've seen on the web about loco position detection seem to be universally applicable in that they'll work for cars too. I propose something which is utilising the unique feature of railroads: sleepers at regular intervals.

Placing a pair of infrared leds (emitter-receiver) on an engine makes it possible for such an engine to detect when a sleeper is passing underneath, under the assuption that sleepers are rather different in the colour from a layout. For instance, sleepers seem to be often black and a layout is generally not :)

Placing three leds (two emitters/receiver or one transmitter/two receivers) could make it possible to detect the direction of train movement. Although DCC engines know which way they are going, I suspect that under certain conditions a train may actually slip in a direction opposite to what an engine thinks it is going. For example, if a heavy train takes a steep hill, it may have enough kinetic energy to get some way up at which point it will stop with loco's wheels slipping and may slide down. Not sure whether one should plan for such an eventuality but Rapid's led pricing (15p+VAT/pair for 100pairs or so as I recall) seems to permit over-engineering.

A current feedback from a loco can be used to send the location back to a controller.

Ideas on improvement of BC1a power supply

Current sensing

The BC1a power supply uses a pair of 0.33 ohm resistors as a current sensor to detect an overload condition so that a PIC can take an action. Two potentially less than desirable things about such as sensor are: Borrowing an idea from PC motherboard voltage regulators (output voltage 1.6v, current 30A), current sensing can be based on the fact that when used as switches, MOSFETs act as resistors with the resistance slightly dependent on the current through them. In the context of BC1a, measurement of the voltage on the track rail closest to the ground can provide an indication of the current through the lower (Q8/Q9) MOSFET and thus the current through whatever is there on the track. According to the MTP3055 datasheet,page 3, this resistance is around 0.095 Ohm for the range of currents between 3 and 6 Amp and gate-source voltage of 15v. I believe the resistance will be similar for lower currents. Consequently, for the 0-6Amp load the voltage on the lower track rail will be between 0 and 0.6V.

Current measuring

With both the resistor-based and the MOSFET-based current sensing, we get a small voltage close to the ground. Typical electronics does not like either - PIC16F87X datasheet claims that reference voltage has to be at least 2V for the 10bit accuracy to be achieved (page 170); PIC18FXX2 datasheet states that this has to be 3V min (page 287). I interpret this such that unless we amplify 0.6V to at least 3V, the accuracy of A/D conversion will be reduced. This will in turn limit the achievable current feedback from the locos; even if we do not need all the 10 bit, reduction of the accuracy can be used to speed-up the conversion process. The task is thus to amplify 0..0.6 V to some uu ... uu+3V in a reasonably linear way under constraints of BC1a such as absence of a negative power supply and uu+3V having to be under 5V (for the PIC).

Proposed solution for the MOSFET-based current sensor:

The amplifier is a common-base one which is consequently non-inverting. I had trouble getting a `conventional' common-emitter amplifier perform as well as I wanted under the given constraints.

Rail 1 and rail 2 are connections to the two rails. The way they are connected, rail2 has 12V and rail1 is near the ground and voltage on it is consequently used to sense the current. If resistor-based current sensing is used, a single diode will do or otherwise resistor values will need changing.

Please note that both transistors above are Q2N3904 because BC547 is not available in the `student' version of the PSPICE. The result of the simulation is shown below, with colour curves showing voltages at points with similar-coloured probes. The current-sense voltage is on the horizontal axis (also shown in green) and the yellow curve is the output to the PIC.

I've prototyped the above (without the emitter-repeater) on a bread-board with BC547 and the it performed rather similarly to the result of the simulation, altough was slightly less linear. The signal generator was my PC sound card.

Specific things to note:

Current limiter

This is at present no more than an idea, but I think it could be useful, particularly if one decides to replace LM338 with something simpler. The paragraph below describes why this may be considered and the one after that outlines the idea.

From the MOSFET datasheets it appears that at 5Amp we are losing about 2.5 volts on them, plus 1.6V in decoder diodes, perhaps 0.5V on a track and 0.5V in decoder MOSFETs. If one would like to run an engine at 12V, the voltage applied to BC1a's MOSFETs has to be 17V. This means a voltage stabiliser only has 3V room (20V coming from the bridge rectifier and 17V output) which is not a lot, potentially prompting usage of a different stabiliser, which may not include over-current protection.

Generally-speaking, MOSFETs are programmable current sources. This means that the voltage on a gate can be used to limit the output current. In the context of BC1a, the lower MOSFET (Q8/Q9) could be connected as described in the BC1a shematics but the upper one (Q6/Q7) be used to limit the current through track rails as needed. The output current sensor using `lower rail' and the common-base amplifier could have its output connected to the gate of an `upper' MOSFET. As the current through the lower MOSFET goes up, so does the amplifier output, bringing the gate of the upper MOSFET closer to the 15V power supply and thus limiting the output current. An obvious disadvantage is having to ensure that 0.6V sensed from the lower rail translates into the appropriate voltage for the MOSFET, with all the spread of parameters.


me (replace _ in the email address with @)
Last modified: Sun Feb 9 22:13:44 GMT 2003