NFC Login 2.1

image

This should be the final revision. Just a few minor tweaks. The regulator is now a TPS77533 rather than an incorrectly footprinted TPS77333. Corrected the bi-colour LED wiring. Move to a smaller 4MHz crystal for the USB side of things. Shrunk it a bit as I’m no longer expecting to find any PCB bugs. Dropped the 0.1″ pin header as the TagConnect worked fine.

The most obvious change is the small capacitive touch sensor PCB on the front. The previous version searches for a tag a couple of times a second. This works fine but I don’t like the idea of all the 13.56MHz EM noise pollution. This will poll for touch frequently and if it senses a touch it will poll for tags rapidly for a few seconds. In theory it could be more responsive too. Not had a chance to code this yet though.

There’s is also a Login NFC the way to another implantee. I’d recommend you check out Hans Peter’s embryonic.dk blog.

NFC login 2.0 finally working

image

It’s taken some time, but it’s finally working! It’s hard to debug when you don’t know what’s at fault.

  • Is it the PCB design? I’ve never done anything as complicated or as high frequency as this.
  • Is the the PCB manufacture? I decided to get the board made by DirtyPCBs rather than home etching, so at least that took one potential source of screw-up out of the equation.
  • Is it my soldering? I’ve never done anything as fine as the LQFP (larger chip) and QFN (smaller one on the right). They’re both 0.5mm pitch but at least the LQFP has pins that stick out rather than just metal patches on the edges of a square block.
  • Is it the design of the antenna? This is the work of the very talented Mathieu Stephan (from here) so probably not the weakest link.
  • Is it the firmware? I’ve had the code running on a MSP430F5529 LaunchPad, but I’ve switched down to a smaller F5510 and reassigned the pins.

Well, it took three tries – as you can see from the scribble on the board above. There’s a mistake around the TPS77333 voltage regulator which truned out to be a footprint error in the Eagle-supplied libraries. It’s now a bodged-in TPS77533. There’s another by the LED which I’ve had to swap for two separate ones rather than a red/green single package. My mistake on the pinout there.

It turns out the problem was the soldering of the QFN packaged TRF7970A. Buying a microscope helped me sort it out and it’s finally there! It’s finally working! There’s more to do, of course. I need to fix the mistakes. The software could be tidier. Version 2.1 will be perfect (probably). I’ll publish the design and code when it’s tidy, but in the mean time if anyone’s interested in any of it, let me know.

image

I laser cut a simple acrylic enclosure. It’s just black acrylic on the back – with some 5mm neodymium magnets press fitted into holes so it attaches firmly to my PC.
Some clear acrylic makes up the front so I can see the LEDs and the fruits of my labours. M3 nylon bolts go into threaded holes on the rear piece.

It’s been harder and slower than I expected but I’m very happy.

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

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.

Further PCB improvements

I’m glad to report I’m getting even better result with my PCB etching. Results do seem a bit up and down each time I get back to it but I feel I’m narrowing it down and getting more polished.

One. I’ve started using Ziplock vacuum bags to evenly press the transparency against the PCB. A really nice cheap substitute for a vacuum light box! I can thoroughly recommend them.

Etching underway

Etching underway

Two. I’m now able to get even better exposure with 3.5 minutes under the UV box rather than using the fluorescent tube. Maybe my developer solution used to be too strong. Maybe ditching the glass in favour of the Ziplock helped. Regardless, I’m getting a really good result. Here’s the partially etched board showing great definition.

Three. I got some Tin plating solution. No idea why I didn’t do this before, as it’s really easy and gives a great finish. The instruction say to carefully clean the copper with an abrasive. However, I assumed that as I’d just removed the etch resist from the copper with acetone and it had to be just about as clean as it could be. I popped it straight in the tinning solution before I got fingerprints all over it.

Etched and soldermasked board

Etched and soldermasked board

Milled, drilled and populated

Milled, drilled and populated

I had to mess something up and I removed the protective layer on the soldermask before exposing. Some of it dulled a little on contact with the transparency. Oh well. Otherwise I’m very happy. The ridiculously small negative text even came out a little. Here’s the board before drilling and populating. It a simple MSP430 based alarm for when my two year old son opens the front door. He can now just reach the handle.

When I’ve got it all sorted (and have tried the via rivets too) I think I might do a proper write-up.

Animated Lego Darth Vader build monitor

Darth Vader build monitor

Darth Vader build monitor

At work we use Continuous Integration to build and test our code as we check it in. It helps catc problems early and ensures we keep code standards up. We were using CruiseControl.NET but have now moved to TeamCity. Anyway, this is no use unless people take notice of broken builds and this was starting to slip. I decided that something fairly visible (but not too annoying) was needed. After spotting a Lego Dath Vader toy torch it seemed like a good solution.

The standard toy has a button on his chest that is used to switch on some while LEDs in his feet. There was also a red LED and a AAA battery in his lightsaber so it could be switched on. The plan was to add a servo to his arm so he could wave the lightsaber around and replace the red LED with a RGB one so that the colours could change. All of this under PC control of course.

Get out the Dremel

Get out the Dremel

Remove the battery connectors

Remove the battery connectors

Rather than describe in detail exactly what was needed, maybe some photos of the progress will sum it up. First I had to get a servo in place operating his right arm. It required cutting away the battery compartment, filing the joint to make it a little easier to move and hot-gluing the servo in place.

Make a slot for the servo horn

Make a slot for the servo horn

Make room for the servo

Make room for the servo

The front just involved making a bit more room to glue the servo in. The a slot needed to be carefully added for the servo horn to drive the arm. The horn was later screwed to the servo. The connection between the servo horn and teh shoulder joint is just a push fit.

For the lightsaber, the battery, connectors, original PCB and LED had to be removed. The switch was glued in place as it wasn’t to be used but needed to fill the hole. As ther was no PCB to locate the new LED, it was glued into place.

Finished arm

Finished arm

Finished saber and hand

Finished saber and hand

Running the 4 wires from the RGB LED involved carefully drilling a path through the side of the lightsaber, the hand, arm and shoulder joint. I had to be careful that the wires coming out of the shoulder didn’t limit the servo movement.

Closed up

Closed up

The next step was putting all this under PC control. I decided that the recently release MSP430F5529 Launchpad would make an ideal control system. It has built-in USB functionality and could easily handle a few PWM channels. All that was required was to connect ground, 5V and a PWM signal to the servo and 3 PWM signals to the channels of the LED. The photo also shows the clear acrylic base – cut using a 40W CO2 laser.

Darth-62-complete-controlleI intend to etch a small microcontroller board that will fit inside where the battery compartment was, but for the initial build uses the Launchpad externally, in a 3D printed enclosure.

The connection between the device and the PC is using a USB serial port. As far as what controls Darth Vader, I tried a number of options. Initial control was done from an ASP.NET MVC web page. Anyone in the office could control him with simple URLs like fredpc/Vader/Colour/Blue or fredpc/Vader/Position/0.

The connection to TeamCity proved a little more difficult. I started work on a Java plug-in for TeamCity that would call these URLs, but it was a pain to get the plug-in installed and working in TeamCity. All the documentation I could find was out of date and inconsistent – as is often the case with Java. So I went with a Windows service that polls TeamCity (using Rest APIs) every 10 minutes. Later, I realised that information like who is assigned to fix a build was missing from the APIs. Believe it or not the best solution I could find was to screen-scrape the HTML from the page used by the TeamCity Tray Notifier! I’m not impressed with the API side of TeamCity at all.

I you’d like to see it working, here are a couple of videos of it in action.

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

First etched surface mount PCB

Well, after experimenting with CNC milled PCBs I decided to give etched boards a ago. As I have a “UV exposure box” (i.e. a cheap eBay thing for drying dragons’ fingernails) for the soldermask, I decided to try photoresist board. Odd then, that I found this was far too stong for the PCBs. Even a minute would appear to give a good exposure when I started developing the, but it turned out to be so overexposed I stripped all the resist off the boards. An expensive way to end up with plain copper boards.

Etching the boards was also not as simple as I thought. Sodium Persulphate seemed useless. Using Freeic Chloride and a sponge seemed too rough for the delicate photoresist. Sloshing Ferric Chloride didn’t do much until I heated it up – by putting the containing (including PCB) in the microwave. Anyway, enough of my woes and failed attempts.

Image

PCB after etching

When I eventuallly got a combination that worked this is what I came up with. This is the board post-etch. It’s not quite as good as I hoped but definitely good enough for the MPS430 microcontroller (TSSOP) and the 0805 LEDs, resistors and capactiors.

ImageAnd this is the end result after applying the Dynamask 500 solder mask that I’ve used before.

I’m hoping I don’t ruin it when I come to try surface mount soldering…

PeeLight v1.1

The reason for my CNC mill conversion was to enable me to make my own home PCBs. I’d done a few tests but had yet to actually make one that I was going to use. I thought I’d start with something simple and upgrading the ugly stripboard I’d used for the PeeLight seemed an obvious choice – it’s small and only used a few through hole components.

Learning to use Eagle for PCB design took a little while. It’s not awful, but not the most intuitive piece of software either. I stuck with it because it seems a good choice if I later decide to send the design of to a fabrication house and have it done professionally.

PCB-gcode is an add-in for Eagle and also takes a while to get the best from. I found there was lots of trial and error regarding settings before I got the sort of result I wanted. There’s a trade off with the diameter of the mill to allow you to do some fine work. Too large a bit and the software knows it won’t fit between two tracks so it doesn’t try and the pads aren’t isolated at all. Too small and you may find that it tries loads of passes where you do want a bit more isolation. I also tried lying about the size of bit – especially when some pads had a 0.08mm gap between them and I only had a 1mm endmill.

Here’s the finished PCB. One thing I really like is how I can also cut out the board (including rounded corners), drill the component holes, drill any mounting holes and even engrave text with perfect alignment as it’s all done on the same machine without removing the workpiece. See if you can spot one mistake where I stopped the milling and tried to move the work without raising the tool.

Most people use a V-shaped engraving bit for PCB routing, but I had varied results this way. I’m fairly sure my problems were down to the way I was holding down the PCB. I clamped it at the edges using the clamps supplied with the mill. The problems were two fold. The fact that my PCB wasn’t completely flat caused varying cut widths. Any gaps under the PCB where the clamps had made it bow upwards meant that the rotation of the knife-shaped 2 flute cutter caused vibration and gave ragged edges in places. I did have some excellent results, especially on smaller pieces, but not consistently. Then I tried using a 0.5mm endmill and got a much better result. Any slight variation in cut depth didn’t cause variation in width. The vibration also seemed to go, or at least didn’t matter. I will try the engraving bits again, but this seems to suit me for now.

PeeLight

Background

My house is pretty dark at night – especially the bathroom. There isn’t a street light outside so if you get up for a pee in the middle of the night you can’t see a thing. And at my advancing age I do get up for a pee in the middle of the night! I’d found a very cheap MSP430 USB stick development kit on eBay and had got as far as setting the IDE and compiling “blinky”. I needed a simple project to force me to use it properly.

Then I noticed a nice MSP430-based PIR board – also on eBay. Olimex had made a nice board based on a TI example and it already flashed a LED when it sensed movement. Couple that with some dreadfully underpowered LED light that I had lying around and a light level sensor and I had the perfect starter project. It wasn’t too tricky but would force me to learn about the MSP430’s timers, interrupts and ADC. I can throughly recommend John Davies’s book if you’re embarking on a similar project.

The hardware

Most of the tricky stuff was done. All I had to do was add a LDR to measure light levels and a transistor to let me switch the LED. Along with a couple of resistors and a PP3 9V battery clip that was it. The 9v made the 12V LEDs (sealed units) even dimmer but that turned out to be perfect. The only tricky bit was working out what pins I could use from the MSP430. Olimex had broken out a 6-pin header intended for SPI communications. Out came the soldering iron and some stripboard. The header shown on the left of the photo mates to the 6-pin connector. The 2 pins on the top right match up with the 14-pin programming header. They’re not connected to anything but that was a convenient way to solidly mount the PIR sensor on the board. I’m afraid I don’t have a schematic for the design, but it’s pretty simple and I did create a schematic for v1.1 (to be added later).

Coding

The existing code was a great starting point. Both the hardware and software seem to be based on a TI reference design SLAA283 – Ultra-low Power Motion Detection using the MSP430F2013. They had a timer setup and this checked the PIR level via ADC. If it differed significantly then the LED was toggled. Nothign complicated but it covered the basics. I say basics – after being spoiled by the ease of programming on the Netduino just getting an ADC reading seemed like hard work! My code simply merged in a second ADC reading to check the light level and would switch the LED light on for a set period of time if there was movement and it was dark.

I’ll attach the code once I find out how best to attach/show a C source code file in WordPress.

Debugging

The coding was done in the Eclipse-based Code Composer Studio IDE. I managed to get a full version (including upgrade to version 5.0) for only $25 (rather than $450) after heading about a promotion for the Piccolo ControlSTICK over on 430h.com. TI often do great deals on their hardware. 430oh is a brilliant resource for MSP430 info.

To connect to the PIR board I used the emulation side of the EZ430-F2013 I already had. The PIR sensor used the same F2103 variant of the MSP430. The only tricky bit was connecting to that 0.05″ header. You can see in the photo that some iffy soldering and hot glue did the trick. To be honest a better way would have been to use a Launchpad. This amazing kit includes a programmer and 2 microcontrollers for an unbelievable $4.30 – and that includes international shipping. Details on how to use it as an external programmer are here.

The final product

Well, once it was complete the only thing left was to mount it neatly in the bathroom ceiling. I frequently final at the final hurdle of completing a project. Once the difficult stuff is done, I know I can do it and only the implementation remains I can lose interest. And to be honest this probably wouldn’t have been completed if my son Adam was born on time. This was done whilst my wife was overdue and waiting to be rushed into hospital.

I wanted to get it finished as I’d foolishly promised to enter a project in 43oh.com Project of the Month contest and posted about it here. I placed exactly where I expected to – i.e. last – but it was fun to enter. The guys on there really know their stuff and produce some great projects.

Weirdly enough my little project caught the imagination of Hack a Day, then Lifehacker – two sites which I tend to check almost daily. I’m under no illusion that it’s the toilet humour rather than the quality of my creation that was responsible for this, but it was nice all the same!

Version 1.1

I have since made version 1.1 which you can see here.