Wednesday, December 19, 2012

Back on the Rails

Holidays seem to be my train time. I did a train show in April and a merit badge clinic in September and that is about it. I have gotten excited about the new Raspberry Pi Linux computer, and plan on using it to control my layout instead of the two Arduino microcontrollers I use now.  There were are a lot of things that I hacked together to get the layout working, and I've long wanted a chance to do it over, simpler and cleaner.

My first step is designing a new control board. This will basically have an Arduino brain (Atmega 328) and two L293D H-bridge controllers. That isn't much of a departure from how it currently works, except it collapses several separate modules on to one board and will be able to control the engine and turnouts itself, or interface with another computer (say a Raspberry Pi)!
Perhaps my biggest leap in simplicity is in the turnout control. In my prior amateur stumbling, I ended up using a transistor to control a relay to control Ken Stapleton's switching circuit (times two!). I burned up two Atlas under-table switches figuring out that Rube Golberg setup. I guess that happens when a 5 volt guy starts trying to control 12 volt systems.  I've determined you could do the same job with several two-dollar, high-power MOSFET transistors, or (drum-roll please) a L293D H-bridge. There are two of these on the Adafruit motor control shield I'm currently using, capable of powering two DC motors each, of which I'm currently using exactly one half of one. A single H-bridge, with some diodes, can control both turn outs! It works, and I've only burned up one resistor and two cheap transistors.
 
The prototyping and testing is done, and the board is laid out and sent off for manufacture. See if you can tell the difference between my board and Lady Ada's motor shield. That is Open Source Hardware for you. She provides all the design files and I just stripped it down and built if up the way I wanted, complete with a  Wii nunchuck adapter! I just have to wait six weeks for it to come back from China to see if it works as advertised. If it works, I'll post my designs on line for others to use as well. So it goes.