Sunday 26 February 2012

Fuzz Face with NPN transistors (MPSA18 amplifiers)

After amending our FuzzFace design to use a positive power supply, we've had a couple of enquiries about the schematic. Mainly that a few readers weren't familiar with the PNP transistors used (nor seeing them drawn "upside-down" in the circuit) so we've found a design that uses NPN transistors and different resistor values (including a potentiometer/variable resistor to adjust the amount of "fuzz")

FuzzFace with NPN transistors

Here's the PCB layout. We've not had chance to try this, as we're still waiting for some 20uF capacitors.

That said, we've a few 22uF caps lying around here (large black barrel electrolytic types) and since 22uF is just within the range of a 20uF with +/- 10% (and 20uF is within the range of a 22uF with +/- 20%) then it may just be a suitable replacement. We hope so, since 22uF caps can be easily found all over Farnell and eBay for just a few pence whereas the cheapest 20uF rated capacitors are about £3 each.

FuzzFace NPN pedal PBC layout
(print the above at 100% no scaling to create your own press-n-peel image for toner transfer)

Since simplifying the design (using 22uF instead of 20uF capacitor for example) we've managed to source all the components needed to make this pedal, so it's off to the nerd cupboard now to crack open the Ferric Chloride and get etching!

Friday 24 February 2012

Painting Blood Bowl miniatures

I've been trying to spend some time away from my computer lately - which is quite difficult since it's not only my work, but my hobby and most of my other hobbies (electronics, music etc) use a computer somewhere along the line too.

Since working on my Blood Bowl electronic clone, I've been looking at miniature-based war games. I never understood them, nor was I particularly interested in the whole dragons-and-wizards games, even when I was a teenage nerd-bag baby (listening to Iron Maiden, baby). But I always thought that Blood Bowl was a good game in it's own right - or rather, it could be, if it wasn't for all that pesky dice-rolling and looking up results.

One thing I have found, however, is that I can wield a tiny 000 paintbrush quite well. I'm not up to Games Workshop Golden Demon, professional painting standard, but I do seem to be able to blob colours in roughly the right places on a miniature. So I'm trying to develop my own painting style. I can't be bothered with all those washes and blending and teeny-tiny details, but I do quite like my thick black outlines and the "toon shading" finish on these models

So this is going to be my signature style. Van Gogh had his, Escher and Matisse had theirs. This is mine. Two-tone shading and thick black outlines; miniatures that look like they've been coloured in using a set of children's felt-tipped pens. I'm still building up my range of paints, so I've a couple of miniatures on the go while I'm waiting for different shades to arrive in the post. Here's an Orc "thrower" started in my new "toon shading" style:

(the colours on the actual model are much more vivid and vibrate - my camera-phone obviously isn't very good with garish bright colours!)

While I'm actually enjoying regressing back to my 14-year-old self doing this sort of painting, I still can't wait to get the models painted and actually see them being used in an electronic Blood Bowl game!

Wednesday 22 February 2012

Investigating capacitive sensing

The results from our earlier testing for a multi-plexed capacitive sensing grid are in and...... it's not good. The idea just didn't work. It seems that to use "simple" capacitive sensing - ie energising a pad then checking to see if an input is present a few moments after shutting off the power - the pad has to be directly under the top "plate" of the capacitor (i.e. your finger).

We were hoping that putting power onto a plate immediately to the side of what would be the bottom "plate" would suffice but the only way we could get an inputs to activate was to introduce a "real" capacitor and make a mechanical contact to the plates.

This got us thinking about alternatives for our cap-sensing board (and if it would even be possible). While an RC network on each input pin is immediately obvious, converting this into a grid also gives us a few headaches. So we're now investigating how to use rows and columns of pads and our working cap-sensing prototype

.We already know that we can activate/deactive single input pins one-at-a-time and detect if a piece is above it. But when it comes to multi-plexing, re-using the same inputs for different "rows" of pads is quite tricky. But we've come up with another idea which keeps the same (working) technique and builds on it:

We're going to make strips of pads, all connected in a line. At 90 degrees to these, we'll have strips of pads on the other side of an insulating material. We can then send an entire row high, flip the pin to input and check for a signal on the input pin - just like before. What we're hoping to do is to use the pads running perpendicular to "mask out" some of these pads, so if we get an input high, we know which of the pads in the strip triggered the input.

Let's say the lower (darker) pads in the diagram are on the X axis, and the paler (higher) pads are on the Y axis. We can send row X1 high and check for a high input back. But it could have been any of three pads in that row which triggered the input. BUT - if we send columns Y1 and Y2 high, when row X1 flips to input mode, only capacitance from X1,Y3 will be detected (since when row X1 goes low, Y1 and Y2 stay high, so if your finger is over X1,Y1 or X1,Y2, it won't actually "discharge" until these columns go low as well).

That's the theory anyway.
Once again, it's a bit late to try the whole thing from start to finish, but here's as far as we got:

We started by drawing 1" squares onto a strip of 1" wide sticky copper tape. In the centre of each square, draw around a penny coin. Draw lines to connect all the dics in a row and cut them out using a sharp knife

As we're going to have rows and columns running in opposite directions, we'll need some insulating material and to stick the strips of pads on each side. Ideally we'd have preferred to use tracing paper or tissue paper - but in true "hacker" style we used whatever was to hand; these paper towels were quite thin:

Stick the rows of pads in one direction, and the "columns" at 90 degrees. If we'd used tracing paper, we would be able to see where the pads had been placed on each side - we couldn't and had to guess, which is why they're a little bit out of alignment. We're not even sure if this idea is going to work - let's hope this doesn't prove critical when we come to try it out!

Rather than spend all night making a large grid of pads, we're after proving that the idea works (or, if it's anything like last time, whether it doesn't).  So we've marked the four pads in this arrangement that have pads in both the X and Y axis on opposite sides.

All that's left to do is to write some new firmware and try the idea out!
Unfortunately, it's gone midnight now and with work in the morning, this will have to wait until tomorrow.....

Monday 20 February 2012

Multiplexed capacitive sensing board(s)

This is yet another proof-on-concept idea, but if it works, it'll be perfect for our intelligent/electronic board game. Following our earlier instructions, here are two multi-part boards for testing.

As you can see, each pad is split into two large rectangles. One half of each pad is connected to a common "power" pin and the other to an input pin on the microcontroller. The principle is to make one half of the pad "live", shut down the power, wait a uS or two, then check the input pin. Hopefully the pad size will be sufficient to allow the coin to act as a capacitor, even if the two plates of the capacitor are different sizes.

There's no real way of knowing for sure if this idea will work or is just crazy wishful thinking - except, perhaps, to build it and see!

Sunday 19 February 2012

Multiple capacitive sensing inputs

Using our switch-from-output-to-input method of testing for a piece works fine to date. But there's a problem brewing that needs tackling early on:

Each sensing pad currently uses one digital i/o pin.
One of the larger pin-count PIC microcontrollers, an 18F4550 (or 16F877A if we're not worried about the USB stack) has only 40 pins, of which about 34 can be used for digital i/o. If we consider even a simple chess board, we'll need at least 64 digital i/o pins for an 8x8 grid.

For anything larger or more interesting than a chess board, we'll need LOTS more pins! It's possible that we could use lots of shift registers and daisy chain them to increase our pin count, but we're going to try our earlier design, using "rows" and "columns".

We'll hook up 8 pads onto a single input PORT (each port is 8-bits/one byte wide) and monitor it for input from the board. Then we'll use the left over digital pins (and perhaps a shift register if necessary to increase the pin count here) to activate specific "rows" on the board. By knowing which row is activated, and by reading which input pins are high after the row has been switched off (using residual capacitance to keep the input pin high if a pad is touched or a player touches a piece standing on top of the pad) we can calculate exactly which pad has triggered the "high" input signal.

To achieve a full-sized Blood Bowl board, we're going to construct each row from two "modules" of 8 pads. Each module can connect to its own input port (e.g. PORTB and PORTD) on a 40-pin PIC so we'll be able to monitor up to 16 pads at any one time.

Here's a module we've come up with.
For testing we're going to etch this onto single-sided copper board. For the final version, we're going to use double-sided board (so that the traces are on the bottom and can't pick up any stray capacitance from the pieces on the top).

Capacitive sensing 1x8 board module

The first 8 pins connect via a wire to the input port(s) on a microcontroller. The final pin (connected to the 8 "row" pads through a 1mm wide trace) goes to a "row control" pin (either directly to an i/o pin, or to a shift register used to increase the number of available pins).

A few people have already said that when they printed the earlier (portrait) version of this board, their printer resized it ever so slightly to get it to fit onto the page - we managed to get this effect too, so here's a landscape version of the same board:

Capacitive sensing 1x8 module (landscape)

Testing piece tracking

Now we've tested our capacitive sensing board and everything appears to work when using pennies (and batteries) as playing pieces. The next thing we need to know - before getting immersed in board builds, data manipulation etc - is that the whole concept still works if we use anything other than pennies or batteries.

This project started out as a digital Blood Bowl game board but we've come to realise that it has potential to be used to "electronify" (is there such a word?) many other popular board games. Luckily, many of the miniature playing pieces used in these types of games are metallic (pewter). All we need to do is make sure the metal figurine is connected to a penny in the base of the miniature.

The "slotta-bases" used by many miniature manufacturers are ideal for this.

Remove some of the plastic from the underside of the slottabase and file the bottom of the figurine so that there is enough space under the miniature for our penny

The finished model should look exactly as before, only with a void under the base to house our penny. When the finished figurine is placed over the penny, an electrical connection is made from the coin to the miniature but the penny is not visible:

This means that touching the miniature gives the same result as touching the penny - i.e. we can, indeed, use a metal miniature as a playing piece on our capacitive sensing game board:

Note that the flickering LED in the demo is not due to a fault in the board - trying to watch the video viewfinder and place the piece on the correct place on the board meant sometimes it sat between pads

Tracking playing pieces

To date we've come up with a capacitive detecting circuit which tells us when
a) a piece is introduced (put down) on the playing board
b) when a piece is either lifted off the board, or released

It's part B that's causing us a headache for use as an intelligent board game.
The two actions are actually opposite of each other, so it's difficult to track where exactly on the board a piece is at any one time.

For example, in our test-rig, when an LED lights up, we know that
a) a piece is above a capacitive sensing pad
b) the player has hold of the piece (this is necessary to provide the "ground" for the capacitive part of the sensor

So when an LED lights up, we know that a piece is in the square above the sensor. The problem comes when understanding what has happened when the LED goes out:

Either the player has put the piece down in the square and let go of it OR the player has lifted the piece off the board and continues to hold it in their hand. These are opposite statements - when an LED goes out, either the piece is on the board, or it's been lifted off. Hmmmmm. How to tackle this one?

Let's say we start the game with a completely empty board (and a matrix/array of empty cells).
The controller (whatever that will end up being, either a character LCD or a PC connected to the board or something similar) tells the player to put down a specific piece on the board - for the sake of example, we'll use chess pieces, but the principle applies to lots of other board games.

We could keep a track of the "last piece touched" or "piece in hand".
In this case, the controller sets which piece is in hand (by telling the player to pick up, for example, a black knight). Now when an input is activated (LED lights up) the board can record the playing piece type in the matrix/array. So if pad 1 lights up, it can say "square one contains a black knight".

If, sometime after this, pad 2 lights up, the board would say "the piece in hand is a black knight. Find which square contains the black knight. Square one is now empty, the black knight is now in square two." By doing this, every time a square "lights up" we simply clear the previous location and update the playing piece to the new location. This works well for a single playing piece on the board.

When we introduce more than one playing piece (which, let's be honest would make for a pretty board board game if we couldn't) things get a little more complicated, but the same principles <i>should</i> still work:

When a square lights up:
  • Check to see what playing piece is in this square
  • If no playing piece is in this square, we're working with the previously held piece - clear the previous square and update this one to say the last held playing piece is now in a new location.
  • If a playing piece is found, remember this is now the held playing piece and wait for a different square to light up.
This should allow us to deal with a player simply touching and releasing a piece (the LED lights up and goes out, the board knows that the square already has a piece in it and simply updates which piece is "in hand"). When the player lifts a piece off the board, the LED lights up then goes out and the board updates which piece is in hand (since it knows that the detected square contains a playing piece). But now, when the piece is put back down in a different square, a different LED lights up, the board knows that this square is empty, so updates the location of the piece "in hand".

By using this method, it should be possible to keep track of any number of playing pieces on the game board.

The only problem we can see so far is when removing pieces from the board completely. For example, when a white queen takes a black pawn:

The player picks up the white queen to start moving. The player picks up the black pawn and removes it completely from the board. The player puts the white queen in the black pawn's old square. If more than one piece is moved during a turn, things could get messy!

In this example, the board detects the white queen being lifted off the board (white queen is "in hand"), then it "sees" the black pawn being lifted off the board (black pawn is in hand) then a piece (the board doesn't know which) appears on the black pawn's square. It's possible that the board thinks the black pawn is the piece in hand, and so says that the black pawn is back in the black pawn's square - leaving the white queen where it was.

The solution to this, is to have an "offboard area":
The board sees the black pawn is in hand (when the player lifts it off the board). The black pawn is removed from the board and put into an offboard area. The board now updates the black pawn's old square and makes it free. The player then picks up the white queen (the board puts the white queen "in hand") and places it in the black pawn's old square. The board recognises that this square is now empty, so updates the location of the white queen in the matrix/game array.

Code for capacitive sensing

Following on from an earlier post, introducing capacitive (touch) sensing, here's the Oshonsoft PIC Basic Code to read three pads, connected to PORTB.2, PORTB.3, PORTB.4

Define CONFIG1L = 0x24
Define CONFIG1H = 0x0c
Define CONFIG2L = 0x3e
Define CONFIG2H = 0x00
Define CONFIG3L = 0x00
Define CONFIG3H = 0x01 '81=use MCLR, 01=pin1 is input
Define CONFIG4L = 0x80
Define CONFIG4H = 0x00
Define CONFIG5L = 0x0f
Define CONFIG5H = 0xc0
Define CONFIG6L = 0x0f
Define CONFIG6H = 0xe0
Define CONFIG7L = 0x0f
Define CONFIG7H = 0x40

Dim tmpinput1 As Byte
Dim wd As Byte

Config PORTA = Output
Config PORTB = Input
tmpinput1 = 0
wd = 0

       WaitMs 200
       UsbSetVendorId 0x1099
       UsbSetProductId 0x1099
       UsbSetVersionNumber 0x1001
       UsbSetManufacturerString "Nerd Club"
       UsbSetProductString "Capacitive board game sensor test"
       UsbSetSerialNumberString "1234567890"
       UsbOnIoInGosub usbonioin
       UsbOnIoOutGosub usbonioout
       UsbOnFtInGosub usbonftin
       UsbOnFtOutGosub usbonftout

       'turn portB into outputs
       Config PORTB = Output
       PORTB = 0xff
       'wait a bit to settle
       WaitUs 1
       'turn portb to inputs
       Config PORTB = Input
       'wait a bit to settle
       WaitUs 1
       'read which pins are still high
       '(these should be the ones with coins over them)
       tmpinput1 = PORTB
       If tmpinput1.3 = 1 Then High PORTA.4 Else Low PORTA.4
       If tmpinput1.4 = 1 Then High PORTA.3 Else Low PORTA.3
       If tmpinput1.5 = 1 Then High PORTA.2 Else Low PORTA.2
       Goto loop
       'received data from PC
       Select Case UsbIoBuffer(7)
              Case 1
              Case 252 'write a value to onboard PIC eeprom
              Write UsbIoBuffer(0), UsbIoBuffer(1)

       'send data back to PC
       UsbIoBuffer(0) = tmpinput1
       UsbIoBuffer(7) = wd
       wd = wd + 1





This code reads whether a touch is detected over each of the pads and lights up a corresponding LED on PORTA.2, PORTA.3, PORTA.4. It also sends the value of the input pins on PORTB to a USB client (so the board game can be connected to a PC and data read in that way too, for future development).

(For our trials, we concentrate on just the LED outputs).

Here's a video showing how the LEDs light as a playing piece (metallic disc) is picked up and put down on the playing board. Note that the LEDs flash in exactly the same way as when the playing piece is stationary and momentarily touched by the player:

Saturday 18 February 2012

Intelligent board game update

It's been a while, and we've been concentrating on the "nicer" (i.e. nerdier) side of our electronic board game. That is, storing and retrieving game play data and displaying it on a nice, fancy character LCD. This week, we've been looking more into the actual mechanics of game play. Now, our earlier attempts at tracking playing pieces on a board did work, but the board itself left a little to be desired. Because we were making and breaking contacts on the board surface, the playing side of the board was littered with lots of little metal studs.

These didn't look particularly nice so we've been investigating capacitive sensing - specifically, placing the copper/metallic pads under a printable surface and moving the pieces around on top. This should allow us to create a number of board games with different layouts, finishes etc. but more importantly, to remove the need to drill hundreds and thousands of little holes all over the place.

Cap sensing is quite straight-forward. Create some large pads, connect to the i/o on your microcontroller, set the pin to output and send it high. Wait a few uS then set the pin to input and give it a few uS to settle. Read the input pin. If your finger (or an object acting as a ground plane) is over the pad, you've effectively created a miniature capacitor and the input pin will still be high. If there's nothing immediately over the pad, the input pin will be low.

Heres' how we tested the principle:

First cut out some sticky copper tape - we cut around a penny coin and left a trailing "lead" coming off it (so we had something to connect our wires onto, to connect to a PIC microcontroller. We placed three of these onto a sheet of cardboard, then wired them up to PORTB on an 18F2455 chip.
The input pins were pulled to ground through some 500k resistors.

The process described above was carried out and the pads touched with a finger.
The corresponding LEDs lit up as each pad was touched. Next, a sheet of 350gsm (quite thick) cardboard was placed over the pads and the experiment repeated. The LEDs continued to flash as each pad was "touched" through the sheet of cardboard. At least we can be confident that we can create a grid of pads and put a nice, printed face over the top without affecting performance.

Then we placed our penny coins over the pads.
The LEDs did not light, unless the coins were touched. But once they were touched, the effect was the same as touching the pads directly, and through the sheet of cardboard.
One last test remained - if we used metallic playing pieces, with a metallic base, they should behave in the same way our coins were. But what if the playing pieces were coated in acrylic (or other non-conductive) paint? Our last test was to touch the coins "through" a sheet of paper (a shopping receipt was easily to hand).

Now we had a working prototype, we considered how we could detect the presence of a coin above our pads but without the player having to touch them. This proved trickier than we thought. The only progress we made was discovering that touching the piece/penny was the same as connecting it to the ground pin through a wire.

Wednesday 8 February 2012

Make your own FuzzFace guitar pedal (cont)

Following on from an earlier post, guitargeek82 got in touch to point out that the original circuit was based on a "negative power" design. When running your pedal from a PP3 battery rather than a plug-adaptor-type power source, this doesn't cause a problem (nor will it cause us any issues since we'll only be running our "pedal" off a battery, since the PCB will be embedded inside our guitar body).

But for anyone interested in making this pedal to run off a positive power supply, here are the amended files:

Fuzz Face revision 1c Schematic

Fuzz Face revision 1c PCB

And the amended silkscreen/layout is below.
The parts list remains the same as before - nothing has been added or removed, just the way the components are connected up has changed:

FuzzFace parts list

The FuzzFace (amended) design is relatively simple and has just a few components: 4 resistors, 3 capacitors, 2 PNP transistors, 1 DPDT switch (and a partridge in a pair tree).

R1 = 470 ohm resistor
R2 = 33K resistor
R3 = 8.2K resistor
R4 = 100K resistor
R5 = 500K potentiometer
R6 = 1K potentiometer
C1 = 0.01uF capacitor
C2 = 2.2uF capacitor
C3 = 20uF capacitor
Q1 = PNP transistor
Q2 = PNP transistor
SW = double pole, double throw (changeover) switch

Here's the silkscreen/layout for the earlier PCB :

Simple Tiny Fuzz Face pedal circuit

It's been nearly a month since we've done any nerding around at Nerd Towers. Unfortunately, it's just that time of year - when everyone else is easing into the New Year and starting again, we're going hell-for-leather trying to keep real-world work from overtaking us; January is a particularly busy month for us in the real-world, so hopefully now it's out of the way we can get back to to some serious geekery.....

Despite having numerous projects on the go at the minute, there's never a better time to drop everything and start a new project, than when you're already juggling about eight balls in the air. So here's our latest one.
In fact, it's quite a quick-and-easy project and took only an evening to put together.

As we're due to move again before too long, we've been sorting out the nerd cupboard(s) and having a bit of a clear out, to make sure everything will fit into the new place. In the corner of the cupboard are a few (full-sized) guitars which we just can't leave behind. But we've not done anything with them for about 18 months.

Maybe it's time we did:
One of the easiest (and most satisfying) mods to make to a guitar is to add some onboard electronics. After a quick hunt around on the 'net we found some schematics for the original FuzzFace stomp box and decided not only to have a go at building one ourselves, but to get the chisels out and actually embed it into the guitar body, with an onboard switch to flick between "clean" and "dirty" output.

Here's the schematic:

Fuzz Face revision 1b Schematic

And the PCB layout - with components placed as closely together as possible.
Note that the two potentiometers and the DPDT switch connect to three-way connectors on the board via short wires, they are not actually mounted onto the board!

Fuzz Face revision 1b Pcb
As ever, print this onto your press-n-peel as-is so that when it is transferred onto the copper board, it is reversed. This is fine, since you're etching the bottom of the PCB, not the top - don't panic, everything will just work out in the end!