Packaging up the Controller
When working with off-the-shelf boards, they will ultimately determine the size of the enclosure since they come in fixed sizes. The enclosure I ultimately selected was larger than I wanted, but will still reduce the amount of clutter inside the loco.
Here we see the first group of boards used. Clockwise from upper left:
- Arduno Mega
- LM298-based motor controller shield (brake output)
- XBee shield with XBee module, also has wiring for connectors to other boards
- Small Digital-to-Analog board based on the Microchip MCP4725 DAC IC (speed output)
- 4-channel opto-isolated N-channel MOSFET driver board (digital and PWM outputs)
- 3 x 5-volt 2-channel relay boards (horn, bell, soundcard controls)
The XBee shield and module came from Sparkfun. Everything else is from Amazon.
Here we see the enclosure and the user-interface boards. I selected the Hammond 1591U enclosure with bottom mounting flange. The lid has openings for the LCD display and menu buttons. The enclosure has the standoffs mounted for the arduino. Not seen is a hole in the side for the Arduino USB connector.
The menu button board is one of the few custom boards. I like to use ribbon cable whenever possible for multi-wire cables. You can peel off the number of wires needed and solder header strips and sockets to each end. The wiring is much neater than having a big jumble of individual wires. In the previous photo you can see that I did use individual wires for many of the connectors. That's because the ribbon wire was too small for the insulation-displacement connectors I had on hand.
Putting everything together. You may have to get creative when fitting boards. Here, the relay boards are stacked together with an assortment of standoffs on one end. The edges on the other end align with slots molded into the enclosure. They are wedged between the enclosure and Arduino boards to keep them from rattling around. I have not added the external wiring and connectors yet. That is the next task.
If you are considering a custom controller to adapt the ProtoThrottle to your needs, note that your requirements will probably be much different from mine. For G-Scale if you're putting the controller on-board, you may only need the motor and XBee shields, and you can use one of the smaller Arduino boards (Uno R3). As an example, Here's my current stand-in throttle (work in progress):
It uses an Arduino Nano and a Nano IO Shield, both from Amazon. You can find the Nanos in 5-packs for $10-$15 (cheap!). The shield also has a built-in slot for the XBee module, but you'd need to do something different for the motor controller. Arduinos are a popular choice in robotics so there are lots of options available for separate motor controller boards. If you look closely, you'll notice that I actually use 2 Nanos in the throttle. The one tucked into the upper left corner handles all the processing for a small graphics display, while the main one handles the buttons and wireless tasks. All of this fits into a plastic electrical box enclosure with room to spare.
Speaking of XBees, if you're interested in playing around with them, I highly recommend getting a starter kit from Sparkfun here (or somewhere else similar). It includes several parts that you would need, and they also have a tutorial on getting started with XBees.
Now that we have our hardware put together, we can start looking at the code that makes it work.
Craig