Philips Hue garden floodlight

So, after the initial teardown, it’s time to start the Philips Hue hacking. To be honest this is fairly simple so doesn’t really qualify as a hack. I said I’d start small and work up from there, so consider this a warm-up exercise.

I’ve got a motion sensing 10W LED floodlight mounted on my workshop. It’s supposed to light my way as I head out there but it doesn’t really work as I’d like. As I’m walking straight towards it the PIR only triggers when I’ve already trudged through the dark garden and I’m about a metre away. Also, the local foxes are constantly triggering it at night. Having this under Hue control would be ideal. Let’s take a look.

img_20161231_130126My Wicked brand floodlight contains a single chip LED which actually had 9 separate LEDs on the die. It has a constant current LED driver which outputs 350mA at about 24V. Hmmm – this could be very easy. They pretty much matches the Hue bulb I tore down. Electrically this might be as easy as connecting the spotlight’s LED in place of the Hue’s board. And you know what – it was! I did a quick check that the hue bulb circuitry was happy to dive the LED in the floodlight directly and then it was just a case of putting it all together. Out came the PIR sensor. Out came the constant current LED driver (the white box) and in went the Hue circuit board.

img_20170102_130311The only tricky bit was deciding where to put the PCB. Once the LED driver had gone, there was plenty of room behind the light. However, this was a metal case and the light is a fair distance away from the house. I didn’t think the Zigbee signal would reach. It didn’t have to be in the lamp at all of course, but it seemed neater.

I decided that the best place to put it was where the PIR has been. All it needed was a new 3D printed front cover. I could have saved space and printed a new back piece. I could have missed out the hinged bit and printed a two part case. My new Year’s resolution is to get project finished so I went with the simplest option.

img_20170102_131430So, here it is side by side with an original. Fitting was pretty easy. The only gotcha I has was that as i connected it, the Hue hub decided it would be a good time to update the firmware in the bulb. Hue bulbs normally switch on when first powered but whilst updating it was off. Cue some unnecessary checking of wiring, removing and remounting it, checking fuses, etc. Oh well, it working

 

NFC login (version 1.0)

After my experiments with NFC readers I felt it was time to actually create something useful to work with my NFC implant. At work I need to make sure that my PC is locked whenever I leave my desk. It’s not that I work with anything really sensitive, it’s just that given half a chance my colleagues will certainly send an email on my behalf admitting to unusual sexual inclinations or offering to buy everyone biscuits.

I decided the easiest way to do this was with keyboard emulation. It doesn’t require me to have any privileged domain access, modify the PC or install anything that compromises security. Plus, it should all be possible using a MSP430F5529.

The launchpad, booster pack and antenna.

The launchpad, booster pack and antenna.

My proof of concept involved a MSP430F5529 LaunchPad and a . I made sure that I could emulate a USB keyboard, implement a USB CDC serial port and read my tag id.

The USB side of things was adapted from some of TI’s example code. The NFC stuff was a little trickier. The Booster Pack is sold bundled with either the G2 or F5529 Launchpads. However the sample code is surprisingly complicated and only supplied for the MSP430G2553. Porting it over to the MSP430F5529 should have been fairly simple – just changes to some in assignment and clocking. It somehow took me ages but I managed it in the end. I must publish my ported code to save other people the same trouble.

I combined them all together to implement the following:

  • A USB CDC serial port allows me to set the password (but not read it). It’s stored in the microcontroller’s flash so persists when powered down.
  • Pressing one button on the launchpad send Windows-L to lock my PC. (Not actually easily accessible in its current form.)
  • It scans continuously for NFC tags and if it sees mine it sends Ctrl-Alt-Del{password}Enter

The 2 part 3D printed case for my NFC login

The 2 part 3D printed case for my NFC login

Hardware wise for version 1.0 I went with the setup from my previous including a DLP coil antenna and a cheap bit of U-FL to SMA cable from eBay. I don’t intend that the final version will be using a dev board and booster pack. It’ll be a custom etched PCB, but I decided to take the same approach as with Agile software development – produce a minimum viable product first and improve later. If I don’t ever get round to a nice neat version 2.0 then at least I can actually log in with my implant.

A view showing the installed boards and antenna

A view showing the installed boards and antenna

I 3D printed a case that allows the launchpad, booster pack and antenna to slot in. It comprises two parts that clip together and a couple of magnet to hold it firmly against the PC case on my desk. The case is 3mm thick but only 1mm thick by the antenna coil so it reads fairly easily.

OK, it just looks like a plain yellow box

OK, it just looks like a plain yellow box

The final version looks a little dull. It’s a plain box that was almost done in black, but I happened to have yellow filament in the printer. All that happens when I successfully scan my tag is that a red LED shows through the case for 5s whilst scanning is temporarily disabled and my PC unlocks.

I’ve got a little bit of tidying of the code before I include it. As it’s evolved from two different lots of sample code in different styles it’s a little bit messy. I’ll also attach the STL files for the case – designed once again in my 3D modelling package of choice OpenSCAD.

Source code (still messy) and STL files (under files folder) are now available at https://bitbucket.org/fredmurphy/public/src/127c1b2f26305bd8b2b2184084927da72457f9e5/LoginNFC/?at=master

CNC controller enclosure

Laser cut acrylic enclosure

Laser cut acrylic enclosure

I converted my Proxxon MF70 mill to CNC quite a while ago. When I was testing things out I wired up the PSU and controller board and just threw them in a Tupperware container so that nobody got electrocuted. It even had the lid open to allow the cables (including 240V mains supply) in. A temporary hack if ever there was one. You know how temporary hacks are though – they tend to stick around longer than intended.

Close up of the connectors for the axes, e-stop and LED

Close up of the connectors for the axes, e-stop and LED

Well, I finally got round to making a proper acrylic enclosure. I attempted to mill one ages ago, but struggled with the small working area on the MF70 and abandoned it. This one is laser cut. It’s held together with machine screw’s and has two shelves – one for the PSU and one for the TB6560 based stepper controller. I particularly like the rounded piece for the power LED and the hexagonal grid for venting.

I’d be happy to share the design files if anyone is interested, but I doubt anyone has exactly the same setup as me. I also altered things as I went, so I don’t have any “final” versions.

Laser improvements – coolant monitoring

One of the quickest ways to destroy a CO2 laser tube is to let it overheat. My laser has a very simple system – just a plastic breakfast cereal container of water with a small aquarium pump. It works well enough, but is easy to forget.

My first modification was to power the pump from the laser so that it’s running when the laser is switched on at the mains. That gets around the “oops, I forgot” problem, but doesn’t cover a pipe coming loose or the temperature creeping up. I really wanted to actually check cold(ish) water was flowing through the glass laser tube.

The water and temp sensor

The water and temp sensor

To check the flow, I started with a LM35DZ temperature sensor and a cheap water flow sensor from eBay. For neatness I carefully milled the flow sensor to embed the temperature sensor in it. This was then attached to the output of the laser. I intend to check that enough water is coming out and that it’s below a temperature threshold.

I etched a board with a MSP430G2533 microcontroller that counted the pulses from the flow sensor over a fixed timer period and used the onboard ADC to read the temperature. I set the threshold at 40C and 75% of the normal flow.

PCB with logic error

First PCB with logic error

My initial attempt used a MOSFET to pull the last signal down to GND if things were awry. Unfortunately this fired rather than disabled the laser! This was replaced with a 74LSxxx AND gate so I could force it to 5V and disable the active low signal. Some connectors to match the controller board meant I could drop it in with no rewiring.

The finshed PCB - with a fix for a lifted trace

The finshed PCB – with a fix for a lifted trace

So far it has been working well. (I actually finished this months ago but didn’t document it.) It’s not actually been needed to save my tube yet, but it’s nice to know it’s there. I might later and another sensor on the input and also flag if the difference between the two is too high. I could also add a cheap LCD display but that seems a little over the top.

Coolant monitor in the laser

Coolant monitor in the laser

As it’s a single sided board with some through hole pin headers, when it’s in place you only see the “boring” side of it with not tracks or components. Oh well – there’s no need for it to look pretty. Here it is in place. It’s a drop-in addition on the 6 pin cable to the controller board. It’s powered from the existing 5V line and simply forces the signal to fire the laser high (as it’s active low) when it senses trouble. From teh top you can see:

  • The connector to the sensor
  • A debugging / programming header
  • A currently unused connector for a screen
  • The connectors to patch into existing power and signals

If anyone wants a copy of the PCB layout or code, just ask.

CNC mill alignment camera (version 1.0)

Since switching from milling PCBs to etching them, one of the most awkward steps is getting accurate alignment for drilling and cutting out the boards. Mounting a camera on the spindle isn’t an original idea, but after sporting some tiny endoscope cameras on eBay (10mm dia, 40mm long) I thought I’d give it a go. A good excuse to use the new lathe too.

image

The design is pretty simple. I drilled out some  aluminium bar stock to 12mm, with one end slightly narrower and tapped to M12. Then I turned down a M12 bolt to for in the 3mm collet I use with my end mills. A slot at the top is for the USB cable and two sets of three nylon screws allow for accurate alignment.

image

As you can see, a Mach3 video plug in makes it very easy to set the origin on a PCB or other work. Unfortunately it’s a bit long so there’s only just enough room to use with flat stock. I considered mounting it to the side of the spindle (with a known offset) but that didn’t seem right. A more compact version 2.0 is already planned using just the guts of the camera.

Adjustable MSP430F5529 Launchpad enclosure

F5529 caseI’ve been working on a project using the MSP430F5529 – a really nice microcontroller with built-in USB functionality. The final product should get an etched board. However it has a whole Launchpad for now, so I thought I’d dust off the 3D printer and make a case. My favourite tool is still OpenSCAD so I came up with an adjustable enclosure. It should be easy to add any openings or custom bit if you want to.

 

Here’s what it’s being used for. More info on that later…WP_20131014_001

More laser improvements – safety

I’ve been making yet more improvements to my laser. Mainly because there are so many things that can be improved upon. This time it’s been mostly about safety. Probably wise after I managed to burn a hole in the back of my hand last week.

Operating the laser without the water pump running is a quick way to overheat the tube and kill it. As this is just plugged in separately it is hey easy to forget. And it uses up another valuable socket. I added two outlets to the back of the machine that are connected to the main power switch. If the laser is on then the water is on. Ditto the power for the exhaust fan – not as essential but might as well do that to. I was going to use a standard UK kettle style power outlet but as the supplied fan and pump have Chinese plugs and they’re the same as Us ones I just used US sockets from Maplin.

Whilst doing this I checked out the wiring and traced where the main be power was going. The colour scheme used was black for neutral (or sometimes live) and red for live (or sometimes neutral). Thin yellow wire for earth of course. The fan had these three wrong way round. And a connector strip mixed them up anyway. Astounding!

The final thing was a simple microswitch in series with the laser on switch the cuts the beam if the lid is open.

Next will be a water flow sensor in case the pump is unplugged or the tubing is blocked. Then a water temperature sensor. I could add an emergency stop and maybe even circuitry that kills the laser if the head isn’t moving. That should prevent it burning a hole if I forget to turn it off at the end of the gcode.

Laser improvements – an adjustable honeycomb table

One obvious thing when looking at the Chinese laser is that the table to hold the workpiece is an unnecessary spring loaded contraption that limits what you can work on to 209 X 88mm. Why? Removing it reveals enough space to add a table measuring 350 X 230mm. It’s easy enough to trim the end stops so that the laser head can cover this area too. So on to making a more useful lasering area!

Z table 2Z table 3I started with some 10mm L shaped aluminium, cut some 90 degree notches in it so it could be folded into a rectangle. I made up some corner pieces to hold it in shape. These were initially 3D printed but I ended up CNC milling them from 5mm acrylic instead. The L shaped slot held the aluminium frame firmly and hex cutouts underneath held some M6 nuts. Some coach bolts provided simple height adjustment.

It was all finished off using some aluminium honeycomb (6.4mm cells and 10mm thick) from Easy Composites.

In the future this could be motorised, but for now this is all I need to cleanly cut sheet material up to A4 in size.

First laser improvements – ditch Moshi

The great thing about the 40W Chinese lasers you can get on eBay is the price. For what you pay, the quality of the core components is surprisingly good. The laser tube and power supply are fine. The optics (mirrors and lens) are fine. It’s really only let down by the quality of the surrounding bits. Wires may be loose. Screws may be missing. Alignment may be off. The table to hold the workpiece is bizarrely small. The Moshidraw software is an abomination. However all this stuff can be change to turn your £500 laser into something you might have to pay 3-4 times the price for.

The first improvement to the laser had to be to ditch the Moshidraw controller board and software. I’d heard so many bad things about it that I decided to replace it straight away. I’m proud to say that I’ve never even installed Moshidraw.

ChrisCircuits boardI replace the board with one from ChrisCircuits. It’s basically a parallel port breakout with a couple of Pololu A4988 stepper drivers. However, Chris has done an excellent job sourcing the unusual connectors and making it a swift drop-in for the Moshiboard. There were a couple of tweak to be made to make his V1.1 board work in place of a V4.1 Moshiboard, but he documented these well and it was easy enough to do. Now I can conrol the laser using CamBam (for design) and Mach3 (for CNC control) and I’m right at home. This is the same toolchain I use with my CNC mill.

It wasn’t completely smooth. I was surprised to find a female connector on the board rather than the male on on my TB6560 mill controller. An annoying delay whlist I ordered a male-to-male DB25 cable. I also had to cut out a slot in the side of the machine that was big enough for the cable. The little USB opening wouldn’t cut it.

The X axis didn’t work at first but it turned out to be nothing more than a loose cable. I meticulously worked out how many steps per millimetre I needed by meausing the belt pitch, counting the teeth on the pulley and checking the microstep setting on the driver. I calculated it at ??. Way out. By measuring how much travel there was it turned out to be 79. Oh well. 79 it is. No idea why.

The only things that were missing from Chris’ installation instruction were on the homing settings. I had to tell it the the X axis homes in the negative direction and set the X and Y coordinates for the home position (0 and 220). I suspect I may have a different version of Mach3 to Chris. [To do – add details.]

Anyway, here’s the obligatory “first cuts” video.

Laser cutter dangers

OK. This bloody laser is trying to kill me.

Shortly after getting it I checked it over. It needs some water flowing through it to keep the glass laser tube cool and the tubing was kinked. So I decide to blow through it to ensure the thin flexible rubber tubing wasn’t blocked and the coolant would flow OK. I assume the tubes would be empty so I wasn’t expecting to blast a load of stagnant water out of the tube all over me. Yuck. Oh well. It seemed to work OK so I filled it up with clean water and some antifreeze and continued to test it out. I was pleased to find the tube and PSU in working order.

A week later I was struck down with a really dodgy stomach bug. My wife (a GP) checked me over for the usual things but the tests came up negative. I mentioned the stagnant Chinese pond water and she tested for a few more things you wouldn’t normally check for unless you’d been abroad. Bingo! It turns out my bloody laser had given me a nasty water-borne amoeba like gut parasite called giardia. Easily treated once I knew what it was but I felt shocking for a week.

Later on I was looking to fit a new Z table and wanted to measure how close the beam got to a bracket. I know! I’ll hold a piece of wood in place and quickly zap the laser to see where the burn mark is. What I forgot was the the beam doesn’t magically come out of the lens. It comes in from the left and bounces off a mirror. At least it would do if my hand wasn’t in the way. A few milliseconds of an unfocused beam was enough to make me think I’d got an electric shock. Until I smelt the burning flesh. Nothing too bad, but if that beam had been focused down to a point 0.1mm across it would be a different story.

image