Showing posts from August, 2011


Following on from this morning's post about ditching the LEDs/push-button control panel, here's a revised version of my first strip board layout. It's much more manageable. I've retained the resistors for sinking current from the 2-aspect signals, but they could be omitted from the strip-board and fitted in-line in the cabling instead. I really need to buy one and see what they look like.


I've spent the past couple of days re-laying track. I'd laid the two outer loops with Gaugemaster foam underlay, but it doesn't seem particularly compatible with Peco point motors. When I laid the track, that wasn't a problem, but now I want to automate everything, it is. So, the track's coming up in sections and I'm drilling ~6mm holes under one end of the tie bar on each point. I have one motor on a mounting plate that I'm offering up to check the holes are large enough and aligned correctly - you'd be surprised how hard that is to do. I've also decided (for today, at least) that wiring up indicator lamps and push switches is all too 1980s. I think I'm going to start by connecting the Arduino to my laptop and developing a serial protocol for activating the points and signals. The upgrade path is then to connect over Bluetooth using Serial Port Profile to either my Nokia N900 or one of those dirt cheap Android tablets that seem to be flooding

Less wires

Well, this one has less insane wiring, but uses a larger board. I could probably build it on three boards and each piece is fairly standalone. To make things easier, I've ditched the common Vcc or Gnd connections for each LED and decided to daisy-chain those connections on the back of the display panel.


This is a bit better. I could halve the number of resistors on the signal indicator outputs in the middle as I shouldn't turn red and green on together. Perhaps, however, I should leave it as is as it will stop the indicator LEDs going dim if I get it wrong.


Well, it's pretty good on board size, but perhaps I should expand it a few rows to try and tidy up some of the wiring. I drew it using DIY Layout Creator 3 (beta) . It crashed a couple of times (and, to be fair, the wiring is insane), but the autosave recovered me perfectly and it's far faster than Fritzing. The top bank of resistors is to drive common-cathode pairs of LEDs. This is because that's how the Berko signals come (I believe) and it was easiest to make the repeaters on the panel work the same way. The bank of resistors below that show the status of the points on the panel, and they use two LEDs top-to-tail with a switched centre. I did that to halve the number of outputs needed, at the expense of doubling the number of resistors. The bank below that are the four MCP23S17 I/O expanders (three of which have UDN2981 source drivers fitted to drive the signals) and the bottom bank are the L293 motor drivers. I will set every side of every L293 to high/low or low/


Here's my final schematic. I've only put one signal and point motor in - duplicate to taste. Multiple MCP23S17s can be wired in parallel, provided each has a unique binary value on the A0/1/2 pins. Diodes D1/D2 should be something like a 1N4004. I read somewhere (must find the link) that the inductive spike could be 300V, so make sure they can handle that.

Darlington Pairs

I spent some time today deciding whether I could use a 7 or 8 channel Darlington Pair IC (like the ULN2003A) to drive the point motors. They can only handle 500mA per channel, but it's possible to parallel up multiple ICs to increase the maximum current. The problem is the Vce(sat) is 1.2V and sinking 500mA means each IC will have to dump 600mW of power somewhere. It's nice that the chips are under 20p each , but I'd need a lot of chips to drive all 19 point motors (19 solenoids x 2 coils x 3 channels per coil / 7 channels per chip = 17 chips). That's an awful lot of soldering. The other option is MOSFETs. They can handle huge loads without wasting too much power as heat, so I only need one per motor coil. You seem to have to buy them a singles - there aren't any cheap 7 or 8 way packages. They cost around  65p each   56p each if you buy a few (I'd need around 40). But, if you're spending £1.30 per point on MOSFETs, why not just spend  £1.77 on an SN75441

Price update

CPC (who seem to be in some way related to Farnell, except that they charge entirely different prices) have the Allegro UDN2981  for £1.67 inc VAT. Bargain. I think I'll order a couple.

Easier than mucking around with MOSFETs

I found this: Basically it has 8 channels and each of those can continuously  source 150mA at up to 50V. This means I can drive four 2-aspect Berko signals from one £2.15 IC. This is good. Answers on a postcard (or in the comments) if you know the difference between a 2981 and a 2982. *shrug* The Allegro UDN2981A-T appears to be the same as the Micrel MIC2981, in case you find that in stock instead. If you're doing things on breadboard, like me, you'll want the DIP package, not the surface mount ones.


You can get my modified MCP23S17 library from Github: My four-led twinkling app is: /* Simple MCP23S17 demonstration */ /* Supplied with Arduino IDE */ #include // Mcp23s17 library available from #include // Wire up the SPI Interface common lines: // #define SPI_MOSI 11 //arduino <-> SPI Master Out Slave In -> SI (Pin 13 on MCP23S17 DIP) // #define SPI_MISO 12 //arduino <-> SPI Master In Slave Out -> SO (Pin 14 on MCP23S17 DIP) // #define 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) #define MCP23S17_RESET_PIN 8 // SINGLE DEVICE // Instantiate a single Mcp23

Stuff has arrived!

The Arduino Uno has arrived,. along with some other bits and pieces. Firstly, the Arduino Uno is awesome. It's so simple to program. I didn't need to install any drivers (I use Ubuntu). The special Arduino IDE is very light on features, but that makes it very simple to use. I had an LED blinking on and off in no time at all. The MCP23S17 had me baffled for a while, but I got it up and running eventually. The major pit falls were connecting both GND and VCC on the breadboard to GND on the Arduino (the pins are quite close together and my eyesight isn't that good). The second pitfall was using some example code that presumed I had tied the address pins one low and two high. I'd tied them all low. The third was that I need to strobe reset on power-up - something I'd not seen in any examples. As is usual, multiple intersecting bugs mean each makes the others really hard to find (I'd tried fiddling the addresses and moving the power pins, but never at the same ti


Here we go. For gEDA: MCP23S17 symbol L293 symbol For AnyRail: Track schematic


I'm considering adding some form of electronic control to my N-gauge model railway. It's a fairly compact layout, at 5' x 3' (approx 1500mm x 900mm), but has around 16 points. I'm done the layout in AnyRail and will post up the schematic soon. I've ordered an Arduino Uno ( ) to get things rolling on the automation side, along with: Microchip MCP23S17 16-pin I/O expander with SPI interface -   Texas Instruments L293 rated at 2A (not the weedy 1.2A L293D) -   Some LEDs and 330 ohm resistors (so about 13mA @ 5V) -   Some breadboard and jumper wires - The idea behind the port expander is that the Uno doesn't have many pins, and the Arduino Mega is a bit pricey (~£50, as opposed to ~£20). You can think of the MCP23S17 as an upgrade to the common 74HC595 shift register. Controlled via SPI, you can set each of the 16 pins as an input or an output