Those of you who have been reading this blog for a while, might remember that the main motivation behind modelling Jerusalem in N gauge was that I wanted a roundy-roundy layout where I could just watch the trains go by, as I'm not really into the whole shunting business. This preference for just sitting back and watching the trains hasn't changed which leaves me with a bit of a problem, as the new layout is so narrow that it could only ever support an out and back style track plan and personally constantly turning the controller on and off to operate such a layout sounds seriously tedious. To try and solve this problem I've been experimenting with some electronics to see if I can control the layout automatically for those times when I just want to sit back and watch.
What you can see here is my first attempt at controlling the locomotive automatically. The basic idea is that it simply runs the train in one direction for 2 seconds, stops the locomotive, waits for a second, and then runs in the other direction for 2 seconds before repeating the process indefinitely; currently for some reason the locomotive travels faster and hence further in reverse than when going forwards, even though the power supplied is the same.
Given that this isn't a post on my code/electronics blog I'm not going to go into the full details here, but essentially I'm using an Arduino UNO with a L293DNE integrated circuit acting as a H-bridge to provide power to the tracks (the messy collection of wires to the left of the track). Power comes from standard transformer that provides 12V DC at 1.5A, and the speed of the locomotive is set by using pulse-width-modulation (PWM) to vary the duty cycle of the output (i.e. the percentage of the time the power is on versus off). This arrangement seems to work reasonably well, although I have found that the Kato chassis doesn't work as well as I'd hoped at low speed (even with a standard DC controller), although adding some weight to the body shell in the form of Liquid Gravity has helped a little. Interestingly if I put my N gauge locomotive onto the track it performs much better at slow speed. Does anyone have any hints on getting the best out of the Kato chassis (it's model number 11-104)?
Of course basing the change on direction on time is never going to be particularly accurate, especially given that the speed seems to change based on direction, so in practice I'll need some way of determining when the locomotive should stop and reverse direction. My current plan is to re-use some of the ideas from my scale speed trap to sense the presence of the loco at certain points on the layout and then react accordingly.