Story: I have a lego train that is modded to run off of a 9v train track rail system that was a control function of 0 to 9 volts when fully on. LEGO does not make the motors that can run on these rails ( such as a regular model train does) and thus have made use of a trickle charge system that has a bridge rectifier and uses the circuit that is included in the LEGO LiPo battery pack that controls the charge time,rate,etc...

Here is a picture of what I have going on.

The system consist of ac wall wart that breaks the voltage down to 9 volts thus is controlled by a voltage control (0 to 9 volts) to metal rails. Train engine has motors that will take the 9v dc power which are powered through the trickle charge setup through the LiPo battery.

Question: How to I come up with a circuit, diode, etc to switch from this 9v dc power to the LiPo battery in a time of power loss?

Is there a better way to do this whole system as a whole, if needed I supply the needed info such as pics, measurements, etc...

Also so sorry that this is a drawn out story/question(s)

  • 1
    \$\begingroup\$ Sounds like you're looking for almost the same thing as I am, except you need a boost regulator with the ability to shut off when the supply is live. \$\endgroup\$ Aug 22 '13 at 1:08
  • \$\begingroup\$ @IgnacioVazquez-Abrams, I think you're right, this seems duplicate, although it was just posted 3 hours after yours. Your question is much more clear though. \$\endgroup\$ Aug 22 '13 at 5:19
  • \$\begingroup\$ @Poe, could you try to draw a schematic for your setup? It would help a lot in clearing up your question. There is a schematic drawing tool above the text box when you are editing the question. \$\endgroup\$ Aug 22 '13 at 5:24

The LEGO LiPo battery is rated for 7.4 Volts, I believe. Thus, a single diode would be enough to switch between the 9 Volt rail supply and the LiPO when the rail voltage fails or falls below 7.4 Volts.

Note: If the speed control is DC instead of DCC, then in any case when you set the throttle to slow, the rail voltage will drop below LiPo voltage. This means that below a certain speed setting at the throttle, the loco will continue to run at the speed defined by the LiPo, and will not drop lower - instead, the rail supply will simply not be used until the throttle is turned up again.

This following schematic addresses cases where the rail voltage does not drop below the LiPo voltage.


simulate this circuit – Schematic created using CircuitLab

Why this works:

  • When the rail supply from the wall wart is on, the cathode of D1 is at a higher voltage (~8.3V) than the anode (7.4 Volts) - at least until the throttle reduces speed, assuming DC control. Hence D1 acts as an open circuit.
  • When the rail voltage is set below the LiPo voltage, or off, D1 conducts in the forward direction, supplying ~6.7 Volts to the voltage controller. D2 becomes open, preventing voltage to the wall-wart from the LiPo.
  • Of course, this is not satisfactory if prototypical scale-speed slow running is desired.

If the 0.7 Volt diode drops are unacceptable, use a high current Schottky diode such as the Vishay 95SQ015 instead: 0.25 Volt drop at up to 9 Amperes.

If the intent is to continue using rail voltage and DC speed control until the rails actually are supplying practically no voltage (say down to 2-3 Volts or so), and then switch over to LiPo power, that too can be done - but the loco would then speed up to a fixed speed as determined by the LiPo's supply, until rail voltage came back up to the chosen threshold value.

To achieve this, a Schmitt Trigger takes the voltage from the rails as input, while its supply voltage is from the LiPo cell. The output is used to drive a switching solution, such as a MOSFET, to switch between rail supply and LiPo supply for the motor. The supply would come from the rail until the rail voltage drops below the Schmitt Trigger's threshold voltage that you preset. If this is the solution you are looking for, a schematic can be added if desired.

Edit: Added schematic.

A simple schematic for achieving the objective described in OP's comments:


simulate this circuit

Note that both the LiPo battery positive voltage rail, and the LiPo battery motor output rail, are used in the schematic.

  • The rail voltage supplies the motor as long as it is over 0.65 Volts or so, and the P channel MOSFET remains off, so the LiPo supply to the motor is blocked.
  • Once the rail voltage drops below around 0.65 Volts, the MOSFET switches on, and the motor is then supplied from the LiPo's motor output line - adjust that output to provide a very slow motor speed, else there will be an abrupt increase in speed the moment the external supply via the rails stops or drops below 0.65 Volts.
  • To reduce or eliminate any switching back and forth at the threshold voltage, play with the C1 capacitor's value. In the experimental circuit I've put together, I find that value to give stable switch-over, but YMMV.

Alternatively, more complex logic circuitry needs to be added on board the loco, to distinguish between crawling speed as determined by the controller, and no-power-on-rails, and to lock the no-power voltage from the LiPo to a defined value (i.e. a predecided speed). This however is a pretty strong case for DCC instead of DC. If you are already on DCC, then it's no big deal.

  • \$\begingroup\$ I think the problem here is that the "To Voltage Controller" node also is used to power the LiPo charging circuit. So when the external supply is disconnected, the battery tries to charge itself! The original question was not totally clear on this though... \$\endgroup\$ Aug 22 '13 at 5:16
  • \$\begingroup\$ Yes, the LiPo charging circuit is drawing power through the metal rails, thus when there is no power the Train needs to switch over to the battery for power. \$\endgroup\$
    – Poe
    Aug 22 '13 at 21:25
  • \$\begingroup\$ @Poe, if that's the case, you may already find yout answer here electronics.stackexchange.com/questions/79697/…. If that doesn't answer it, you will have to explain your question in much more detail. Otherwise, we don't know how to help you. \$\endgroup\$ Aug 23 '13 at 6:27
  • \$\begingroup\$ Ok guys thank you for the info, I will get back to you on Sunday with more info and a drawing as needed. I will also look at the link to see if its what I am after... \$\endgroup\$
    – Poe
    Aug 24 '13 at 7:49
  • \$\begingroup\$ Ok, Sorry for the lapse of time I said I would get back to this. Crazy one day off and then back to work I go. Ok I have a dumbed down drawing of what I have going on for a layout. I am not sure if its the greatest setup or if there is better with the help from the more understanding among here. I think that I would rather have the motors feed right off of the power pick up and have the battery kick in when there no power to have, though if it could pick up with no interuption so that the train doesn't have to be reset with the remote, that would be great. \$\endgroup\$
    – Poe
    Aug 26 '13 at 22:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.