Categories for Tutorials

Rastering Autocad 2016 designs on OSX

For my simpit i designed several backlit panels that i wanted to engrave using the lasercutter at our hackerspace. To print with this lasercutter, i need to export my drawings, save it on a network share and then run VisiCut on a laptop running some Linux distribution. Even though all the fonts and files are there, the export of the DXF loses all the fine details of the font and line thickness. This is probably because i’m a total n00b with AutoCad and VisiCut. Searching on the ‘net the only solution was to vectorise the image on a Window edition of AutoCad (because that comes with the awesome text tools that aren’t available on the Mac edition of AutoCad). I have no Windows machine so that is an absolute no-go.

However I found a workaround to get the 100% spot-on engraving option of my design.

The trick is to print the design to PDF in AutoCad and save the PDF as bitmap to get the proper DPI:

  • Select the layers you want to engrave, either through a WBLOCK or direct from your main design
  • print it as PDF. Make sure you print 1:1 and that you paper size is large enough.
  • Then, on the Mac, open the .PDF with Preview,
  • Crop the image
  • Save As PNG. This will allow you to set the DPI of the target image (be blunt and just set it to 1000dpi or something).

Now, to laser-engrave our design you need to make sure that the scale is exactly right. VisiCut is a little pesky about opening bitmaps, but what I do is I open the DXF of the design, and then IMPORT an additional layer with the pre-rasterized bitmap I just saved. With a little adjustment, you can overlay the PNG on the vector file. When the scale is absolutely spot on you can delete the vector file.

About that DIY keypad


This panel is part of a long-running project to build a simpit for Elite Dangerous. It is the keypad for the navigation computer that will replace the standard QWERTY keyboard, adding some nice features and a immersive design.

I made the panels and switches by painting transparant acrylic sheets with Humbrol modelling paint (comes in a small spray can). This paint is specially made for plastics, has very good adhesion and doesn’t melt when lasercutting. I have to paint several layers for it to become opaque (hold it against the light and check that no light bleeds through).

After the paint is done I can engrave the panels so that the white below the paint comes through.

The comes the engraving/cutting. All the panels we lasercut with the 40W lasercutter we have at my local hackerspace; i must have spent several hours sitting next to it by now! At first I wanted to make a proper PCB for the switches. But as this is a one-off prototype and PCB’s for this size are pretty expensive i tried to do it by hand. After designing the layout in AutoCAD 2016 I added several layers in my diagram:
1) switch solder panel (2mm,my alternative for the PCB)
2) support panel (actually wasn’t needed but it serves as a good standoff panel right now).
3) button panel (5mm thick creme transparent white with black paint)
4) button retaining panel (2mm white)
5) front panel (3mm thick creme transparent white with dark grey paint)

Because the buttons are 5mm and the front panel is only 3mm, the buttons stick out by 2mm which gives are nice glowing effect when they are lit.

Layer #4 is something that came up last-minute since my previous solution didn’t work. These are little plates that are glued to the backside of the buttons so they do not fall out. The buttons themselves are 13×13 (wider ones are 21×13) and the backplate is 15×15 to give them a 1mm border.

This all comes together in a stack. The distance from the pseudopcb to the buttons is fixed with a few stand-offs, but exactly high enough so that the spring tension of the switches pushes the buttons against the front plate without actually making contact. These tact switches have only 0.5mm travel.



Load of wiring because of the LEDS and the Switches






Sorting the buttons


Button back side



DIY Solder Paste Stencils with a Lasercutter

I recently joined a hackerspace and they have some awesome equipment. One of the machines is a 40W laser cutter. I thought it was time for some experimentation!

For my Simplyduino project I needed a new solder paste stencil because the previous one I ordered at OSH Stencils (these guys offer excellent service!)  is missing a few holes for the components I added with PCB version 1.07. While those 3 extra components are very easy to solder by hand I didn’t want to spend any more more on a stencil. I read quite a few articles on the net on the subject of laser cutting your stencils and here’s my formula.

After a few experimental runs, this is my end result, and I am very happy with it:


There are a little burning marks on the stencil, that’s all!

Configure the cream layer in eagle


Export as DXF

First go to layer settings and disable all but the tCream layer. Then go to file > export > DXF..



The important setting is ‘Fill Area’ which automatically forces the ‘Use line widths’.


Opening the file in VisiCut

Our lasercutter uses VisiCut as a printer software and I figure out that tool allows me to open .DXF files directly without the fuzz of converting it to PDF or SVG first. Another advantage is that the dimensions of the pcb are not lost, saving me a lot of time aligning the stencil.


After positioning, go to Mapping en select ‘Engrave All‘. Edit the details of the mapping and change the resolution to 1200 DPI.  Finally, go to Laser Settings and select power 30 and speed 100. These settings work perfectly for me. I used 125micron Mylar sheets available from


Commercial (zooming in on the 8 pins of a ATMega328p-au)


My results


With some minor tweaking thing may get even better.


Check the photo below for solder paste applied to the board with the above DIY stencil. I shot the photo at an angle so you can see the height of the paste applied.  This close up I notice a tiny alignment shift which is entirely my fault, not the stencil!


After assembly, this looks like this:

IMG_1364(I needed a little rework on the ATMega pins near C2, that kind of messed up the shot )




How to monitor your Synology NAS Health DIY-Style

While working on my Sensorium monitoring website for the Sensoduino, it occurred to me that i can monitor much more than just the plant moisture level. Why not (ab)use the system for monitoring the server health?


Block undefined properties on PHP classes

Coming from C#, I am not really used to being able to define properties on the fly. In C# you have to declare basically everything. Not in PHP. You can define a class and do whatever you want with it. Explicitly declaring a property actually has very little use. For example, the following is perfectly legal.

class MyObject

$obj = new MyObject();
$obj->Username = "John Doe";

Now i’m a bit of a strange guy, and I actually DON’T want this behaviour on my framework classes. What I would like is a compiler-time error like ‘Undefined Property’, but since PHP isn’t compiled that gets slightly difficult. Instead, I came up with the following concept called a trait:

trait SolidObject
        //this is a guard to block undefined variables.
        public function __get($name)
                if(!property_exists($this, $name))
                        throw new UndefinedPropertyException(get_class($this).'.'.$name);

        public function __set($name, $value)
                throw new UndefinedPropertyException(get_class($this).'.'.$name);

Normally, when an undeclared property is used, the PHP engine calls the __get or __set method on a class. PHP allows you to override these methods (Basically it blocks all access to a __get, i don’t even think the property_exists is necessary) But instead of having to extend from a base class they have a thing called ‘traits’. Traits are comparable to extension classes like you have in C#, Swift and Objective C.

Here’s an example on how to use it:

class MyObject
   use SolidObject;

$obj = new MyObject();
$obj->Username = "John Doe"; 

Now if you run this, the code will throw an exception at runtime, which is good enough for me.

Notice that unlike properties, access to undefined variables can be blocked by including the E_STRICT flag on the error_reporting call, or simply use E_ALL like this:


Perhaps a future version of PHP will allow typed variables and properties for even more goodness.


Sending mail using PHP templates

For the Sensoduino monitor website ‘Sensorium’ i’ve implemented email notifications. These HTML message are sent whenever a trigger is activated. To avoid endless prototyping I wanted to use the php engine itself to come up with the email.


I made a php page named ‘NotificationTemplate.php’ and added some code to fill a few default variables. Also, the template includes shared header and footer file to allow the mail template to be reused.


require_once __DIR__.'/../config.php';

        class dummyData
                public $TriggerID = "X";
                public $SensorDescription = "[SENSOR NAME]";
                public $Threshold = "[THRESHOLD]";
                public $MetricDescription = "[METRIC NAME]";

        $triggerInfo = new dummyTrigger();
        $active = true;
        $triggerType = "[IS ABOVE]";

$url = HOME_URL . '/notifications.php';

include 'MailHeader.php';

The sensor <b><?php echo $triggerInfo->SensorDescription; ?></b> has reported that the <b><?php echo $triggerInfo->MetricDescription;?></b> <?php echo $triggerType;?> <?php echo $triggerInfo->Threshold; ?>.

include 'MailFooter.php';


To use this template, it needs to be ‘rendered’. Below is a fragment from my ‘sendNotification’ method that initialises a few variables and renders the above template file to a string:

$logoImageSrc = "cid:logo_sensorium";
$poweredByImageSrc = "cid:logo_powered";

//construct the message by loading running a template
require 'Templates/NotificationTemplate.php';
$message = ob_get_contents();


The $logoImageSrc variable is used to switch between inline image attachments. As you can see in the template it is given a default if $triggerInfo was not defined.

This way the message can be preview in the browser by directly opening the php file in Safari. I am still figuring out a way to automatically convert the inline images to attachment because it will clean up the code.

Now that we have the messagebody captured in $message, we can easily send the mail by the php mail() method, or even better use phpMailer.

Deleting photos in iPhoto

When you are browsing an iPhoto album and press `delete`, the picture is not deleted, but only removed from the album. This isn’t really helpful when you are trying to prune your photo albums.  Instead, you’d have to flag the photo, move to events or photos, find the flagged photo’s, and press delete again (simply selecting flagged doesn’t cut it). This is very tedious.

But I found the solution:


Block anonymous users on Photo Station 6

Synology’s photo station is a nice app, but there’s no way to block unauthenticated users out of the box. A simple patch will help this. What the patch does, is present an authentication dialog box on the default page when the user is not authenticated. Very effective and no messing around with redirect url’s. To apply the patch, go to /volume1/@appstore/PhotoStation/Photo/  and edit index.php . You’ll probably have to SSH in as root to be able to write the file.

vi /volume1/@appstore/PhotoStation/photo/index.php

Then scroll down a little where you find the end of the php header (just before the DOCTYPE), and insert the following code:


if (GetLoginUsername() === 'Guest')
    include 'login.php';     

 A bit of warning though. You just patched an file from the original distribution. You will probably need to apply the patch again after an update has been applied. This would cause your albums to become visible if your security wasn’t tight.

Good luck.

Using AppleDoc to generate Xcode help (Part 1)

PLEASE NOTE: This article was written for XCode 4.6.3 and may be outdated on some parts. See the AppleDoc issue tracker on github for more info.

While developing SimplyStats I had to learn a lot of new stuff, and having integrated help certainly helps in those situations. Apple’s Xcode comes with a good set of documentation for all its classes, and can be accessed right from your code. To look up a keyword, just opt-click and you’ll get all the information you need (now if somebody integrates queries in the IDE he’d be my hero).

Wouldn’t it be cool if that was possible for your own static libraries? Well you can! In these days and ages of open source and community development it’s not a strange thing that others will use your excellent coding efforts, so providing a descent help set will certainly be appreciated.The help system for Xcode is called a ‘documentation set’ (or docset for short). Constructing a docset manually is a hell of a job. Nobody wants to construct XML files and references by hand. Fortunately there are quite a few (free!) tools that can extract comments from your code and translate them into neat docsets. There’s appledoc, doxygen and headerdoc just to name a few. I decided to go for appledoc for its simplicity.In this tutorial i will explain the steps necessary to get your code documentation up and running. This is part 1 about installing appledoc and configuration a build target. In part 2 i will explain more about the options and documentation syntax.