Saturday, 28 January 2017

Weather-proofing the bungalow workshop

With the roof and three out of the four walls on, and at least two days of rain forecast for the weekend, we had to act fast and get some plastic sheeting on, to protect the OSB3 outer skin.

The roof will eventually be clad in roofing felt (either charcoal mineral felt, or maybe strips of shingles - it depends on whether I can secure the shingles well enough to stop any driving wind from lifting them, as the roof pitch is only about 14 degrees).

But before any outer cladding goes on, we're covering the OSB3 with  DPM plastic, just to protect the wood, should any of the cladding come loose at any time in the future (plus, it buys me an extra couple of days to get  just the right sort of stuff delivered).

Under most of the beams secured to the floor, and at the bottom of every piece of OSB that comes into contact with any concrete structure (or anything that could possibly even potentially be a source of damp rising from the floor) we put strips of plastic. This plastic will be folded up and stapled to the walls, then an outer layer of plastic, from under the eaves to the bottom of the boards (covering the blue stuff) will be stapled on.

The roof took longer than expected to cover - making sure the plastic lay flat with no wrinkles or folds was a long, slow job; smoothing it out and stapling every half a metre or so. But the roof is now entirely water-tight.

Just got to make sure the walls are too.
Then when the (uPVC) cladding arrives, we'll be able to actually see it as a proper structure, not just large wooden box at the bottom of the garden!

Capacitive sensing using PIC microcontroller

We've been spending a lot of time with Arduinos in recent months. Which has been fun and quite interesting. But now we're back to prototyping some low-level ideas - and many of the libraries for Arduino either "work" or "don't work". There's little room for tweaking and customising - a lot of the functionality is encapsulated away - and once you get to the point where you're reading through someone else's (often quite poorly written) code, it's often quicker to write your own, from scratch!

One of the things we're looking at is detecting large bodies of liquid (ok, pint glasses filled with beer) for a fun experiment. It might turn into something, or it might just remain one on the ideas board. The first thing that springs to mind with detecting any kind of body of liquid is capacitive sensing.

We've done this in the past, using a "charge and count" digital input method (our touch-sensitive miniature guitars used this approach before we finally settled on the darlington multiplex idea instead, and very early prototypes of electronic Blood Bowl used the same, simple approach). The basic idea is to set a pin as an output, drive it high, turn it into an input and count how long it takes to drain; any addition capacitance added to the pin/pad will make it discharge more slowly and you can use this to detect the presence (or absence) of a finger.

In recent years Microchip have been promoting their mTouch technology but it's basically a variation on using two pins/ADC channels to create a voltage divider and using an analogue input to detect the presence (or absence) of an object. A great explanation of how it works can be found here.

The basic idea is:
  • The design uses at least two i/o pins (even if only one sensor is required, although the second pin can also be used as a sensor, if queried in sequence, so three sensors would require three pins, not four - it is only for one sensor you require more pins than you're testing)
  • Pin A is made a digital output and set high
  • Point the ADC to PinA (this causes the ADC to charge up)
  • Make Pin B (the sensor pin) a digital output and force low (set to ground)
  • Turn Pin B (the sensor pin) into input (TRISx = 1)
  • Point the ADC to PinB (the sensor line). While the ADC charge-and-hold capacitor retains charge, we've effectively created a voltage divider between Pin A and Pin B.
  • Begin ADC conversion
  • Read the values of ADRESH: ADRESL (10-bit analogue value)

This is why we need two pins for a single sensor (but there's no reason we can't swap them over and use PinA as the sensor and PinB as the ADC charge circuit if we need two sensors). When the ADC is pointing to PinA, it's held high and the internal charge-and-hold capacitor that makes up part of the analogue-to-digital circuitry is charged up to 5V (or whatever the supply voltage is).

The input pin is grounded (to put it into a known state) then made an input. When the ADC is pointed to the sensor pin, PinB, we now have the VC(hold) capacitor in parallel to the capacitance of the sensor. We also have a voltage divider - the VC(hold) capacitor is fully charged, and the sensor pad is at zero volts. The input pin reads an analogue value, somewhere between the two.

Any increase in capacitance at the "sensor side" of the voltage divider results in a lower analogue value on the input pin.

We take multiple samples and look for a relatively low or high value on the analogue input to determine whether or not there is extra capacitance (and therefore a larger body of liquid) on the sensor. Relative means we keep a rolling average and look for values that are noticeably larger or smaller than this average, to indicate an object being placed or removed from the sensor.

The overall code looks something like this.

Define CONFIG1 = 0x0804
Define CONFIG2 = 0x1dff

   Symbol tx = PORTA.0
   Symbol rx = PORTA.1
   ConfigPin tx = Output
   ConfigPin rx = Input

   Symbol pin_a = PORTA.4
   Symbol pin_b = PORTA.2
   Dim adc_value As Word
   Symbol pin_led = PORTB.6
   ConfigPin pin_led = Output
   Dim i As Byte
   Dim last_val As Word
   Dim val_diff As Word
   Dim trigger_threshold As Word
   OSCCON = 11110000b 'oscillator = 32mhz
   WaitMs 10
   APFCON0 = 11000100b 'APFCON

   trigger_threshold = 30

   Gosub readsensor_1
   'Serout tx, 9600, #adc_value, CrLf
   If adc_value > last_val Then
      val_diff = adc_value - last_val
      val_diff = last_val - adc_value
   If val_diff > trigger_threshold Then
      If adc_value > last_val Then
         'this is a rising edge (remove glass)
         Low pin_led
         'this is a rising edge (glass added)
         If last_val > 0 Then
            High pin_led
      last_val = adc_value
Goto loop


   'make pinA a digital output and set high
   ANSELA.4 = 0 'set to one for analogue, clear to zero for digital
   TRISA.4 = 0 'set to one for input, clear to zero for output
   High pin_a
   'point the ADC to pinA to allow the charge-and-hold capacitor
   'to start to charge up (RA4 is analogue channel 3)
   ADCON0 = 00001101b
   'make pinB a digital output and set low
   ANSELA.2 = 0 'set to one for analogue, clear to zero for digital
   TRISA.2 = 0 'set to one for input, clear to zero for output
   Low pin_b

   'wait for a bit
   WaitMs 1
   'turn pinB into an analogue input
   ANSELA.2 = 1 'set to one for analogue, clear to zero for digital
   TRISA.2 = 1 'set to one for input, clear to zero for output
   'point the ADC to pinB to complete the voltage divider effect
   '(RA2 is analogue channel 2)
   ADCON0 = 00001001b

   'read the ADC values
   Adcin 2, adc_value

And the result works like this

The capacitive sensing pad is just some Bare Electric conductive paint - so it's got a relatively high resistance. The reason we made the "trigger threshold" a variable is so that different pad materials could be used, as well as catering for different glass thickness and even different fluid types that might affect the overall capacitance.

Do J20 and beer have the same trigger points? Would using copper instead of carbon-power-and-gum make it more or less sensistive? We'll have to find out....

But so far, it's all looking quite positive. It's only a simple test, but it's encouraging to see that the trigger stays set even after you release the glass - but it's not so sensitive that it triggers if you just wave your hand over the sensor.

Friday, 27 January 2017

Bungalow workshop roof and skin going on

With the carcass complete, it was with great excitement we received our B&Q order for 9mm and 18mm OSB sheets (the big 8' x 4' ones). Now, of course, everyone immediately screams "you DIY noob, only idiots use retail outlets for building materials!" But I've yet to find anywhere that sells OSB sheets for less than B&Q sells them for.

Jewsons charge more than £22+VAT per sheet. Stamco are about £20 a sheet (plus VAT if I remember correctly). Even our new favourite building supplies store, Chandlers (at Hove Lagoon) want £18/sheet (again, I think you have to add VAT to those prices).
But at B&Q a sheet of 18mm 8'x4' (2440mm x 1220mm) costs just over £16. Strangely a 9mm sheet costs only slightly less at just under £15 per sheet. But if you buy enough of them, they'll even deliver to the door for free (on a whacking great big palette which we've already got designs on to use as a vertical planter, but that's for another day).

Now let's forget the cock-up they made with delivery dates (a single order of 9mm and 18mm boards was delivered over two days). Or, at least, forgive it. Because no sooner had the sheets been delivered, than we were dragging them through the house, to the back garden and throwing them up on top of the bungalow.

The roof has plenty of rafters at 300mm and 400mm centres, under the 18mm OSB roof, making it super-sturdy for walking on (this is going to be really useful to get at the apples on our enormous apple tree!)

The 18mm boards are for the roof, and the 9mm sheets for the walls. While the rain held off and the fog lifted this morning, it's been bitterly cold - making holding, lifting and carrying 8ft sheets around really hard work. Nevertheless, it only took a few hours to make serious progress on the outer skin.

Steve's matra might be "measure twice cut once".
I measure three times, cut once, cut it again, throw it out, start again, cut twice then patch up the gaps with any left over bits.

The "twin width" roof proved trickier than I expected. But we did manage to measure and cut the last remaining bit of roof before the sun went in and it got too cold to carry on (I just got a bit click-happy, taking photos before we had actually finished!).

With the roof and two sides done (two of the trickier sides too, with all that cutting and shaping around the top) the remaining two sides should be finished and ready by the weekend. Hopefully the rain will hold off until we've managed to get at least the first layer of waterproofing in place (before the final cladding goes on). Then we can move inside, put some insulation up and hopefully it'll be a bit easier working "indoors".

Wednesday, 25 January 2017

Light up Lego droids

Having a Lego R2-D2 and not making it light up - after getting Luke and Darth Vader to hold their own light-up lightsabres - seemed like a crime. So I ordered some tiny 0805 LEDs in red and blue. At first it was tempting to just make R2's eye lens light up. But that's not how he works. There's a little light just below the eye lens, that - in the movies - flashes red and blue.

So I figured I'd do that.

(the little black dot immediately under the eye lens was originally a red dot painted onto the head, which I drilled out with a 0.8mm PCB drill bit)

(the back of the head showing where the tiny hole was drilled - you can just about see if on the right hand side of the inside of the head)

But soldering two 0805 LEDs without bridging the terminals proved to be really really tricky. So I got some twin LEDs in a single 0805 package. If truth be told, these are probably more like 0806 or 0807 sized packages - they're ever-so-slightly wider than a regular 0805 component. But not by much. Not much at all!

This turned out to be an exercise in hand-soldering really little components. And not even doing it the easy way, with a pcb and a hotplate and solder paste (where you can just heat the whole lot up and let the surface tension of the solder simply pull everything into place).

This was spot-soldering onto pads half the usual width of an 0805 LED. In short, it was tricky. But, after a few goes (and uncrossing my eyes a couple of times) I managed to do it!

the whole assembly is really tiny - smaller than it appears in the photo because I had to place the LED closer to the camera lens than my fingers, in order to get it to focus

So with a single LED with three trailing wires, I can make either the red or the blue side light up (or both for a reddy-purpley colour). Which means that next time I'll be looking to put the smallest PIC I have available into R2D2's tummy to toggle between the two colours.

For now though, I need to do something that doesn't involve keeping my nose just an inch or so away from the end of my soldering iron!

(the components will be held in place with translucent hot glue, acting as a light tunnel, so both the red and blue sides of the LED will be allowed to shine out through the drilled hole)

Monday, 23 January 2017

Bungalow workshop carcass complete

It was with great joy and an oversized mug of tea we celebrated completing the bungalow carcass today. We lost a couple of days due to poor weather, but made up for it when the sun finally came out.

It was, of course, still icy cold - but not cold enough to stall progress. On the north-facing wall, our 1.4m wide double-opening window is now securely in place (and it still opens!)

The triumph of the day was getting the massive, heavy doors hung on the frame.

We were expecting all kinds of problems, from the frame not being square, to the doors not closing properly or maybe swinging open on their own (from the frame being installed at an angle). But none of it came to pass. The doors behave just like uPVC doors should. The open easily, close properly and when you turn the handles, lock together and make nice, tight seal against the frame.

(ok, in these photos, the uprights under the double windows haven't been fully installed - but they're in place now and everything is good and sturdy!)

After installing the doors, we finished putting the noggins in the back and side wall(s) and left the structure ready for cladding with it's first outer skin.

(more over-enthusiastic photo-taking, as the diagonal braces are not in on the "high" noggins in this photo)

Despite the freezing weather, it was a good days work (ok, allowing for brew breaks, a late start because of the overnight frost, and freezing fog in the morning, and finishing before it got dark around 5pm, it was more like a good four hours work).

The OSB sheets should be here soon and we can get the outer skin on!

Saturday, 21 January 2017

SD cards for microcontrollers

Getting SD cards that work consistently well with microcontrollers is pretty tricky these days. As users demand larger and larger volumes, the smaller, FAT16-compatible drives are becoming increasingly difficult to source.

Not that they're not out there.
Just that it's a bit of a minefield getting ones that work with a microcontroller - especially if it's for a pre-built module with slightly flaky firmware (I'm looking at you, WTV020 ad4 audio playback device!)

A few years ago, we built our own audio playback module. We documented quite extensively how to make SD cards work with a microcontroller. And just about every SD card pre-built module seems to work within the same parameters as ours:

FAT16 support means cards not bigger than 4Gb
Some Windows machines won't format 4Gb into less than 32kb clusters, so the actual maximum size is more like 2Gb.
A lot of 2Gb cards simply won't initialise in SPI mode, so stick to 1Gb max.
Most unbranded SD cards simply won't initialise in SPI mode - it's part of the SD card specification, but cheap suppliers sometimes don't support this backwards compatibility

We managed to snag a load of assorted SD cards off eBay - they worked out at less than a quid a go, so were pretty good value for money.

We freshly formatted each card, to use FAT16 and 16kb allocation units.

Except, of course, that not all of them worked in our audio playing device

(our device is not much more than an Arduino Pro Mini with a WTV020 sound module mounted directly on top of it)

Strangely, manufacturers that worked at smaller capacities didn't work at 512Mb. For example, when we first built the devices, we tried them out with an assortment of 128Mb and 256Mb SD cards. The only cards that consistently worked were Nokia and/or Sandisk branded.

Unbranded cards simply wouldn't initialise.
So we were surprised to find today that neither our Nokia 512Mb nor our Sandisk TransFlash 512Mb SD cards would boot up. But - strangely enough - unbranded cards (which ordinarily we'd avoid as they almost always fail to initialise) work perfectly.

Which goes to show - there's no rhyme or reason to which cards you should choose for your microcontroller projects. Don't just stick to one brand and assume the same manufacturers cards will work in a variety of different sizes/capacities. Similarly, don't assume that all unbranded disks will fail.

In short, you'll have to take a punt and hope you get lucky!

Friday, 20 January 2017

Bungalow workshop windows in

A few months back, we took the big bouncy van over to Kent and picked up some white pvc double patio doors and a large(ish) window for about a hundred quid. It was only when we got there,we were told the sale also included two upright windows (which had been fitted by the previous owner either side of their door frame).

So - after much deliberation - we decided to use them on the east-facing wall of the bungalow. It might make it look a bit weird from outside (as there'll be a worktop running along the inside, effectively cutting each window in half) but it also means plenty of natural daylight.

And, being east-facing, it'll get the early morning daylight but, in the summer months, shouldn't create too much of a greenhouse effect (since the sun is at it's hottest between around midday and 3pm by which time it won't be shining directly in through these windows).

We fixed the wooden framework around the sides of the window before placing it in the frame and screwing it to the existing structure. Neither of us had any idea if this is how your "supposed to do it" but it's a method that worked well for us. And the window feels good and solid, in it's new location.

We also got on with the back wall of the building, placing the necessary uprights (before it went dark, we managed to get a few diagonal support pieces in too). And the second window went in relatively painlessly too.

With the noggins in place, we're almost finished with the carcass of the structure. There are a couple of long rafters that need finalising and fixing in place, but we'll do those when we've the OSB3 sheets to put on the roof - which should allow us to position them to support any joins between the boards as necessary.

We've the large window to put in the north-facing wall, then the whole thing should be ready for the outer skin. Exciting indeed!

Wednesday, 18 January 2017

Microchip/AVR news

This arrived in my inbox yesterday.

Each time Microchip release news about (what is now) their AVR line, it's often met with suspicion by the long-term hardcore Arduino users. Many of the Arduino fan-boys baulked when it was suggested that Microchip might buy up Atmel. "It's all closed source" they shouted. "Microchip / Microsoft they even sound the same. Boooo. "

But Atmel never released an open source device; their IDE wasn't open. Their hardware wasn't open. The avr compiler was open source and the Arduino platform (which uses AVR chips) is open source. But there's a world of difference between AVR (the company/device line) and Arduino (the development platform).

Just as there's a world of difference between open source and free.
And, just like the hipsters who complained about Microchip not being open source, while running open-source Arduino on their not-so-open Apple MacBooks, it's easy to get the two confused.

But Microchip isn't the big evil baddie in all this. Microchip make great microcontrollers. Even better than AVR did. Some people have tried to argue that the AVR toolchain is "better" than that used by Microchip's PIC. Again, they're confusing AVR with Arduino.

Both AVR and PIC devices require you to use a programmer to "burn" the firmware to the chip. Arduino uses a bootloader, so that you don't need a dedicated programmer - you can upload new firmware over serial. And if you don't have a usb-to-serial device, some Arduino boards even have an onboard converter - meaning you can plug them straight into your computer with no additional hardware.

But this isn't AVR - this is the Arduino ecosystem. Microchip's PIC also supports bootloaders - you can also upload code to a PIC over serial. It's just that the tools to do so aren't necessarily free; the community support isn't there like it is with Arduino. But the tools exist. The toolchain for PIC is no different to AVR. Burning code to my PIC 18F series is no different to burning code to an ATMega via the AVR Studio IDE. Both require a programmer, both compile your code into a hex file, which you then upload to the microcontroller.

It's Arduino that makes things different.
In fact, I'd probably argue that the tools used with PICs are even better than those used with Arduino. Because the PICKit2 (not the three, that's horrible! but the PICKit2) has some extra useful little features built into it that aren't available with most AVR programmers - things like a built-in UART/serial tool.

You don't have to disconnect the programmer, then introduce a different serial device to talk to a PIC (as you would have to when programming an AVR over ICSP then sending data to/from it over serial). PICKit2 lets you use the same programmer as a UART/serial device.

But it gets better than that. Much better. And it's something that a lot of AVR users dismissed. Until they really needed it - then a few even admitted is was a good idea!

The PICKit2 has a built-in logic analyser.
Ok, so it's only got three channels. But if you work with SPI or I2C communications, being able to quickly and easily debug waveforms by seeing them on the screen, without having to unplug and hook up yet more hardware, is brilliant.

Microchip make great hardware.
We've banged on enough times about how much more robust PIC chips are to AVRs. With clamp diodes on their i/o ports, reverse polarity protection on supply lines and so on, they're almost indestructible. The same can't be said for AVR chips. Swap the power and ground on most atmega devices and they'll let the blue smoke quicker than you can say "is this adapter centre positive?"

There's no doubting that Arduino has made things much easier for a whole community of people to make cool and exciting new things. It's allowed people with limited technical ability to make electronics projects which would otherwise be impossible. And that's a great thing.

But booing Microchip for "changing the branding" of AVR is just silly. In their press release, Microchip even specifically mention their support for Arduino. Just think how great the Arduino ecosystem is for developers - it's the one area Microchip was lacking - but now how much better it could be with a really innovative hardware company behind it, making really cool tools and peripherals.

There are even Arduino projects on the 'net that use Microchip devices to make them work! A lot of Arduino-driven ethernet controllers and capacitive sensing modules are simply using Microchip PICs and exposing the data over a serial connection.

Wouldn't it be better for everyone if you could just put those peripherals onto an AVR device and program it using the familiar Arduino IDE? That's exactly what Microchip are doing!

In the mid 2000s - as Linux started to take hold in the marketplace - it became fashionable to knock Microsoft for their "closed" expensive almost-ubiquitous software. Microsoft became a by-word for "big, expensive, over-bloated" technology. They weren't cool and trendy like Apple. Microsoft were "old school".

In the hardware/microcontroller world, Microchip (and their PIC line of mcus) have tended to get the same treatment. They're not cool and groovy and open source and free. Learning to program a PIC means learning how stuff actually works, not just including a library or copy-and-pasting someone else's code. But - just as the detractors to Microsoft missed the very reason they were so successful in the first place - Microchip make great hardware. The make great peripherals. They stuff loads of stuff into their tiny little chips and make it really easy to do cool things like gesture detection in 3d space.

And now they're releasing new devices into the AVR/Arduino community too, things are looking very exciting indeed. There's no AVR/PIC divide any more. Thirty years ago, Spectrum and Commodore owners were as divided about which was "best" as they are today. But there's no division between PIC/AVR; they're becoming one and the same.

And this isn't to say that either is being diluted or compromised by the other - more like each is getting better because of the other's influence. So the next time Microchip send out a press release, I for one will be really pleased to see it drop into my inbox!

Tuesday, 17 January 2017

Bungalow workshop walls going in

After a few responses to previous posts, we made doubly sure of protecting the support beams of the bungalow from damp with some left over DPM plastic sheeting. Now, I'm pretty sure the plastic sheet under the concrete will act as a reasonable barrier against rising damp from the ground underneath.

But then again, the concrete is 4" thick but a good 6-7 inches deep in places, especially around the edges. It's quite possible that this could take a good soaking in a heavy downpour and retain moisture. So for the remaining beams to be bolted down to the floor, I made sure they sat on heavy duty plastic sheeting with sufficient left over to wrap up over the outer skin.

We've a 1m x 1.4m window to go in somewhere, and we decided that the north-facing wall would probably be the best place for it. Not simply because it'd be facing the house and looking over the rest of the garden (which is a bit of a bomb-site at the minute, but will be fabulous when it's been landscaped) but because the garden is south-facing, it's also something of a sun-trap.

We know from experience how hot a room can get with a south-facing window, so we've decided that the main window will be on the north wall and the two 2m windows (shown in the photo below) can go on the east-facing wall (the same side as the glass doors).

Hopefully this means I'll get the early morning sun which should be bright without being too hot. In the summer months, there should be no direct sunlight from the mid-day or late-afternoon sun (which is when it's at its hottest, here on the south coast of the UK).

The horizontal section is 75mm x 75mm, supported by the 47mm x 75mm timber (two-by-three for you old school types). This should be more than adequate to support the weight of the window. It's certainly strong enough to take my weight as I sat and dangled my legs over it - so the weight of a window is nothing in comparison!

With the horizontals in place along the floor and across the top, going from one upright post to the next, it was soon time to start building the back wall uprights.

A couple of diagonal braces really helped firm up the structure, making it good and solid with no wobble at all. Given that zero carpentry skills have gone into the building of the bungalow, it's surprisingly sturdy. I was expecting it to behave like an Ikea wardrobe - just about holding its shape but really only becoming fully rigid when the sheet/boards are fixed across the frame, tying everything together. But just the framework on its own is rock solid.

(the uprights along the back wall still need some noggins and diagonal braces and we'll be using these for fixing shelves and worktop to, so they need a little more planning yet)

As the light started to fade, the actual size of the bungalow was becoming apparent. And it's not small. At 5m long and just under 3m width (with a bit missing in one corner) it's within the maximum 15m2 area and under 2.4m high, so within the dimensions allowed for permitted development without extra planning permission. But stand inside and it feels pretty big.

Just before it got too dark to do any more, we doubled the number of rafters in the roof section so they're now less than 300mm centres - a bugger for cladding and fitting insulation, but if I'm going up there to collect apples, I want to know the roof can handle it!

Light up Lego continues

There's a very special little person having his fifth birthday in March, so there's a few weeks to finish this one. But then again, having a few weeks leadtime often means leaving it for a while and not worrying about even starting it, and before you know it, you're up til 3am the night before the deadline and nothing's quite working as it should....

But this is going to be a light-up Star Wars Lego set of characters. At first it seemed easy - stick some 0805 LEDs around the place, a few resistors, connect up power and ground and off you go. But as we started to put together our first character, things starting getting trickier.

Firstly, we can't just put power and ground - one up each leg - and hope that a 5-year old understands direct voltage polarity and why sometimes some things light up and sometimes they don't.

As we already had a blue light sabre, it made sense to start assembling Luke Skywalker. The first thing was to drill "up" the arm, from the wrist, towards the elbow.

Because of the bend in the arm (and because our drill bits are perfectly straight, not bent half-way along!) we couldn't get the channel to go perfectly from the wrist up to the shoulder (as we would have preferred). The best we could manage was to come out just below the shoulder joint

Which meant that this arm isn't going to move all that much (we might even glue it to the body just for good measure). And a matching hole had to be made where the arm meets the body, just under the shoulder socket.

We cleared out the body cavity (to make a little room for the sot-23 rectifier when it arrives)...

... and pushed the wires from the lightsabre up the wrist and out of the shoulder.

We then re-assembled the light sabre into the hand, the hand into the wrist and the arm into the socket. As this is a dry fit, we just left everything clicked into place. Eventually all of these pieces will be glued, to make the character much more robust (and hopefully more likely to stand up to the rigours of being played with by a five-year-old).

As there's no rectifier yet, we had to make sure to get the connections the right way around for testing.

Lego Luke and his blue light-up light sabre.

At first we thought connecting to pads in the feet (which in turn connect to the studs in the Lego) would be easy. But we'd forgotten that kids like to actually play with their toys, not treat them as fancy models to be admired. One thing that we definitely couldn't get away with (despite our protesting to the kids parents about how hard it would make the whole project) was simply gluing the legs on.

Kids want to sit their Lego characters down, put them inside Star Wars space ships and run around the room with them - not place them on a dedicated plinth and admire the technology and dodgy hand-soldering of tiny surface mount parts that make things light up. Which means we had to keep the pose-able legs.

As we only had one set of Luke Legs, we tried a couple of ideas out on some spare minifigs before hitting upon a solution with a left-over C3P0 (the pearlescent one, not the cool one with the ultra shiny chrome paintjob).

An example of "powered" Lego studs

When our Lego character is on a powered base, connection pads in the feet will make contact with metal studs pushed into the surface of the Lego bricks.

Running wires from the body into the legs at this point is easy. But when the character sits down, with the legs folded out in front, either the thin magnet wire will stretch (and possibly snap) or will get snagged up again when the legs are straightened out. What we decided on was tiny pins connecting the bottom of the body to the top of the legs, with any "loose" wire contained within the leg.

So we drilled a hole from the top of the "hips" (with the body part removed) into the tops of the legs. Then, put the character into a sitting position and drilled through the same point in the hips - this time into what would become the front of the legs, when the character stands up. Then simply cut away the excess between the two points

(this photo was taken after completing C3PO to demonstrate the technique on a different character)

The end result is a character with little slots in the front of their legs. It's a good job Lego Minifigs are so stylised that it doesn't really distract too much from the characterisation of the person it's supposed to represent.

When added to the character, we have legs that can still move from standing to sitting, while maintaining a short length of solid-core wire between the top of the leg and the base of the body

The leg is allowed to move without bending or stretching the solid core wire

We're still waiting on our rectifiers (Farnell have them on back-order, due around about the 19th/20th Jan) and pads for inside the feet. So it's difficult to build an entire character and try one out fully. But in the meantime, we've got a Darth Vader that needs a red LED light sabre, an Emperor wanting some edge-light acrylic cutting for his lightning-hands and a C3PO that needs wiring up to see if we can't make his eyes light up. So plenty to get on with for the rest of tonight at least....

Wednesday, 11 January 2017

Bungalow workshop build stage one

The bungalow is up to 3.3m wide at its widest point. Which means we need to use 3.5m lengths for the roof joists and they're not so easy to just pick up at the local merchants. While we're waiting to collect these from Wenban Smith, we've been getting on with the "smaller" half of the build.

Despite the bright sunshine, it remains bitterly cold - and the wood is still wet from standing outside in the rain - it's going to take a bit of drying out before we even think about putting an outer skin on!

The frame for the patio doors fits quite snugly (there'll be another piece strapped to the horizontal to fill the gap at the top). The final slope of the roof is now set (the roof joist will be a solid length, not that piece with the nasty join in it - that was only to get the angles right). We wanted a fairly flat roof, and to make it pretty solid and sturdy, so that it can be walked on in the Autumn (to collect the apples off the tree). Just check out how high that tree is! That's a 2.5m roof. I'm 6' 4" and I can only just reach the very lowest branches, even on my tippy-toes!

If nothing else, having the bungalow where it is means collecting the apples will be a doddle this year.

[EDIT: next day]

After checking the prices with various local suppliers, I found that Chandlers at Hove Lagoon couldn't be beaten on price (and quality). Their 3.6m rafters for the roof (75mm x 47mm or 3"x2" for you old-school types) are fully equalised (planed and rounded) and pressure treated for less than a fiver a length! That's less than the rough-cut 2.4m lengths from B&Q (which were £33 for 6) and substantially less than nearly twelve quid a length that Jewson wanted for their similar timber (though only 3.3m long not 3.6m). For almost all building supplies (including stuff I've already bought) they're cheaper than most other providers.

Though, for some reason, I can't find anyone selling OSB3 sheets (18mm thick) cheaper than B&Q (

Monday, 9 January 2017

Fixing the bungalow workshop uprights

The corner posts of the build were set into concrete before starting this project. But there are a couple of uprights that had to be added after the base was laid.

We used some heavy duty M10 anchor bolts to strap some 100mm x 100mm gate posts onto the concrete. These hold the post(s) pretty securely. But even with a load of strapping, holding a two-and-a-half metre length of 100mm x 100mm post perfectly vertically can put even the heaviest duty metal bracket under strain.

While it feels pretty solid, if I were to lean on the post, I could feel it shifting slightly. The wood remains straight, but the metal of the bracket, anchoring the post to the floor, can flex slightly. So, wherever possible, even when securely braced with metal brackets, I much prefer the security of a big grey slab to hold everything in place!

We used postcrete to hold the posts in place which goes off in about half an hour. Normally with postcrete - according to the usage instructions on the bag - you dig a hole then fill it a third full of water (the post and concrete mix go into the hole, with the powder added until all the water has been absorbed). This method has worked just fine for our fence posts in the past.

But because the shuttering (few bits of rotten fence panelling, crudely nailed together) wasn't water tight, we couldn't use this approach. So we added a layer of dry powder, then poured water over it. Then more dry mix on top and a splash more water, and then waited a little while to allow all the water to "sink through". Repeat until the shuttering is filled to a suitable level.

Although the instructions say the post should be fixed in 20-30 minutes, we left it overnight to ensure it was fully cured (working in temperatures of just 1-7 degrees means we're giving all our concrete much longer than usual, to go off fully).

The end result was a good, solid, rock-steady, perfectly vertical post. Although it's possible to push and pull the post about (with quite a bit of force) the base of the post is not moving away from vertical, it's just the wood, flexing along its length.

With all the uprights secured, it's time to get on with building the carcass!

Sunday, 8 January 2017

Laying out the bungalow workshop

It was a nasty, damp, misty day, as we started to lay out the bungalow carcass. The uprights along the line of the fence are concreted in already. The uprights standing on the concrete base are to be fixed securely using M10 anchors and fence post brackets.

To give an idea of size, each of the lengths of wood is 2.4m (before being cut down).
The 75mm x 75mm sections along the breezeblocks are strapped down using 200mm long nail plates (screwed not nailed) along the back, as well as bolted through the  wood, into the tops of the blocks (using M10 anchor bolts).

Freezing fog and mid-afternoon rain brought an early halt to the bungalow build. But it's quite exciting to get a feel for how it might take shape already.

Friday, 6 January 2017

Light up Lego

This Xmas, I was surrounded by friends and family and, inevitably, small children. Which meant Lego. Lots of Lego.

As a child in the late 70s and early 80s, I had barrels and barrels of Lego. But it was all plain blocks. There was the odd wheel. About the most exciting pieces were little windows. There was no such a thing as MiniFigs. And only the rich, posh kids at school had those specialist pieces (my friend up the road had not only the pieces to make an amazing double-decker bus, but the printed instructions too!)

This Christmas, Star Wars Lego seemed to be the toy of 2016 (ok, it's only last year that any toy could be the toy of 2016!) But loads of the kids had loads of Lego. And I was feeling a little bit left out.

So I thought I'd get some Lego.
And make it really cool.
Then give it away.

The first thing that sprung to mind was making a laser-cut Death Star (the genuine Lego version costs about £250 and - as much as I love my nieces and nephews - there's no way I'm paying that much for a toy for any of them). The playset could be made from interlocking pieces of mdf, with lego "plates" embedded in it (so their Star Wars Minifigs could stand up in it).

But after getting my hands on a Minifig Darth Vader (who, with a removable helmet, is already pretty cool) I thought "wouldn't it be cool if his light sabre, you know, lit up?"

Same for Obi Wan and Luke Skywalker.
Wouldn't it be cool if, as you plugged them onto the Lego board, their lightsabres would light up?

In theory, it could be relatively simple (although in practice, a little bit fiddly).
Simply put some contacts in the legs of the minifigs and some pins on the top of the Lego pieces. Connect all the pins on a diagonal to either power and ground.

If we put our minifig on the top-left corner of the board (above) we'd have power going up the left leg and ground on the right. But if it's plugged into the bottom-left corner, then ground would be on the left leg, and power on the right.

Luckily there's enough room (with a bit of hacking) inside the minifig body to put a small sot-23 sized full-wave rectifier

Now, if we connect the contacts in the legs to pins 2 and 3, it shouldn't matter which is power and which is ground - we should always get Vcc on pin 4 and ground on pin 1. Perfect for lighting up LEDs!

So now it's just a matter of choosing the right components.
At this stage, we're still not sure whether we'll be running the whole thing  off a power supply (at 5V) or a lipo battery (at 3.7V) or a couple of AA batteries (making up to 3V). Whichever supply voltage we end up using, we want to provide some inline protection for our (surface mount) LEDs, so we're looking at putting an SMT LED and an SMT resistor inside a Lego lightsabre.

A 1206 is ever-so-slightly too large to fit inside the end of a Lego lightsabre. True, we might be able to make some grooves with a knife or otherwise modify the plastic. But it's just possible....

.... that we can fit both an 0805 LED and an 0805 resistor (220ohm) stacked on top of each other, into the end of a lightsabre handle. And better still....

.... the blade part still fits!
Which means we need to get the magnifying glass out and do some super-fiddly soldering!
We set the two components at 90 degrees to each other. This allows us to solder two ends together easily, while keeping the other ends separate with little risk of accidentally bridging them with solder, when connecting the wires.

A 1mm hole up the length of the handle and a smaller, shallower 1mm hole at ninety degrees about half-way down provided a channel to thread some super-thin magnet wire.

All that was left was to wire the thing up, plug in and see how it looked. Here's the result of putting an 0806 blue LED in the end of a blue lightsabre.

Wow. Running straight off a lipo battery, the result was pretty impressive! So that's one light sabre down, another two to go (a green one for Luke Jedi and, of course, the red one for Darth Vader). Maybe there's even room to try making C3P0's eyes light up.....

I still need to drill Obi Wan's arm (for it is, indeed, his blue light sabre that's been wired up) and fit this into his hand and try to make a complete light-up minifig. But so far, the overall effect is pretty convincing.