Battery, ESP8266 based Remote Control and Automation for an LGB 24140 KJF Loco

Michael

Registered
26 Jan 2010
139
16
Best answers
0
Country flag
At the beginnning of this year, I added some Binnie Hudson Tipper Wagons to my L&B themed railway. Tippers were used during it's construction and also in 1925 during the building of the Parracombe bypass. In both cases small industrial locos provided the power.

At the last Peterborough show, I saw and fell in love with this cute little LGB loco. I thought it would be suitable for the tippers and I've always wanted to own at least one LGB loco. It was secondhand but appeared not used, apart from various holes drilled in it. This included a huge chunk out the back, in what looks like a botched attempt to add battery operation from a trailing wagon.

lgb_kjf_1.JPG

Taking it to bits was relatively easy. All the space in the boiler was taken up by a large weight. There is a small PCB underneath at the back (along with a further small weight) which connects the track pickups to the motor via some suppression components.

lgb_kjf_3.JPGlgb_kjf_4.JPG
lgb_kjf_5.JPGlgb_kjf_6.JPG
Whilst the loco is small there are several places for the battery and electronics, underneath both at the front and back, in the boiler and in the coal bunker. It's main use is pulling and pushing 4-6 tippers up and down a separate section of track which lies within a loop at one end of my layout and automation is required so it can do this unattended.

I'm quiet hopeless on the building/mechanical side (for example, those tippers were a challenge!) so get my enjoyment from designing and building the electronics. The requirements were as follows:

Powered by an 18650 Lithium Battery
Integral charger powered from track
ESP8266 controlled
Reed switches for on and off to remove the need for an external on/off switch
Manual and Automatic operation
No visible electronics

A block diagram of the system:

lgb_kjf_2.jpg

The existing PCB mounted underneath at the front is replaced with a PCB containing the bridge rectifier and the 5v switching regulator required to charge the battery.

lgb_kjf_10.JPG

The smokebox section of the boiler contains a 18650 lithium battery and a TP4056 based protection/charger. This provides all the discharge / charge protection required for a single Li-Ion battery and has the advantage of requiring a simple 5 volt supply for charging. From the nominal 3.8 volts from the battery, two voltages are required, 3.3 volts for the processor and RFID reader and 12 volts for the motor drive.

lgb_kjf_8.JPG

A Pololu 12 volt step up regulator, 3.3 volt step down regulator, H-bridge motor controller and the on/off circuitry fit on a small PCB at the cab end of the boiler. On either side of this PCB are mounted the on/off reed switches. A red LED in the cab illuminates when the loco is switched on. The Wemos D1 mini, ESP8266 processor board fits (just!) in the coal bunker.

lgb_kjf_9.JPG

An ID-12LA RFID reader is fitted underneath at the back of the loco. It is smaller, has a built in antenna and is much more sensitive than the ones I've previously used.

Location detection using RFID - G Scale Central

This allows the use of 20mm diameter tags on the track rather than credit card sized ones.

lgb_kjf_11.JPG

I've glued a magnet to the end of a pencil for switching on and off. It can also be switched off via the remote control, after a fixed period of inactivity or when the battery voltage drops to a certain level. The current drain from the battery is very low in the off state so the loco can be left for a long period without recharging.

lgb_kjf_12.JPG

All fit nicely together and nothing visible. It has worked fine since mid summer. In keeping with the L&B naming tradition (a 3 lettered river in Devon), it is called Sig. Picture taken before the driver was added.

lgb_kjf_13.JPG

Michael
 
  • Like
Reactions: 1 user

Rhinochugger

Retired Oik
27 Oct 2009
36,715
4,240
North West Norfolk
Best answers
0
Country flag
That's a novel approach, and a neat installation to get all that into such a petite loco :clap::clap::clap:
 

dunnyrail

DOGS, Garden Railways, Steam Trains, Jive Dancing,
Staff member
GSC Moderator
25 Oct 2009
26,171
4,993
75
St.Neots Cambridgeshire UK
Best answers
0
Country flag
Have to say that I initially though that this was a request ‘how do I’, I think my answer may have been tricky at best. But you have done it with applomb. 10/10 for supreme effort.

The reed switch on/off is of great interest to me and I would guess others. Do you think you could amplify some about how this works and the specifics required In terms of parts and wiring. I would guess that somewhere there must be the equivalent of a latching relay?
 

Michael

Registered
26 Jan 2010
139
16
Best answers
0
Country flag
Thanks for the kind comments.

Jon, I normally use push buttons rather than toggle switches as I always forget to switch things off and hence flatten the battery. This is the first time I've used reed switches but the circuitry is the same.

It's all down to the Pololu buck regulators which I always use. They have an enable pin which is internally connected to Vin via a 100K resistor. If you leave this open circuit then the output is enabled but if you take it below 0.4 Volts the output is disabled.

Sig1.jpg

The 6K8 resistor (R1) holds the enable pin low and the regulator is disabled. Pressing the 'On' button will take the enable pin high and the regulator is enabled and the processor is powered. During the setup routine the output shown is set to a 'high', which keeps the voltage high on the enable pin so you can then release the button. You normally have to hold it down for 0.5 second. You can switch off either by pressing the 'Off' button or under processor control by setting the output to a 'low'.

Alternatively if you don't want to use an output from the processor then the Vout is connected to the enable input.

Sig2.jpg

The technique works with most Pololu regulators that have an enable input, though the resitor values are slightly different when you use for example a 4 cell battery pack. The diode is very important!
 

dunnyrail

DOGS, Garden Railways, Steam Trains, Jive Dancing,
Staff member
GSC Moderator
25 Oct 2009
26,171
4,993
75
St.Neots Cambridgeshire UK
Best answers
0
Country flag
Thanks for the kind comments.

Jon, I normally use push buttons rather than toggle switches as I always forget to switch things off and hence flatten the battery. This is the first time I've used reed switches but the circuitry is the same.

It's all down to the Pololu buck regulators which I always use. They have an enable pin which is internally connected to Vin via a 100K resistor. If you leave this open circuit then the output is enabled but if you take it below 0.4 Volts the output is disabled.

View attachment 259596

The 6K8 resistor (R1) holds the enable pin low and the regulator is disabled. Pressing the 'On' button will take the enable pin high and the regulator is enabled and the processor is powered. During the setup routine the output shown is set to a 'high', which keeps the voltage high on the enable pin so you can then release the button. You normally have to hold it down for 0.5 second. You can switch off either by pressing the 'Off' button or under processor control by setting the output to a 'low'.

Alternatively if you don't want to use an output from the processor then the Vout is connected to the enable input.

View attachment 259597

The technique works with most Pololu regulators that have an enable input, though the resitor values are slightly different when you use for example a 4 cell battery pack. The diode is very important!
Many thanks for the explanation, not sure that this helps me as the additional wiring to my 14v NiMh system using a Fosworks Controller would be usable or easy to fit into some of my small locomotives where I have had to shoehorn things in. But I am sure that some here would use this circuit.
 

Fred2179G

Registered
20 Apr 2017
1,059
186
USA
Best answers
0
Country flag
Michael,
Very interesting. Not being an electronics engineer, I embarked on a more conventional r/c fix for my loco using a trailing gondola.

20191116_173334_-lgb040-trailingcar.jpg


Large Scale Central - Advanced Forum Detail Topic - LGB 20140 Sound and battery install

All the loco wiring is now complete, including the speaker in the loco coal bunker, and the ESC and sound card just arrived.
 

Michael

Registered
26 Jan 2010
139
16
Best answers
0
Country flag

I'm not a member there but have been following your thread. Thanks for adding the link here as it shows a more typical method of running this loco on batteries. Looking forward to the next installment.

Interesting to see that the 24140 I bought in March has been re-issued this year by LGB as model number 24141. It look exactly the same as the previous model but the recommended price has almost doubled and is typically selling in the UK for over £300!

Michael
 

PhilP

G Scale, 7/8th's, Electronics
5 Jun 2013
33,566
3,521
Nottingham
Best answers
0
Country flag
Michael,
Did you add-in any additional weight?

Less weight, so the loco more-likely to slip, under load is probably better for these loco's? - They are known to be slightly fragile in the drive-department.

How many skip-wagons are you pulling?

Thanks,
PhilP.
 

Michael

Registered
26 Jan 2010
139
16
Best answers
0
Country flag
Did you add-in any additional weight?

Less weight, so the loco more-likely to slip, under load is probably better for these loco's? - They are known to be slightly fragile in the drive-department.

How many skip-wagons are you pulling?

No, I havent found it necessary to add additional weights. It's normal use is to push and pull 4 tippers on a 5 metre level track as per the last photo in the opening post. Two are filled with real coal and two are filled with the ballast I use and I've had no problems at all with the reduced weight. The skates have been removed.

I also occassionally run it round my main track pulling 6 tippers (again all filled) which has at one point a 60 foot incline (on average about 1" in 3 feet) and again no problems.

It is however not very tolerant to any obstructions on the track and will tend to stop or derail if there are leaves or small twigs on the line or the ballast is too close to the rail.

Michael
 

PhilP

G Scale, 7/8th's, Electronics
5 Jun 2013
33,566
3,521
Nottingham
Best answers
0
Country flag
Thanks for the information. :clap:
 

Fred2179G

Registered
20 Apr 2017
1,059
186
USA
Best answers
0
Country flag
The skates have been removed.
That's the second comment about removing the skates to improve traction. Mine will stall on hills with the wheels spinning (I know, too many wagons behind!) But I wanted to retain the track/battery option as I wasn't sure I am keeping it. I will have to see if there is some way of fixing them up when in battery mode. Maybe a steel rod underneath the chassis. . .
 

PhilP

G Scale, 7/8th's, Electronics
5 Jun 2013
33,566
3,521
Nottingham
Best answers
0
Country flag
Maybe a steel rod underneath the chassis. . .

A sleeved steel-rod, please!

The track pick-ups might be isolated, but what if it drops off, or the loco derails? :eek:
 

Fred2179G

Registered
20 Apr 2017
1,059
186
USA
Best answers
0
Country flag
A sleeved steel-rod, please!
No track power anywhere I run. But you make a good case for insulation! I have a 1/18th stainless rod that I was thinking of using, and I'm sure the shrink-wrap tube will fit.
 

JimmyB

Now retired - trains and fishing
23 Feb 2018
6,947
921
69
Weston-super-Mare
www.tumble-down-falls.co.uk
Best answers
0
Country flag
I currently have two LGB locos (Otto and HK Porter) battery powered from training cars, both with alternate track power, however I use a DPDT CO switch to ensure the track is isolated when on battery, as I found that without the battery power routes back to the controller even when switched off, causing issues.
 

Fred2179G

Registered
20 Apr 2017
1,059
186
USA
Best answers
0
Country flag
I use a DPDT CO switch to ensure the track is isolated when on battery
Me too. I just hide it in front of the chassis, on the assumption I don't flip the switch very often.

20191129_143617_loco-frame-wires.jpg
 

PhilP

G Scale, 7/8th's, Electronics
5 Jun 2013
33,566
3,521
Nottingham
Best answers
0
Country flag
The tolerances look very close? - Could be angle of the photograph??

It looks a little like the skates could be touching the flanges?
AND
Is there enough room for the 'swing' of the motion to clear the pickups?

Just it look's really close. :(
 

Fred2179G

Registered
20 Apr 2017
1,059
186
USA
Best answers
0
Country flag
It looks a little like the skates could be touching the flanges?
The skates are pushed up as far as LGB designed them to go. At the top of my photo the rods are at their lowest and are quite close, but not touching the skate. The wheel flanges are also close, but not touching. It's a very small loco! >:)

And soldering stainless isn't easy - the bar just got fed up of the springs and dropped off. I think I'll use a tabbed wire terminal and wrap it around the rod.
 

dunnyrail

DOGS, Garden Railways, Steam Trains, Jive Dancing,
Staff member
GSC Moderator
25 Oct 2009
26,171
4,993
75
St.Neots Cambridgeshire UK
Best answers
0
Country flag
I find removing the skates beneficial, once you properly take the battery decision no turning back. Things can always be put back if you flog the Loco subsequently.