Saturday, 24 September 2011

VeeCAD

I was recommended to try VeeCAD by a colleague who's a member of CMES.

I polished up my schematic in Eagle and, using the VeeCAD recommended export script, generated a netlist that VeeCAD could open. The advantage over diylc is that it tells you when you've not followed the netlist, allowing you to move components around until they fit nice and tightly together while knowing the circuit should still work. The disadvantage is it's slightly less pretty than diylc and it's a touch more fiddly to pick up and move components.

This schematic has 8 high side 12V outputs and 8 strobed 12V output pairs, so it will drive 4 2-aspect signals and 8 points. I think that means I'll need three of these and another, smaller, board that does just the signal outputs. The boards take as an input a 4 wire SPI bus and two pins to control whether the points are driven left or right (it didn't make sense to lose two pins off every MCP23S17 to do this), plus 12V, 5V and GND. The only thing I haven't added is smoothing capacitors for every IC, but there's plenty of spare board space for that.

Free Photo Sharing by ThumbSnap
Eagle schematic

Free Photo Sharing by ThumbSnap
VeeCAD stripboard layout

Sunday, 18 September 2011

Moving signals

I think this is a little more prototypical. I've moved to 3 aspect for the double track mainline and moved the up feathers onto the platform starters. Free Photo Sharing by ThumbSnap The signal BOM is:
All signals from http://www.crsignals.com

-- (20) --

Platform 1 up (London or Hilton Parkway)
	3 Aspect with two Feathers
	SN34 3-aspect Home LH Platform starter £15.95
	RI12 Position 1 + 2 Route Indicator £20.00

Platform 1 down (Birmingham or Radford)
	3 Aspect with Feather
	SN33 3-aspect Home RH Platform starter £15.95
	RI01 Position 1 Route Indicator £10

Platform 2 up (London or Hilton Parkway)
	3 Aspect with Feather
	SN33 3-aspect Home RH Platform starter £15.95
	RI01 Position 1 Route Indicator £10.00

Platform 2 down (Birmingham)
	3 Aspect
	SN34 3-aspect Home LH Platform starter £15.95

Platform 3 up (London or Hilton Parkway)
	3 Aspect with Feather
	SN34 3-aspect Home LH Platform starter £15.95
	RI01 Position 1 Route Indicator £10.00

-- (12) --

Hilton Up Approach Junction
	3 Aspect with two Feathers
	SN08 3 Aspect Home with Safety Ring £14.59
	RI12 Positions 1 + 2 Route Indicator £20.00

Hilton Down Approach
	3 Aspect
	SN08 3 Aspect Home with Safety Ring £14.59

Hilton Approach from Hilton Parkway
	2 Aspect
	SN06 2 Aspect Home with Safety Ring £14.00

Hilton Approach from Radford
	2 Aspect
	SN06 2 Aspect Station with Safety Ring £14.00

-- (4) --

Hilton Parkway (Hilton)
	2 Aspect
	SN31 2-aspect Home RH Platform starter £14.25

Radford (Hilton)
	2 Aspect
	SN31 2-aspect Home RH Platform starter £14.25


36 12V on/off outputs required = 5 UDN2938 drivers

Sunday, 11 September 2011

Feathers

The CR signals website (www.crsignals.com) is proving potentially ruinously expensive. They have a much larger range than Berko, including a selection of route indicators. These come in in a range of positions (numbered 1 through 6, corresponding to 11 o'clock, 9 o'clock, 7 o'clock, 1 o'clock, 3 o'clock and 5 o'clock respectively) to indicate which upcoming junction the train is about to take - see Wikipedia or Railsigns.co.uk.

AnyRail doesn't have symbols for any British style N gauge signals, so I've had to approximate with some P├ęgase symbols.

Free Photo Sharing by ThumbSnap
At £14 per signal and £10 per route indicator, they dwarf the costs of the Arduino and driver circuitry. Sadly, though, I don't really have the fine motor skills to build them myself. The little brass ladder must only be 3mm across!

Saturday, 10 September 2011

Signals

I went to the March and District MRC show today. Talked to some great people - made me really enthusiastic about getting stuck in to it all again. www.layouts4u.net had a stand there. I had a look at some N-gauge suitable signals from CR signals. These are the first signals I've seen up close as I've only seen the Berko ones on-line. They have small enamelled copper flying leads with pre-fitted resistors for 12V operation on the two anodes, with a common cathode return. This simplifies the veroboard somewhat as I won't have to worry about the resistors. I am concerned about what to do with the signals while the layout is in storage though. My best suggestion so far is to pull them out of their mounting holes and clamp them to the track using magnetic straps.

Well stone me, it works

I'm hugely surprised to be honest. I expected more fire, or at least some melting.

I do have a problem with the L293 on power up - it drives all four outputs high for a few seconds until the MCP23S17 is initialised. I think if I pull the enable lines low this should stop. Probably not good to drive every point on the layout in both directions simultaneously for a second. Certainly not at 1.2A per point per direction!

Incidentally the diodes you can see on the reverse of the motor are the flyback diodes. These are ultra-fast UF4007s, because that's what I had to hand. I really need to leave it on a soak test to see if the L293 survives.

Sunday, 4 September 2011

L293 driver

Just put some more code on github. I'm still not entirely sure what I'm doing with git, or why I have to 'add' code whenever I change it, even if it's already been added.

See http://github.com/thejpster/L293

I'll take a video of the code running soon, but here it is.

/* Simple MCP23S17 demonstration */

/* Supplied with Arduino IDE */
#include <SPI.h>

// Mcp23s17 library available from https://github.com/thejpster/Mcp23s17
#include <Mcp23s17.h>

// L293 point driving library available from https://github.com/thejpster/L293
#include <l293.h>

// Wire up the SPI Interface common lines:
// SPI_MOSI   11 //arduino <-> SPI Master Out Slave In   -> SI  (Pin 13 on MCP23S17 DIP)
// SPI_MISO    12 //arduino <-> SPI Master In Slave Out   -> SO  (Pin 14 on MCP23S17 DIP)
// SPI_CLOCK  13 //arduino <-> SPI Slave Clock Input     -> SCK (Pin 12 on MCP23S17 DIP)

// Then choose any other free pin as the Slave Select (pin 10 if the default but doesnt have to be)
#define MCP23S17_SLAVE_SELECT_PIN  9 //arduino <-> SPI Slave Select -> CS  (Pin 11 on MCP23S17 DIP)

// Instantiate a single Mcp23s17 object
MCP23S17 io_chip = MCP23S17( MCP23S17_SLAVE_SELECT_PIN /* CS */, 0x0 /* Tie A0/A1/A2 low */);

// L293 drivers
L293 points[2] = {
  L293(&io_chip, MCP23S17::GPIO_B0 /* Strobe */, MCP23S17::GPIO_A0 /* Left */, MCP23S17::GPIO_A1 /* Right */),
  L293(&io_chip, MCP23S17::GPIO_B1 /* Strobe */, MCP23S17::GPIO_A0 /* Left */, MCP23S17::GPIO_A1 /* Right */)
};

void setup()
{
  // Setup the serial port so we can see some debug
  Serial.begin(115200);
  Serial.print("Starting...");

  Serial.println("Started.");
}

void loop()
{
  // send data only when you receive data:
  if (Serial.available() > 0)
  {
    char incomingByte;
    // read the incoming byte:
    incomingByte = Serial.read();
    switch(incomingByte)
    {
    case '1':
      Serial.println("Point 1 Left");
      points[0].strobeLeft();
      break;  
    case '2':
      Serial.println("Point 1 Right");
      points[0].strobeRight();
      break;  
    case '3':
      Serial.println("Point 2 Left");
      points[1].strobeLeft();
      break;  
    case '4':
      Serial.println("Point 2 Right");
      points[1].strobeRight();
      break;  
    default:
      break;    
    }
  }
}