Wednesday, 29 July 2015

Last Night In Zombieville - video production

It's of no surprise to regular readers that we're currently putting together an electronic board game, which includes playing piece tracking and an app for PC, tablets and smartphones. The idea is that we can use the same hardware for multiple games, covering multiple genres, and using lots of different rule sets.

On of our more ambitious ideas is the game "Last Night in Zombieville" - an interactive movie-based board game. Like interactive movies of the early nineties, we'll have a number of clips which are played in sequence, depending on the actions of the players.

So this weekend, a few of us hopped over to meet up with fellow nerds in Berlin for three days greenscreen video filming.

Andrea plays one of the hero characters who has the possibility of being turned into a zombie, so had twice as much work to do as the others! Here he is, playing the hero, waving around a big scary (replica) gun.

Sarah has been a make-up artist on quite a few independent horror/zombie movies (as well as being quite a proficient children's face-painter for festivals and parties) and made a great job of turning Andrea into one of the living dead.

The blood and gore were not only completely edible - being made from little more than summer fruits and food colouring - but, this being Berlin, we also completely organic and ethically sourced!

Right now, we've half-a-hard drive of video footage that needs some serious post-production to get it ready for adding to our game engine. There's enough to keep even a few of us busy for quite a while yet....

Monday, 13 July 2015

Getting jiggy with it (see what I did there?)

Using a jig and a stencil for applying solder paste has been quite a revelation for churning through our PCBs for the electronic board game sections - far more so than getting a rudimentary pick-n-place device working.

After just a few hours this evening, we had soldered and assembled a chain of eighteen boards for testing.

And with just one dry solder joint across all the boards, it was very encouraging indeed, to see each one responding the placement (and removal) of a magnet above each of the hall sensors

There are a few things come up with work today that may take a little time to resolve, so it's likely to be the weekend before we can get to the workshop and rout out some mdf boards to embed these in. But already things are looking very encouraging indeed. Can't wait to get a few sections daisy-chained together and actually see one of our board game apps responding to the  hardware for real!

Jig for SMT reflow soldering

After we got our PCBs and made a CNC pick-n-place machine from bits of junk, and created a solder-paste stencil from mylar, we were ready to start assembling our PCBs.

Except it's a multi-part operation. And one part was still a bit fiddly. Sure, getting the paste onto the boards was easy enough. And placing the components using our junk machine was quite painless (although quite a bit slower than we originally anticipated, thanks in part to the - relatively slow - speed of the geared scanner motor).

We even went crazy and bought a hot-air rework device to make soldering a bit easier (rather than have to hold each component exactly in place, we can blast it with hot air and let the paste pull the component into the correct position)

All this is fine for our surface mount components, that sit on top of the board. But we've also some hall sensors that not only sit on the board, but project out from the sides. And it's important that we place these so that their sensor parts are about 35mm apart (a few mm either side isn't critical).

Keeping the sensors raised while soldering the legs - particularly with a large hot air nozzle - while also ensuring they stayed the correct distance away from the PCB edge was proving tricky - so we decided to make a jig, to hold the board and the hall sensors during soldering.

In the fullness of time, we'd like to use a CNC mill and create the jig from some aluminium or similar material, but for now a few sheets of laser-cut mdf will suffice - at least to demonstrate whether the idea is worth pursuing or not.

The first - lower - layer contains slots for our PCBs to fit. This is cut from 2mm mdf (the boards are 1.6mm thick) and in the bottom of each slot we put some thick card so that the PCB is raised slightly. This means that the surface of the PCB is perfectly flush with the top of the mdf.

(the small rounded bits at the base of each pcb slot are to allow it to be easily lifted from the jig once soldered)

The top layer includes the pcb slots plus shapes that the hall sensors can be dropped into - ensuring that they are perfectly aligned with the connectors along the edges of each PCB, ready for hot-air soldering.

(a quick dry fit to make sure everything lines up)

Normally we'd just use some double-sided tape to stick our mdf pieces together, but since we're going to be subjecting this to some serious heat, it seemed sensible to use a generous amount of PVA to hold all the parts together. If the design proves successful, we'll probably invest in a slab of (soft) aluminium and have a go at routing the design on our CNC machine.

The final jig in use:

After trying the jig with a single board, we were very quickly soldering our PCBs in batches, up to ten at a time.

In practice, manually placing components with tweezers turned out to be quicker than using our junk-built cnc (and even worked out quicker/easier than manually placing using the vacuum pen). But the jig has proved invaluable for getting the hall sensors lined up and soldered in place quickly and easily.

Now all that remains is to embed them into the mdf panels that make up our electronic board game sections, and connect to one overall master controller. That's going to require a trip to the workshop, so for now, we'll just carry on soldering more of these PCBs up, until we can get down there!

Saturday, 11 July 2015

Creating a solder paste stencil with ExpressPCB and Inkscape

Having got a few hundred PCBs ordered from, it was time to think about how  we were going to solder these up when they arrived! Immediately, the obvious solution was to create some kind of solder mask.

We've tried making thin metal solder masks in the past with mixed success (the drinks-can etching approach didn't really work, whereas etching thin sheets of modeller's hobby brass using the same techniques as etching a PCB turned out quite nicely).

This time, we thought we'd try laser-cut mylar.

Creating a solder paste stencil from an ExpressPCB file is relatively easy - although it does involve a few steps, so pay attention: the first thing is to makes sure you have CutePDF installed. This great little program creates a "virtual printer" which allows you to create a PDF of just about any document that supports printing.

So in ExpressPCB, print the pads and silkscreen layer

Wait for the PDF to be generated, then open this in Inkscape. The first thing to notice is that the entire object is grouped - selected everything and click "ungroup" (ctrl +  shift + G) until there are no more groups in the selection. Now individually select the things we don't need - like the board outline, silkscreen shapes and text etc.

When you have only the pads remaining, select everything and remove the fill, while setting the stroke to 0.1mm. This should now show you the shape of your stencil-to-be.

With all of the pads still selected, choose Object -> Transform from the menu and set the scale to around 90%. This is because when cutting the mylar, we're allowing for the material to shrink back a little around the "burnt" edges. It's also creating a slightly-too-small-for-the-pad opening, so that each pad doesn't get fully flooded with solder paste.

It's important when re-scaling to apply the scale function to each object individually, not to the selected group as a whole (otherwise some of the pads will become out of line)

There are two ways to go forward from here. At first, we saved the document out as a DXF file, with polyline options. This makes the file compatible with most laser cutters (or even routers, if you're crazy enough to want to route this stencil from very fine metal - although you may want to reduce the pads even further, to allow for the thickness of the router cutting bit). This means we were (vector) cutting the lines from the mylar with our laser cutter.

It didn't really work - as the laser tried to outline each of the pads, the heat build-up caused the bits of plastic between the pads to simply disintegrate.

Instead, we printed our design to CutePDF, opened in Inkscrape, then exported as a bitmap at 600dpi. The result was a raster image that we could engrave, rather than cut. This gave a much nicer finish to the cut edges.

But even then, the finish was slightly off. It looked like the mylar was warping as the holes were being burned into it. So one last try, this time with a small piece of mylar taped to a piece of scrap mdf

This time the stencil looked just fine with very little sign of warping. When it came out of the laser, the holes lined up perfectly with the pads on the PCB.

Next we created a jig to hold our PCB, and a frame for the stencil/mylar to be mounted onto. Some locating holes ensure that the two line up properly during use.

Getting the stencil and the pcb to  line up with each other as well as the the alignment holes was a bit fiddly, but we got there in the end!

For some reason, our image contained a set of pads which are not actually on the manufactured PCB - so we're either using an old design, or a super-new one, including changes we've made since having these boards made up! Any paste deposited through these two holes on the right can simply be wiped off

The mylar film was fixed to the frame using good old fashioned double-sided tape, and a small amount of solder paste applied in a line across one edge. Using a bit of an old plastic from some food packaging, we swiped the solder paste over the face of the stencil, pushing it onto the PCB underneath

Whereas before it could take three or four minutes to apply solder paste to a board - with a pin or fine-tipped implement - it now takes just seconds. The end result isn't perfect - yet - but apparently, even with the best made, jet-cut, steel stencils, learning to apply the paste properly is something of a fine art.

Although the paste is a bit blobby around the hall sensor connector, the rest of the pads look just fine. It's much more precise than our current application method (which is to just lay a slug-trail of solder paste across all the pads anyway) so in the morning we'll place some components and give them the hot-air treatment, to see how the excess is handled.

Mylar film stencils are not as hardwearing as metal ones, but are generally good for about a hundred passes (maybe more). So, until we're churning out our PCBs by the hundred or thousands, this seems like an ideal way of creating stencils for applying solder paste to our prototype boards!

Friday, 10 July 2015

858D hot air rework station

I just took receipt of a hot air rework station from eBay. It's one of the 858D hot gun things with a choice of nozzles.

Jason has one and when I used it a while back, it was great fun.
But there's something about the packaging that suggests the graphic designer was keen to get away, for an early dart on a Friday, when he knocked this one out...

Tuesday, 7 July 2015

Building a pick-n-place machine from junk (flatbed scanner, dvd drive)

We've got some PCBs to solder up. A few hundred of the buggers. And, at the minute, they take aaaages. That's mostly because we haven't yet got a stencil for the solder paste, and the solder paste is quite old and not as fluid as it should be, so putting it down is like trying to glob jelly down with a pin - sometimes it sticks, sometimes not, sometimes it lifts off with the pin and so on. It's a nightmare!

But other than the solder paste application problem (which is to be solved now we've a nice stainless steel stencil on order) there's also the small issue of placing parts. Anyone who's ever done this with tweezers is probably familiar with the age old problems....

If you keep your 1206 resistors in nice, separated, pill boxes (or jewellers box compartments, or whatever you call them) there's a good chance that they don't all fall onto your desk the same way up! Picking resistors not only the right way up, but also the right way around (yes, we like all our numbers to be the same way around on a soldered-up board) can be a pain.

Then there's the issue of getting a dab of solder paste on the tip of your tweezers. Which acts like some kind of crazy kinetic-mind-melting glue, attracting all kinds of SMT components (and bits of fluff) from all over the desktop.

Once you've put the component down on the board, you have to remove the tweezers cleanly, without sneezing (or, more likely, twitching or shaking) as you remove them, unless you want to spend the next few minutes nudging the component back into it's desired position. Nudge a bit, no, too much, back a bit, no, back where it was.....

We've been saying for some time we need to make a pick-n-place machine.
The only thing is, they're pretty time consuming. What we really need is a quick hacked-up pick-n-place machine, made from junk that's just lying around, and can be quickly thrown together and made to work. Since our PCBs are only very narrow (100mm x just 14mm wide) there's even a case for making a one-time pick-n-place, just for this one job. After all, if it can be done quickly, and cheaply, then there's no harm in it being a single-job machine, rather than a generic device capable of handling lots of different boards (which it would need to be if we were going to spend any great money on it!)

It just so happened that we had an old flatbed scanner lying around, and a knackered DVD rom drive. Perfect for making a simple xy carriage!

Unusually our flatbed scanner had just one rail, straight down the centre, rather than a rail either side as we'd expected. No matter, this will just have to do for now.

The flatbed scanner was easily dismantled. At first we were just going to take the stepper and the belt from it, but then it occurred to us that the actual plastic frame may just make a good enough y axis for our pick-n-place - after all, it was a good enough y-axis for a scanner, taking in images at 1200dpi. It has a footprint of just over A4 (so quite small) but even if we only used one "half" of the bed (splitting it long-ways and adding a second rail along one side) there's still plenty of travel in the y-direction and enough width for the x-carriage made from a DVD rom drive.

After putting back the belt and carriage system, we very quickly had a working y-axis. The x-carriage would mount on the black plastic piece that the current belt system drives up and down along the 6mm stainless steel rod. The y-axis is actually quite nicely assembled, for such a cheap scanner.

The original scanning head was pulled along by a single 48 steps/rev (7.5 degree) stepper motor.

The underside looked very interesting - it's been geared down quite a bit. So this will be great for super-precise positioning. Our only concern is that it doesn't slow things down too much!

The linear rail is simply a polished stainless steel rod with a piece of plastic clipped over it. The toothed belt sits in part of the plastic that has been moulded to fit the teeth - no need for clamping here! The rod feels like it may have had silicon grease applied at some point in the past. It's not the best quality for a carriage assembly, but it moves smoothly (no binding) and there's no wiggle in it as it travels up and down - everything you could want from a linear rail system!

The tension is maintained in the belt by a simple spring-loaded, free spinning pulley on the far end (opposite the motor). The pulley is not toothed, so the belt just passes around it. The spring ensures that the belt is under tension, without putting it under too much strain.

For the x-axis we butchered a old, broken, DVD rom drive.
It doesn't have particularly fine resolution, but should be just about good enough for what we're needing; after all, our PCBs can withstand placement up to 0.5mm or more out-of-place. If we're going to place all our components and use either hot air or an over to "bake" the boards, any slight mis-alignment will be corrected as the solder paste melts anyway.

To get at the carriage, simply keep removing "layers" from the DVD rom drive (retaining any parts that might look useful along the way) until the optical head positioning assembly is accessible.

This part had actually been glued (presumably with some kind of epoxy) to the cast aluminium frame, so required a bit of "persuasion" to release it. Much to the relief of the other nerds, the hammers stayed locked away for this (though a selection flat-ended screwdrivers made for great levers to prise apart the different layers)

We kept the ribbon cable from the little stepper motor intact, but it's quite trivial to solder a couple of wires to the connection points on the top, if it should get damaged. We took off as much of the optical reader hardware as possible from our carriage, until we were left with very little

The optical reader assembly had some interesting bits, including some tiny little mirrors and this tiny - but functional - magnifying lens!

With the two assemblies dismantled, it was now a matter of trying to get the stepper motors to work independently, before we put everything back together and try running it as an actual xy cnc.
This meant putting together a test rig, with a PIC microcontroller (what else?) some L293D H-bridge IC chips (thanks for those Jason) and - just for fun - a 16x2 character LCD to report what was happening (and when the thing is finished, to display which component is being placed, and where)

Sure, it just looks like a tangle of wires (though Steve should be impressed that there are plenty of different colours, to distinguish between each part of the circuit, instead of our usual trick of wiring everything in green wire, then not knowing where to start when it comes to debugging!). Sure, it's just a microcontroller driving a couple of steppers (no Arduino copy-n-paste library code here though!). But it does demonstrate that we've got the basic control over an x and a y axis, both using jog buttons, and by sending "destination co-ordinates" over serial.

Originally it was tempting to just throw an Arduino at the h-bridge chips and get the motors spinning, but in the end we went with the big beefy 18F4550 PIC for a couple of reasons:
  • Arduino libraries are of variable quality. Most are ok. Some are quite clever. A few are shockingly poor. If there are any problems trying to run multiple things together (like receiving serial while maintaining two steppers, and servicing a servo, as well as responding to manual jog controls) eliminating the libraries is the first place to start - so why use them in the first place?
  • We're going to throw quite a bit of stuff at this, and also quite liked the idea of a character LCD to report back which component the device is picking, what it's target destination/co-ordinates are etc. This means we need quite a few pins.
  • Manual jog buttons (up/down/left/right plus a "jog-slowly" option) means lots of I/O pins are needed. Probably more than we could get from a '328 AVR without resorting to shift registers or IO expanders.

Even with a massive 40-pin chip, we used up a lot of IO lines:

A full explanation of the code and ideas behind it (including interrupt-driven, circular buffered serial receive) will follow in a later post. For now, here's a video of some very crude testing:

Although you might blink and miss it, there's also a simple ramp-down function as the carriage starts to approach it's destination point - you can see it in the first motor, as it slows to a stop, a hear a definite change in tone of the motor as the DVD carriage reaches the destination point.

Tuesday, 30 June 2015

Hall sensors and cascading shift registers

Having just taken receipt of a load of PCBs from, it was a nerve-wracking couple of hours as Nerd Towers until we found time to actually solder a few up and try them out.

There was nothing to be gained by testing just one (except, perhaps, to confirm that we hadn't done the usual trick of forgetting to connect all the ground connection points together!) since all the boards share a common latch and pulse pin, and data is supposed to be cascaded from one board to the next, via the serial clock and data pins.

The boards soldered up really quickly and easily - just smear some solder paste across the pads (in a sort-of "slug trail" across them, rather than messing about trying to put a dot on each one individually) then touch the pointy tip of a hot iron to rake out any excess between the legs. Same with the surface mount 1206 resistors - a touch of paste on the pads, place the component, touch with a hot iron, fixed. Each board took just a few minutes to complete (solder resist makes such a massive difference, compared to soldering home-made boards!)

The boards were then connected together using a bit of IDE ribbon cable (a bit of forward thinking and we might have set the connecting pins at 0.05" pitch instead of the standard 0.1" and using ribbons cable would have been a doddle).

Although it made us feel dirty, we put together a rough-and-ready, using an Arduino and the IDE serial monitor, to make sure that the boards were working as expected.

All the inputs on the PISO (parallel in, serial out) shift register are pulled high through onboard pull-up resistors. When a magnet is placed near each of the hall sensors, the appropriate shift register input is pulled to ground by the hall sensor.

(at the minute we're just spitting out the raw data from the shift registers as the input pins change, but it's a trivial matter to update the firmware to make it report much more user-friendly messages, like "board A square 2, piece placed" or "board B square 7, piece removed")

So when the device boots up, all inputs are reading 0xFF (255 in decimal)
Where in the video we see board A input value go to 251, this indicates that the input pattern on the shift register pins is now 11111011 (just from the binary value we can see that one sensor has been activated).

So whenever a playing piece (with a magnet in the base) is placed over a hall sensor, the input pin goes low. Similarly, when the piece is lifted away, the input pin goes high again (and in our example, the shift register input value returns to 0xFF - or 255 in decimal).

The important part of the testing here was not just to make sure that the hall sensors were working as expected (they were) but also to be able to distinguish between the inputs on each board piece - this is proven to be working, as the firmware correctly reports the input state on boards A and B only when their input pin values are changed. It's worth noting that, in the video, only board A is connected to the microcontroller - board B is connected to board A, cascading data via the shift register(s) on each board.

In short, a successful test.
It looks like we got the PCBs right after all!