Wednesday, 8 April 2015

Interactive sci-fi terrain

The long Easter weekend gave us plenty of time not just to mull over a few wacky ideas, but also afforded a few hours to actually put them into practice.

One of the things we looked at was creating some laser cut sci-fi terrain for our larger, 35mm grids.

This meant simply drawing up some vector shapes in Inkscrape and preparing them for laser cutting. It started out pretty simple - some double-length walls, about 68mm long, some inter-connecting pillars (for joining the wall sections either in a straight line, at 90 degrees, or combinations thereof) and spacing them all out onscreen so that, when clipped together, the fit perfectly in our 35mm grid system.

Instead of the relatively chunky 3mm, we designed these to be cut from 2mm MDF. The wall sections are pretty small and fiddly anyway, and we didn't want to make them more difficult to handle, by making them from extra-chunky stock.


Then something went a bit weird. Without even breaking out our favoured ExpressPCB, pads and circuits just appeared on the drawing....

What if, instead of being cut from 2mm MDF, the whole thing was cut from 2mm copper-clad PCB board? That would mean we could put some surface-mount LEDs on them.

And what if we could control individual LEDs? A simple shift register should suffice, allowing multiple walls to be daisy-chained together, all individually controllable from a single source. What if each panel had a few different coloured LEDs placed on them, so that, at the touch of a button, you could - for example - make an entire board area turn red to indicate "red alert"? Or door panels with red and green LEDs to indicate whether the door was locked or open?

Suddenly there was a world of possibility with this "interactive sci-fi wall panel" idea. In fact, since our board game is dependent on some hardware to act as a bridge between a smart device (phone/tablet/PC) and uses serial messages to pass data around, we could re-use the same technology and simply build a stand-alone app, to allow the user to switch lights on and off around their playing surface....

There was nothing for it: we had to crack open the Ferric Chloride!


One thing we hadn't considered (until it came to actually trying out a single wall panel) was that using 74HC595 shift registers meant that every panel needed a five-way connector (power, ground, clock, data, latch lines).


This was a rather chunky connector, and wouldn't work at all well with lots of tiny little, fiddly interlocking pieces. We needed a way of getting that pin-count down.

The Roman Black website has some great ideas for doing just this kind of thing. His site gives a great, detailed explanation about how you can use capacitors and resistors to create an RC circuit, to delay triggering the data/latch pins from a single clock source.


In theory this all sounds great. There's no reason why we couldn't mount a few discrete passive components on each board, and dress them up to look like sci-fi panels on the walls. In practice, things weren't quite so straight-forward.


Here we've connected two shift registers, one cascading into the other (yes, there are three on the breadboard but only two are actually connected together). While the PIC correctly activates the appropriate output pins on the first shift register, the cascade effect fails to send the data on to the second (and, if there were more than two, any subsequent) registers in the chain.

So a single-wire approach is achievable - but only at the cost of losing the cascade ability (and without being able to cascade data from one wall section to another, it'll be really difficult getting any except the first panel to light up!) Maybe we could tie the latch and clock pins together, and reduce our connection count to four pins, instead of five?


By tying the clock and latch pins together (it even suggests you can do this, in the datasheet), we need to provide on extra clock-pulse at the end of sending our data (since the latch is always one clock pulse behind the data). This worked fairly well, but we then discovered the downside of the shift-register approach:

Each shift register is able to source only about 16mA-20mA across all its outputs; roughly the same as the total output of a single PIC i/o pin. That's no problem if we're only lighting one LED at a time. But if we want to light up multiple LEDs, each one gets progressively dimmer, as more are lit at the same time. This could prove to be a real problem, as we've no idea which lights (or combination of lights) the user is likely to want to illuminate at any one time.

What we really need is some kind of constant current, multi-channel, LED driver....
Sometimes you need to invest a bit of time to discover what isn't going to work, in order to work out what is the best way to proceed with some projects.

This weekend we've done just that. We know that not only is a single-wire shift-register unsuitable for, let's be honest, a bit of a crazy whim idea. But investing a bit of time into trying alternatives demonstrated that shift registers aren't exactly the best idea for what we want anyway.

So we've a few TLC5916 LED drivers on order from Farnell.
Etching some PCBs should be straight-forward enough - though quite how we'll cut them into those strange shapes remains to be seen.....