Saturday, 29 May 2010

Prototype Points Control Board

Last night I finished a stripboard prototype of my points control board. This connects to the track/points and provides the following to a (seperate) microcontroller board:
  • +3.3v power source. This is taken from the 12v power source on the tracks and converted down using a linear regulator. The regulator can be changed if the microcontroller board requires a different voltage.
  • Inputs connected to MOSFETs that allow the points to be switched.
  • A logic output that indicates the current position of the points, by way of a microswitch mounted next to them.
Here's an annotated photo of the thing:
A: Points Control Board
B: Control Mote (using this to test for now, as there is only one set of points. Eventually this'll just a be a PIC/RS485 connection).
C: Microswitch. The points have a useful lever that protrudes out of the side and presses this switch when they're set to the straight ahead position.
D: Points movement solenoid. This is a standard Hornby points motor.

The circuit is very simple. It consists of two large capacitors in parallel (1470μF total) and two MOSFET controlled SPDT relays. The first relay switches the capacitors between charging from the +12v rail and the input of the second relay. The second relay switches between the two terminals of the point movement solenoid.

When the two inputs from the microcontroller are zero, the capacitors charge up. To set the points, the second relay is set to connect to the required side of the point movement solenoid first, and then the first relay is switched so that the current stored in the capacitors flows through the solenoid, moving the points. Because the capacitor discharges quite quickly through the solenoid, there is no danger of doing damage if it is left in the on state.

Here's a rough circuit diagram! (n.b: the two throws of RELAY_CHARGE are the wrong way around in this diagram. I've also left off the linear regulator and microswitch wiring.)
The firmware running on the control mote is very simple at the moment - it listens on the radio for points control commands and sets the points accordingly. It toggles its red LED every time a message is received and turns on its green LED when the microswitch is open.

I wrote a simple application in C# that uses a Mote connected to a USB port as a way of sending messages over the radio to the control Mote. The video below shows this in action*.



Next on the agenda:
  • Building circuitry onto a train that allows it to be controlled from the PC and sense its position.
  • Updating the points control firmware so that the current state of the points can be queried over the radio.
  • Making the train send points control messages on the radio so that it can set the points as required.
* I appreciate that this may not fit the traditional definition for "action".

New Project: Model Trains

Ok, this isn't actually a new project as I've been working on it for months now. The aim is to create a model railway that operates in a decentralised automonous way. Here is the basics of how I want it to work:

  • Each train will be controlled by an on-board Mote. These are basically small circuits with a microcontroller and radio chip. Trains can communicate with each other wirelessly and form a peer-to-peer mesh network. I am using the (now discontinued) Moteiv tMote Sky model of Mote, as I have five available to me. They have a TI MSP430 MCU and CC2420 2.4GHz radio chip.
  • Fixed track features such as points, signals and level crossings will each have a small PIC-based controller. These will all be connected together using a wired RS-485 bus. A single Mote will also be connected to this bus and will act as a wireless interface to all of the fixed features.
  • Trains will have knowledge of the track layout, which will be divided up into blocks. The boundary between blocks will have some form of marker embedded under the track so that trains know when they have entered a block. Trains will use dead-reckoning within blocks to estimate their position.
  • Each train will allow its schedule to be programmed into it. This will consist of a list of waypoints (stations) that it should visit. Trains will use their knowledge of the track layout to plan a route and follow their schedule.
  • Trains will communicate wirelessly to ensure that no block of track is occupied by more than one train at once. This will be done with a token passing protocol, where trains may hold the token for a number of track segments and pass them to other trains as required.
  • The fixed track features (e.g. points) will be controlled by the trains themselves by sending messages on the radio to the Mote that is acting as an interface to the fixed features. For example, if a train holds the control token for a block of track with a set of points in, it will be able to set the points as required by its route.
The key aims of the project are that, aside from programming schedules, trains operate autonomously and without any central controlling computer.

Now for a really boring video that showed my progress some months ago. It shows a Mote controling a train and simply moving it backwards and forwards by a fixed amount. Nothing very special at this stage...

Hello!

This is a blog for me to post updates about things I'm working on. Will I ever update it again? Who knows. Will anyone read it? Almost certainly not.

Good times.