Thursday 1 September 2011

Finally, the electronics!

The electronics to control the test layout is actually pretty simple.

A this stage, I'm using a simple home brew power supply. You can see this below. My plan is to replace this with a standard PC power supply which has more than enough grunt to power several trains, all the points, signals, accessories etc.



The point controller is built using a single Arduino board seen below left. There's a lot of grunt here to run just 4 servos but I want to make this a nice independent unit that can be "sold separately". Below right is a prototyping shield that I have used to hook up some jumper pins that I use to plug the servos in to. These were then connected to D10-13.

D0 & D1 I have left for serial I/O. D2-9 are used to control the points. Notice that I have them pulled HIGH simply to ensure reliable operation. Pins D2-5 are used to indicate that the point is being calibrated. More on this later. Pins D6-9 are used to control position (straight or switched). Very simple! Analog Pin 0 is used to connect a potentiometer to set the angles for the servo in the straight or switched positions under calibration.

 

In order to make it easier to connect to this board, I'm using these nifty screw terminal breakouts from DFRobot which I bought at littlebirdelectronics.

Calibration
Below is my home brew calibration board. You must have a way of calibrating this setup and I could have used serial IO but that's not easy for most folks and having a set of buttons and knobs is very intuitive.

Why do I need it? well, mounting servos under the bench is a messy business and there is a lot of slop in the system! Also, what if I want to use this on HO rather than N-scale?

Calibrating is easy. Set the position of the point you want to calibrate, flick it's calibration switch up. Move the knob and the blades of the point will move. Drop the calibration switch and the position is remembered in the EEPROM in the Arduino. Very simple.

Of course, serial control of the points is an easy extension and is on it's way. After all, why wouldn't you?

The photos below show it all hooked together - very nice!



Train Speed and Position
You have seen this in a previous post but I'm including it here in a bit more detail. This is yet another stack of Arduino shields. At the bottom is an Arduino Diecimila (an original form Italy). Then the DFRobot motor shield. This can control 2 motors bi-directional. On top of that is another screw terminal shield and on top of that is a prototype shield which makes it easier to hook up sensors. I'm using these great little analog IR sensors from littlebird. Analog is far better as the triggers can be tuned nicely inside the Arduino.


You can see the motor shield exposed below. 

And here they are all hooked together nicely. The blue wires between the boards allow the Controller system to drive the points. A lot of the cabling was hand soldered but I got really cheap and nicely built extension cables for the sensors and servos of DealExtreme for bugger all cash!


What's next?
  • Source code for the points system - not brilliant but good enough.
  • Controlling 2 separate tracks off this system.
  • Some cute signals I got off eBay.
  • Expanding to 48 digital IO lines.
  • A relay control board for track sections.

1 comment:

  1. Living the dream.

    Now, keep Hansen Lee happy by analysing your transfer functions and doing some root-locus and Nyquist diagrams.

    ReplyDelete