Sunday, 29 December 2013

And so the circle turns again

A while back, we thought we had a winning formula for our board game. It consisted of a rather messy arrangements of pennies stuck to a board, with a layer of copper tape stripes above it. Although it worked, constructing it was painful, so we tried using magnets over some copper clad board, to simplify the actual building of the board.


The problem with copper board, of course, is that it's not magnetic, so we had to fix some thick steel bolts to the underside of the board in order to get the magnets to pull our top and bottom layers together.


Once this was working, we etched some massive double-sided PCBs to test the theory out with a "proper" circuit board.


This time, we tried using pennies instead of bolts on the underside of the board, to give the magnets something to pull onto.


We then had some professional PCBs manufactured, added our own separator layer and placed a printed sheet on the top.

The result? Because of the thickness of the PCB, we needed to use two pennies to provide enough steel, and a 3mm thick, 10mm magnet to get the contacts to close. This means that the cost of building each board has immediately gone up by 2x88 = £1.76, just in pennies (post-1992 pennies are still the cheapest source of round discs of steel we can find!). That wasn't the problem. The problem was no-one is likely to want to stick massive thick 3mm magnets to the undersides of their treasured miniatures to use as playing pieces.

So we tried something else - getting custom keypad membranes manufactured. They took a while to arrive, but looked very promising when they did


The final keypad membranes have a tiny 0.125mm gap between the top and bottom layers - perfect for use with 1mm thick magnets.....


Unfortunately, because of the manufacturing process - and because they are designed to be pressed by a human finger, not a piece of plastic with a magnet on it - the vacuum between the layers means that they need quite a press to get the contacts to close. In fact, they need a piece of steel and a 2mm thick magnet to get the playing piece to register it's position above any one square.
As part of the construction, using a custom membrane, we still have to introduce steel somewhere in or around the material that the keypad will be mounted onto (and still have the small matter of connecting the membrane to a PCB on the underside).

It's becoming obvious that using steel (or a similar, ferrous/magnetic metal) in the construction needs to be given more consideration, and not just included as an afterthought. Which has brought us full circle right back to where we started - with small discs of steel being set into a rigid playing surface.

Now, if we're going to the trouble of constructing each board section, instead of buying in parts from overseas (something that some of us were not always entirely comfortable with, given we have the expertise, if not the workspace - yet - to print and etch our own circuits) then perhaps it's time to review the whole project. Back to the drawing board, as it were.

Instead of trying to build our entire board game system in one go, re-purposing the board sections for different board game styles and genres, maybe we should be looking less at the cost of production, and more on actually getting some production done and optimising to reduce costs from there. Instead of creating loads of the same board sections, then changing the way the software reads the boards, for different games, we're going to focus on just one game - and then re-use the technology, but not necessarily the construction methods - for the others.

So we're back to building a space-ship based shoot'em up: Laser Squad on a board game.
But since we're moving away from having just a few large board sections, with different artwork on them for different games, to custom board game sections for each game.... why not go the whole hog and make different board game sections for the same game?
What about some kind of Laser Squad/Space Hulk mash-up?



Space Hulk had this great game mechanic - the boardgame was made from loads of smaller sections, which meant each game could be played out across a different spaceship. It was a simple idea, but one that worked (and still works) really well. Even with just a few different board sections, it's possible to have a really interesting playing surface.

Here's some preliminary sketches of how we might incorporate different board game sections into a Space Hulk/Laser Squad mash-up, that we've tentatively called Starship Raiders (ok, it's only called that because it was the only spaceship themed URL we could get hold of, but it's not a bad name!)


Our board game sections are

  1. 4x4 room with one exit
  2. 4-way corridor crossroads
  3. Single corridor section (all corridors will be two squares wide)
  4. 4x4 room with two exits
  5. 4x4 room with four exits
  6. Corridor right angled turn


One thing we need to consider is that not all board game sections will be able to connect on all sides.


If we consider using red for power, black for ground, green for rx and blue for tx, there are only so many ways we can lay out the connecting pins.
On the left and right hand edges, the pins need to be in the same order (so that two board edges can connect together). Likewise, the pins on the top and bottom of each piece need to be in the same order, for the same reason.

The problem comes when board sections are rotated (and is not immediately obvious from a piece which is symmetrical in more than one axis). Let's consider connecting a room piece to a "crossroads".


Connecting this way is fine - the connectors all line up. But what if we connect the room to the right hand edge of the crossroads piece?


Bzzzt! We've got a dead short!
So we need to make sure that our power and ground pins are on pins 1 and 3, so that when the board is flipped over and connected to an edge that it shouldn't, these pins line up to 2 & 4 on the other board section, rendering them harmless.


If we continue adding board sections without correcting this problem first, it may lead to some pretty funky data being passed back and forth, but at least there's no dead short threatening to kill our power supply (or worse still, damage the hardware that talks to the rest of the home network). From top-to-bottom (or left-to-right) our connectors read "pigo" - power, data in, ground, data out.

So our current thinking is that when a board section is first powered up (i.e. added to an existing, powered, board section) a one-off message is sent back to the host controller, telling it the ID of the piece just connected. On receiving this message, the host app can play a wav sample to let the user know that their board section has been accepted. If you connect a board piece and - after a short delay - hear a ting, ting, ting success message, you know you've connected it the right way round. If, however, you connect a piece and there's silence after a few seconds, the new board section hasn't been connected the right way (because it's either not powered up, or - if by some miracle it takes power from the data lines of the previous section - it's not able to send the "connect ok" message back to the host). Or, there's always the possibility that the code is buggy or something's just gone wrong ;-)

With all this in mind, it's time to make some PCBs and try this whole new fangled way of working out!
We're thinking of using "penny washers" for our steel discs. These are typically 25mm in diameter and 1.5mm thick, with a hole for an M5, M6 or M7 bolt.
If we use a pin in the centre of the hole, our top layer doesn't need to connect to anything on the board - it can just be a series of conductive dots which, when pressed, cause the pin in the centre of the washer to connect to the ring around it. By powering each row (or column) of washers one at a time, and reading the data inputs from the pins, we should be able to tell which washers have a magnet above them (since the signal from the washer will be conducted through the pin, back to the mcu).
Here's a design for a 6x2 corridor section (for some reason, we added some LEDs along the edges of the corridor, controllable by an HC595 shift register - this probably won't make it into the final version, but it seemed like a bit of fun)


As this PCB is quite large (160mm x 70mm) it's going to be a bit of a nightmare to press-n-peel (the old blule paper doesn't like transferring large areas of filled toner as it tends to smudge a bit during transfer) so this will have to wait until the next BuildBrighton session, where we'll do some PCB mask etching on the laser cutter.

Updates and debriefing (on whether it was a success, or another miserable failure) will be posted soon!

Audio playing toy with a PIC 16F1825

While we're waiting for our keypad membranes to arrive, and while a few other projects are waiting for parts (we really need some 5v zeners before trying our phone dialler in a live telephone point) last night's BuildBrighton Open Night was all about lasering and soldering.

Firstly, we made a PCB for our audio playing toy, small enough to fit inside the cute 50mm x 50mm cube that Steve managed to source from Farnell. It was based on our earlier clock project, but this time used a micro sd card holder and surface mounted 16F1825 PIC.



A hole was drilled in the top of the cube and a disc of acrylic inserted with magnets fixed into the top. These will both hold the toy shape in place and act as mechanical contacts for the resistor that is embedded inside each toy object, when placed on top. Small wires have already been soldered onto the underside of the magnets, and - of course - everything is held in place with plenty of hot glue!

[photo of inside]

The trickiest part of this was adjusting for the pinout of a micro SD card. Despite appearances, a micro SD card is not simply a smaller version of the full SD card. There is a subtle difference in where the pins go:


The thing to notice is that there is no second ground pin on pin 6 on the micro version of the SD card. When used in SPI mode, both pins 1 and 8 are not used. This meant that we couldn't just use the existing PCB layout from the earlier project, and had to build a fresh one from scratch (using ExpressPCB of course!)


The two pins labelled B are where the 3V battery is placed - ground at the top, power below. The two pins labelled R are where the wires connect to the magnets, and a resistor is placed across them. This completes a simple voltage divider onto pin RC4 which we can use to read the analogue voltage in, and work out which object has been placed on top of the box. The two pins labelled SP are where the speaker connects (it doesn't matter which way around) and the micro SD card holder is mounted such that pin one of the card is on the left hand side.

The code is a combination of the audio player code and analogue input code.
It is too long to list in one complete part here, but with a little imagination, it should be possible to combine the two to recreate this project!




Tuesday, 24 December 2013

Micro guitar amp mixer

It's been nearly three weeks since we went out to Berlin. The Arduino workshops were a success and from a group of about eight people, we reckon at least three (maybe four) are already well on their way to becoming electronics and Arduino aficionados!

Since we got back, there has been quite a bit going on, but - as often happens around this time of year - work, real life, and Christmas have tended to get in the way a little bit. But something else has also come up, which demands some attention:

While out in Berlin, Andrea (remember him, the screen printing guy who lives out there?) had lined up a gig at a night club on the Saturday after arriving. A few of us took to the stage at about 1am and played a 45 minute set, after just one-and-a-half days practice (and for some of us, a break of about 12 years since last appearing on a stage!)

We had a great time, and some of us were inspired to actually learn to play our instruments properly (it's like the Sex Pistols and 1977 all over again). Practicing an instrument can be tortuous for friends and family - and neighbours - especially since the only amplification equipment we currently have is a 300W PA and 15" speakers that we bought off eBay almost immediately after getting back!


Of course, there's no way anyone can use this for learning how to play a few guitar licks (though it will sound amazing if we ever get a gig in Brighton!). So, personally, I've been watching videos on YouTube and twanging out a few licks on an unplugged electric guitar.

One really interesting video (and one that convinced me to shell out some proper cash for a learning course) is this one by Griff Hamlin. He shows how to take a single, simple lick, with just a few notes, and apply it to a variety of different songs.


After watching this video, I'm even more convinced that just practicing licks is as pointless as repeating scales and patterns up and down the guitar neck. It's all well and good being able to play a lick or a scale - but to sound good, they need to be played in context. They need to be played with a song, not just on their own!

Also, electric guitars are made to be amp'ed up. They just sound awful "acoustically". And many of the lead licks I've been learning only really sound half-way decent if played through a powered speaker. So I got to thinking about making something which would not only amplify the guitar signal, but also mix in a backing track, to practice along with.

Being able to hear a backing track, as well as the electric guitar signal (not just the twanging of the steel strings) would be a real bonus. Either through a speaker, or headphones, just being able to hear a sound coming back would be really cool. So here's what I came up with



The input signal(s) are mixed using a simple resistor-based passive audio mixing circuit. This allows us to give each incoming signal it's own input volume. Then we use a DPDT switch to route the incoming signal to one of two different amplifier circuits.

It might be possible to merge these two amplifier circuits into one hybrid circuit, but for simplicity, we're keeping them as two different circuits: this means that the entire project can easily be replicated and altered to suit different needs. We used a DPDT switch so that during switchover (as the user changes the output from speaker to headphones and back again) the amps are powered down, to reduce any loud popping or crackling sounds.

I used two different LM386 op amps because the gain on these can be adjusted from the default of 20 to a whopping 200 (x10 output volume) depending on the resistor/capacitor combination between pins 1 and 8 (no components between pins 1-8 sets it to the lowest amplification value 20).
If we route this output to a set of headphones, sometimes even this signal can be too high and create nasty clipping and/or distortion. This can be taken out by adjusting the volume on the guitar, but if the guitar does not have a decent volume control, the gain from the LM386 might still be too high for a nice clear sound on the headphones.

So I created a completely separate circuit just for headphone use (the DPDT switch routes the incoming signal to one of two different amplification circuits) and used a fixed RC combination to force the LM386 to use a lower-than-default gain of about 11. Just for good measure, I also added a "choke" on the incoming signal for the headphones amp, since different headphones may have different sensitivities and use different speakers in the earpieces. The low-pass filter on pin 7 of the headphone circuit helps reduce any low frequency resonance (feedback) introduced by using such a low input signal.

It's probably too close to Xmas now to actually etch a PCB and try the design out, until Santa's been, polished off the mince pies and drunk my best sherry - but if there's a few hours over Christmas between everyone else watching the obligatory James Bond mid-afternoon movie, and Doctor Who saving the world at about 7pm, I'll try to get up in the loft and put one of these together to see how it performs.

In the meantime, the schematic is above for anyone interested in trying it out on a breadboard.