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 (http://www.diy.com/departments/osb-3-board-th18mm-w1220mm-l2440mm/27593_BQ.prd)

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.