Skip to content

New House – new workshop

July 7, 2014

I’ve been a little quiet on the blog for a little while, because we’ve been in the process of moving house. Lots of packing and worrying about logistics etc.
Of course the biggest question mark was the moving of the workshop!


View from our new bedroom

Well now we’re finally in. The new house is amazing, and we’ve had a super sunny first week to really enjoy the new area we’re living in. One of the attractions of the house is that actually it needs redecorating throughout, so we still have boxes everywhere and a daunting task ahead to figure out what to do first and what exactly it is we want to do in every room.

The process of moving was, as always, massively frustrating and fraught with stress. Every time I go through it I wind up feeling two things strongly.
1) I’m never going to move again.
2) The whole industry of estate agents and solicitors is ripe to be completely revolutionised and swept away with maybe one big player intent to make it a modern process.

The first is fairly simple, and I really do not have any intention of moving again at this point. This house is perfect, and it was good enough for the previous owners to live in for 30 years, I consider that a challenge and am aiming to beat their high score.

The second always fades as I realise that I’m not planning on moving again. which I guess is what everyone does which is why it is still a horrific experience to try buying a house and why solicitors and estate agents get to operate as if the internet age essentially hasn’t happened.
There is really no excuse as to why initial introduction with solicitor doesn’t involve agreeing on a secure online form of communication which subsequently allows you to authorise all documents electronically. no need to post bits of dead tree around with ‘wet ink’ on them. Right there you could wipe a few weeks off the process.

If you are in any way inclined in the space of solicitors/conveyancing I really think the market is wide open for you to totally dominate the house moving market. I wish someone would, but that someone will not be me.

I am now just really happy to know I no longer have to deal with estate agents, with the small exception of recovering what I can of my deposit on the rental we moved out of. I sold off the house I was renting a while ago, but now I live in my own house again I really feel the full force of no more random calls with urgent repairs required by my tenant, and no more having to go through a lazy, inefficient estate agency to get anything fixed in my own property.

Just as moving out the workshop was a big consideration, now that we’re in, a big consideration is that I am once again faced with the chance to design my workshop layout. Last time I had restrictions of not bolting anything to the walls, since I was only renting. This time I can hopefully give myself much more decent bench space. Also last time I decided to put my lathe in the middle of the space, I felt previously I’d been a little restricted having it bolted to a wall particularly trying to hollow items. The swing of the tool would clash with the wall. However I think I really just need to give it a little more space out from the wall, it doesn’t need to be in the middle taking up more space. Of course this time around I know that I want to rebuild my cnc machine, so I will have to allot space in the plan for that. And  consider if I’m going to aim for a slightly larger build for this iteration.

There is so much to do in the workshop that I need to remember that first there are other priorities in the house itself. There may come a point of chicken and egg, there are good reasons to get some of the rooms in the house done first, however doing them will require tools which are currently buried in boxes in the garage, so may necessitate a certain amount of workshop sorting to get at them.

So, where to start? we have walls to strip of wallpaper, carpet to rip up and replace with various flooring, bathrooms to replace, a window we’d like to turn into a door,  a kitchen to replace, a fireplace to remodel, a workshop to set up…
Any tips or tricks I should consider? pitfalls to look out for? let me know!

Pan and tilt webcam – face tracking

May 10, 2014

So last week I wrote about building a pan and tilt webcam, and at the end of that I mentioned that the next thing was to come up with some kind of software control on the pc to allow it to be easily moved around.
This is a little google auto-awesome montage of how well things went

Software –
I wound up checking out after watching a video from SVSeeker that showed them using the same to control their in-development under water ROV.

I was very impressed by how easy everything was to pull together, over the course of perhaps 3 hours I achieved everything I set out to do.
I downloaded the environment and started to play.

First thing was to alter the interaction to the arduino based on some examples of a state machine interaction to select options. so you can just send a string of numbers divided by slashes, so for instance /3/2/9/170/, is interpreted as 3rd top level option (servo control), 2nd control within servo control, (write a value), use pin 9, set value 170. This immediately made things more flexible.

Capturing video from webcam

Second job was to get the camera feed from the webcam, this was straight forward with the video library, just get a list of connected webcams as an array, not that within this is an enumeration of the various resolutions and frame rates supported by each camera. For me I gout about 40 options, 20 for the webcam on the laptop I was using, and 20 for the external webcam mounted to my pan/tilt. I did think about putting a picker in to allow dynamic selection, but to get going I just hard coded the number of the one I wanted to use.

void setup(){
    String[] cameras = Capture.list();
    if (cameras.length == 0) {
        println("There are no cameras available for capture.");
    } else {
        println("Available cameras:");
        for (int i = 0; i < cameras.length; i++) {
            println(i + ":" +cameras[i]);
        // For the moment hardcoded to the one I know I want
        cam = new Capture(this, cameras[21]);

void draw() {
    boolean faceDetect=false;
    background(0);  // background black
    if (cam.available() == true) {;
    image(cam, 0, 0);

Manual control

Next job was to put some controls on the screen, I found the ControlP5 library that provided a bunch of simple controls, each one you can just add specifying the name of the control, the range of values it should control and the deafult you want it to start at. Along with simple x,y and width,height values for placing the control.
Once added controls being moved triggers events to a handler method, just look up the name of the control in the event name and act accordingly.

tilt = controlP5.addSlider("Tilt",tiltMin,tiltMax,60,10,10,10,400);
pan= controlP5.addSlider("Pan",panMin,panMax,90,50,10,400,10);

So in a jiffy I had two sliders, one for the tilt control up the left side of the screen and one for the pan across the top. a little wiring up and now I can click around the controls on the screen and move my pan and tilt. Hurrah!

void controlEvent(ControlEvent theEvent) {
    if(theEvent.isController()) {
        if(theEvent.controller().name()=="Tilt") {
        if(theEvent.controller().name()=="Pan") {
            panValue = round(theEvent.controller().value());

At this point I had basically done what I really though I was going to do and it had taken very little time. So I started to get creative with other features I could add.

Auto Pan

First thought was that it would be cool to have an auto-pan mode where it will just sweep back and forth based on some value to set how quickly it should do so. I decided to set it as another slider which sets how many seconds between individual increments of turn, so the fastest it will turn is one increment every 1 second, and the slowest would be really slow, 1 increment every 5 minutes. To control this I added a toggle button, and another slider to set the value. I considered here using an input box to allow any number to be set, but I quite like the interaction being entirely mouse driven with no keyboard input. plus no need to validate inputs etc.

if (autopan){
    //check when last move made
    if (millis() > lastMove+(moveDelay*1000)){
        println("Auto-move step");
            if (panValue160){
    //this line triggers the event handler which in turn writes to the arduino

To make this work I just keep track of when I last moved, and every time through the draw loop check the amount of time passed since that last movement, once I go over the set value I move again and set that as the last movement point. There is a little extra complexity which is which direction you’re travelling. I decided to keep it simple, always start out panning left, then when you get to the max value, flip a direction boolean and start heading right, until you hit the min value, flip again and repeat forever.

This worked nicely and immediately led to the obvious next option… take time lapse images. This is another set of controls very similar to the auto-pan. I want a value to set how often to take a picture, and a toggle to switch that mode on and off.


From an implementation point of view it turns out to be very simple to get a frame of the video as an image. There is even a mode that will auto-increment filenames for you, however I found it was using some internal frame counter such that whilst the filenames did increment in order, they were not sequential numbers. This caused problems for the app I downloaded to stitch images together into a little video so I decided to just keep track of my own frame counter. Plus a little logic to handle creating different folders every time you switch the mode on so they don’t overwrite each other.

if (timelapse){
    if (millis() > lastCapture+captureDelay*1000){
        //take picture to be stitched later

Again so simple that I realised I still had plenty of time to carry on and this is when I got ambitious…face tracking.

Face detection

I’ve seen this kind of thing on youtube so it is hardly novel, however it is pretty freakin’ cool so I guess it was inevitable to try it. Going in I had no idea how hard it might be handling face tracking, and O.M.G. this stuff is so easy now as to be ridiculous.

Library – opencv. this library existed and was easily available to download from within the interface. Import the library, create the object and tell it you want the face identification mode (it seems like it has a few options for doing thinigs like filtering out moving objects from an otherwise stationary scene) Then just pass it frames from your video feed. In return it passes back an array of detected face objects. Its empty if it can’t find any.
For each face in the array you basically get given the bounding box within which the face exists. So x,y of the top left corner and width,height.
By iterating through the array looking for the ‘widest’ face you get a proxy for the closest face.

if (cam.available() == true) {;
Rectangle[] faces = opencv.detect();
int closestFace=0;
int widestFace=0;
faceRectH=0;//use width as proxy for closeness, pick the one which is widest and follow it.
for (int i = 0; i  widestFace){

if(faces.length >=closestFace+1){
//draw frame from webcam
image(cam, 0, 0);
//draw rectangle at co-ordinates for face
stroke(0, 255, 0);
rect(faceRectX, faceRectY, faceRectW, faceRectH);

So that was impossibly straight forwards, by using those values to draw a rectangle you can visually see on the screen where it has recognised faces.
That alone is crazily cool, when you think about what must be involved in detecting faces from an image.

Face Tracking

But once I have this information turning it into tracking controls is pretty easy. Basically I want to put the face in roughly the middle of the the screen. So I figure out the middle of the bounding box of the ‘closest’ face, then determine how far off centre on the x and y planes that is.
Anything outside of about 20 pixels of centre and I send a command to the arduino to pan or tilt in the appropriate direction to shift the face closer to centre.

if (faceTracking){
    int xpos = faces[closestFace].x + (faces[closestFace].width/2);
    int ypos = faces[closestFace].y + (faces[closestFace].height/2);
    if (xpos<(width/2) -10){
        //move camera slightly left
        if (panValue(width/2)+10){
        if (panValue>panMin){
    if (ypos<(height/2) -20){
        if (tiltValue(height/2) +20){
        if (tiltValue>tiltMin){

There is something pretty compelling about building a device that reacts to you in the environment, moving to follow you. This is already very cool, but what I found was that it is fairly slow to keep up, and easy to move a little too fast for it. To remedy this I needed to scale the movement reaction based on how far off centre the face is. the farther from centre, the larger the movement it sends to the arduino. Close to centre yields single steps of corrective movement. right near the edge of video and it moves the camera in larger steps. This meant that the camera could do a better job of keeping up, though it is still fairly easy to outpace it.

Optimising performance

So this is all working great, however I realised that face detection was slowing things down a lot, I knocked up a quick FPS counter and sure enough doing detection on every frame drops the frame rate to about 4 frames per second. Which is pretty terrible considering the camera is producing 30fps.
So I played around with doing face detection on different fractions of the frame rate, it turns out that actually just doing it on alternate frames is enough to make a big difference, I got right back up to 20-25fps, and the face detection handling 10-14 updates per second, which is a lot better than the 4 I was getting trying to do it every frame.


This was crazily easy. from never having used or its libraries before, to a full interactive UI with manual controls and auto-pan, timelapse and face tracking modes in about 3 hours.

Now to set it up to take some interesting long duration panning time-lapses. I’ll have to think of suitable places to set it up, possibly in the workshop whilst I’m making other things.

Pan and Tilt webcam mount – arduino powered

April 27, 2014

A long time ago I built a little pan and tilt mount from some scavenged electronics (a stepper motor from a printer and a worm drive from a cd player) I connected it via a parallel port and used darlington arrays and direct pin out of the parallel port to control the whole thing from some script language, I forget which.
It was a little unreliable and fairly cumbersome but it got the job done, I used it to watch what my cats were up to whilst I was out at work. At some point I got tired of the very bulky and rubbish looking thing sat in the living room and it got decommissioned.

Spin on a few years and I have a few arduino’s laying around, and a higher budget to buy parts. So I decided to revive the pan and tilt camera mount using servos and an arduino to control things. I’m still going to need a pc application to talk to the arduino, but it handles the servo logic and the PWM stuff.

When I looked on line a lot of what shows up is very basic servos stuck to each other and a webcam stuck on the end. This works but looks a little rough and possibly not that robust. So I decided to go with something a little more ‘constructed’. It is probably overkill for just a camera but it could potentially serve for other purposes in the future.



The design of the pan is around the use of a lazy susan bearing, this is where all the weight is supported, so in theory I could have quite a heavy load on top and the servo just needs to overcome rotational friction, it doesn’t also need to support the weight.  To make this work, I have a base board that attaches to the bottom of the lazy susan bearing, and centred within that I screwed one of the standard servo attachments, then just dropped the servo onto it. This then let me figure out the location to cut a hole to fit the servo body into for the board connected to the top of the bearing.
After a certain amount of drilling and chiselling I cut out a recess that snugly fit around the servo body, so that there is no weight pressing down on the servo, but in order for it to twist, it is twisting the whole top board.


With that base in place I could mount whatever I like on top, in this case I wanted a tilt mechanism. The basic idea is that you have a platform that can tilt back and forth, onto which I could mount a camera (or whatever else I wanted). The platform has a centre of axis around which it is going to rotate, on one side there will be the servo, on the other a free spinning axel of some kind to just support the weight. I used a bearing mounted into the side of the platform, and a wooden peg that fit on the inside of the bearing which was just stuck into a support strut. This allowed the platform to spin on the bearing supported by the peg. On the other side then I just needed a block to mount the servo into which brought its centre in line with my desired centre of rotation.


And that’s about it from a mechanical perspective. It is quite chunky by comparison to an off the shelf pan/tilt camera. I’m not sure what future purposes I might come up with, but it should be able to take a considerable amount of weight and still be able to pan at least.


As I mentioned the electronics comes in the form of an arduino. In theory this is very simple, but I had a couple of false starts. The important thing to realise is that whilst you can very easily get the initial sense of success by just wiring up the servo to the arduino for power and signals, this WILL NOT WORK. I know, you’ve done it, and it seems like it is working, but this is an illusion. It is unreliable to the point of being worthless. Servos draw a lot of power, I’ve seen indication that they can draw up to 1A each. depending on what they’re doing. The arduino is not able to provide that kind of power. The path I went down I wired everything up away from the mechanical setup, and everything worked! because the servos had absolutely no LOAD to move. so they drew relatively little power. I was also driving them only one at a time. But the second I had things inside the mechanical build, you’d get one movement, and the arduino would crash. If you were lucky on a small movement, maybe it wouldn’t, but basically everytime you try to do anything it crashes. So what is required is an external power supply to provide the power needed.



My second false start was in assuming I could plug that power supply into the arduino board via that convenient plug socket designed for the purpose. I bought myself a 9V 2.2A supplied and plugged it in. But this yielded the same crashing results. It turns out that the arduino power regulator simply isn’t rated to allow that much power draw through it even if the supply can provide it. So I needed to wire the power supply independently straight to the servos. And just bridge the GND line into the arduino. That bit is important as without the same reference ground level the servos won’t recognise the PWM signals coming from the arduino.

Once I had done this though, I was in business. I made myself a nice little ‘breakout’ board that just plugs down into the arduino to grab the signal pins I was using and the ground line, with some extra pins just to make the board somewhat stable when connected. This let me run the servo lines fairly neatly, and screw the whole assembly to the back of the platform. Whilst this is arguably still very scrappy compared to a commercial unit, it is leaps and bounds more slick than my previous attempt.


Right now, control is via the arduino software serial console, where I sent it a pair of numbers to represent the position for the servos. The program running on the arduino scales whatever I give it to sit inside the range of valid movements for the servo. And actually in the tilt case it is more restrictive as mechanically it would crash into things if it moved the full range the servo is capable of.

I do want to play with making some kind of web interface to it that will both show the video feed from the webcam, but also provide controls to pan/tilt.
Not sure exactly how I’ll approach that yet, maybe see if there is some off-the-shelf software option that I can hook up. I seem to recall using something on linux when I made my first attempt. But I might use it as an opportunity to learn something new, maybe play with some ruby? I could just make a desktop app, but I think it will be more useful as a webapp.

Ultimately I was thinking of leaving it in the office as a little team camera that people can always check in on if they’re working away from the office and get a sense of who is around.

Improvised tripod and light box

April 17, 2014

I am often taking photos of projects that I’ve made, be it projects on my CNC router, or hand made using other more every day tools. Mostly the purpose of the photos is to use here on this blog or other places where I share progress etc.
Something I’ve noticed more and more is that the quality of photos is pretty variable for me, and other makers do a really nice job of taking great photos of their projects.
Recently I was taking pictures of a little wooden watch stand I made for my bedside cabinet, and only noticed after posting that a couple of the images were a little blurry and generally the images are a bit meh.


I feel like I’ve been at this blogging game long enough to feel I should have a better setup for taking photos/video of what I’m doing so I decided it was time to take action.

From doing a little reading the two basic tools I should have to take nicer photos of my creations are a tripod for my camera of choice and a light box to allow diffuse lighting of the subject.

Now it should be noted that the photo’s in this blog post mostly don’t benefit from either of these since I’m taking pictures of them, not with them.

The theory of the two items is pretty simple. a Tripod holds the camera steady, no more trying to brace my arms against something, in an attempt to keep things steady. A light box allows for good lighting of the subject but without hard direct light casting shadows all over the place.

The first thing I started with was a tri-pod. Now I could have made life easy for myself and bought one, or even just used my wife’s. However there is one point I’m being stubborn about. I take pictures with my phone. It is not the greatest camera in the world in terms of quality. However it is the camera that I always have with me, and always make sure is charged. It is also the camera that automatically backs up my photos to the cloud (in this case google+) and make it easy to share them. And even do some amount of editing on the phone.
This is important to me, since I don’t have to mess around with downloading pictures from a camera to my laptop, then uploading from my laptop to somewhere.
However this does make life awkward. a normal camera would just have a screw thread already in it for a tripod. But with my phone I had to devise a holder for it that would hold it firmly but also make it easy to get the phone in and out.

I *could* have just made a mount and have it attach to a standard tripod. However it turns out that standard tripods use an imperial thread, and its not so easy for me to pick up anything that isn’t a standard metric thread. So I decided that I’d just make the whole thing…

A tripod is a fairly simple thing. a collection of m6 bolts with wing nuts, a little time on the bandsaw and some holes drilled on the pillar drill and presto.
The only real measurements I made in the construction was to get the 120degree spacing for the 3 legs around the central circle.

Everything else I just did by eye for what looked about right. Mostly I was just working inside the scrap of cherry wood that I pulled off the pile to work with.


The tricky part was the ‘cage’ for the phone. I have a hard aluminium case for my nexus 4 which I stopped using because it degraded the signal and bluetooth performance. However it is perfect for this usage, I could build a structure that the case slides in and out of and then know I just need to drop the phone into the case and everything would fit nicely.

In this case I went with a ‘spine’ of wood that supports the buttom of the case, into which I cut a recess for the cases hinge to fit into. Then at either end I glued verticals that just hold the front and back of the case at each end. The spine piece was cut to the same width as the case, so everything just fits. The only tweaking required was to cut some recesses for the little dimpled feet of the case to fit into. This just made the whole fit more snug.
The only problem is that the contact area for the glue is not very large, I don’t think this would survive any real lateral stresses, however in normal usage it should not experience any real lateral force so hopefully it will be ok.

The spine of the phone cage just slots into the top part of the pivot mechanism and it holds pretty tight without any need for glue. With the phone in place it is easily able to hold it firmly in place and doesn’t suffer any wobble. To be on the safe side I have my phone camera configured on a 1 second delay, so if it does flex at all when I touch the phone to take a picture, it has time to settle before it actually takes an image.



For the light box the idea was to use a cardboard box, drape some a3 paper from the back to provide my backdrop with smooth curve to avoid any sharp corners/shadows in the backdrop. Then to cut holes in the sides and the top, line with tissue paper to diffuse light, then just set lamps around the edges to illuminate.
I thought the trickiest part here would be sourcing some plain white tissue paper. I wasn’t really sure where I would find that supplied it, but as it turns out the answer is W.H.Smiths, which had white tissue paper in pretty much the first place I looked.
With a box, some regular white paper, some white tissue paper and some cellotape. I set to work and quickly constructed a little light box.

Here are the resulting images. I didn’t really have any good lamps to provide light sources, so I relied on a little post-editing on my phone to get the final result. But all in all when compared to the original set of pictures I took of the same item I am pleased with the results.




Raspberry PI – adventures in case building

March 16, 2014


Recently I was given a raspberry pi, it’s something I’ve thought about buying to play with a few times but hadn’t quite got around to what with other hobbies keeping me busy enough. However, I wasn’t about to turn down one as a gift. I won’t go into much about the device itself, there is plenty around about setting them up and what they’re capable of.

The important point is that they come as a bare circuit board, much like an arduino. This makes one of the first requirements to get a case to put it in. Now there are plenty around and mostly not too expensive, but anyone that has read even a few of my blog posts would realise I’m really not the kind of person that buys something like a case when I could just try to make one myself.

So I set off browsing through thingiverse looking to see what different designs existed. For the arduino I cut a case as 6 sides that interlocked to form the case, which is the kind of thing that you do when you have flat sheet materials and want to make a box. However, on this occasion I decided that I really wanted to try milling a case from a block of cherry.  The idea was to mill out the bottom and top halves that would then fit together. Most of the designs on thingiverse assume that you are going to use a 3d printer to create this kind of case, however the designs work just as well for milling out of a block.

The attempt was not without its failures…

The idea was to use a large 10mm bit to rough out the basic shape, then use a 3mm bit for finishing. Initially I setup the CAM to cut both the top and bottom pieces from a long thing block as part of the same job. The problem with this is that the job takes so long to run, and a mistake anywhere ruins the entire run.

Fail 1:- When setting up the model I made a few adjustments from the original on the basis that I would be using wood and cutting out rather than printing from plastic. I needed the wall thickness to be thicker. I made my modifications and generated some tool paths, but I kept getting errors about unsafe tool paths. I couldn’t figure out why or where the problem was, but I did figure out how to turn off the warning…ok stupid idea, but I’m still learning.
It turned out that at some point in the model it didn’t have a clean solid part for one wall of the top half, it was actually represented as two pieces stacked on top of each other. This was not easy to spot by eye, but the tool path generation had figured out it was being asked to move across the top of the lower wall piece which would take it through the upper wall piece. This became apparent to me when I watched as my cnc router, having carefully milled around the outside profile of the wall, carved straight through that section levelling it off much lower. stupid boy.

lesson 1: – don’t turn off the warnings, the computer is smart and you’re an idiot.

I went back and fixed the model, switched the warning back on, and regenerated. Good to go…

Fail 2:- After probably 4 hours of milling accross 2 days, I had failed to recheck the tightness on the chuck holding the router bit. During a cut the bit began to slip, as it bit into the wood and due to the increased friction get dragged further down and out of the chuck. To be fair to the spindle it kept on chewing throught the wood even as the cut depth went to something like 10-12mm, however the stresses on the machine by then were enough to pull the cutter off course, and into the area of the case. I hit the emergency stop, but I was too late, it was going to be difficult to reset the machine aligned properly with the workpiece again, and even if I could the top half was already ruined.

lesson 2:- Don’t try to mill multiple large complex parts in a single pass, break them into smaller units such that any failure impacts less work
lesson 3:- Always recheck the tightness of the chuck, particularly when its been a few days and temperature changes since the last run.

I split the model into a top half and a bottom half, and set about milling the bottom half.

Roughing it raspberry pi box bottom:

Fail 3:- I set the machine back to milling on a new block of cherry. In the interim I’d found some settings around exact stop versus constant velocity and was able to set the machine to actually run quite a bit faster than it previously was working. It made fairly short work of the 10mm roughing pass, and I got to switch to the 3mm cutter and watch it nicely refine the shape. It worked perfectly. though I did find that the roughing pass + the finishing pass left some places where the rough with 2mm clerance had left 2mm of material but which the finishing pass did not then go over. because the waterline finish doesn’t go over top surfaces. So I had to manually tweak a few things to make it do a proper final pass to clean up those few places. This to, worked perfectly.
I brought it in and set to fitting the raspberry pi into it, this required a little sanding, of the box and the corners of the raspberry pi. The model is a very tight fit and the radius of my cutters meant that corners weren’t as sharp as the pcb. However after a few tweaks I got a really nice, snug fit for the raspberry pi in its new bottom half case in cherry. It looks awesome.

Final pass raspberry pi box bottom:

however, we’re still in fail 3…

The block of cherry I used to mill the case from had been in my garage, for at least a year, and over one of the wettest winters the UK has seen for about a century. After a week in my centrally heated house, the very thin, very precise case, had shrunk around the raspberry pi, and seriously warped across the thin base.  I had forgotten the basics of working in wood. if it is not dry or even just not already acclimatised to teh environment you ultimately want it in, then the change of environment can easily be enough to shrink/grow and generally shift the material around. it is really not that suited to making accurate engineering type cases. At least not unless you started with really dry stable wood in the first place.


Lesson 4: – Wood is a living material, don’t mill wood that has been in the garage for months and expect it to stay stable when put in a centrally heated house.

So, back to the drawing board. I need a case, cherry is probably not a great idea. This lead me to the pibow case, which has the designs available on thingiverse free for non-comercial use. The pibow case design is one of layers. Basically 8 layers, each 3mm thick and each with cut outs that fit around the parts of the raspberry pi at that point. This is back to the idea of cutting something from sheet stock to produce a case, rather than milling out of a block. This time I turned to some hdpe sheets that I had, which would also be stable and not warp when brought into the warm.

Milling pibow layers from hdpe:

Fail 4:- New plan, new material, the machine had been capable of a nice precise milling operation and the only previous problem had been material which I was now getting rid of by switching to HDPE. Let’s rock this thing! In my haste to get going again down this new path, I mounted a sheet of hdpe on top of a block of mdf with some clamps at 4 corners and I failed to notice that the block of mdf was substantially thinner at one side than the other. Having set my z=0 at the surface in one corner I didn’t notice that the rest of the sheet was substantially higher. The first cut that was supposed to be 1mm turns out to cut clean through the sheet in one go, wiping out any attempt at holding tabs and generally making a mess.

lesson 5:- Don’t get cocky kid, check the levels, make sure if you’re resting material on something that that something is consistent thickness across its surface.

Fail 5:- New setup, nice even thickness of mdf. Clamps caused the hdpe to bow up in the middle, but not too bad…I milled the base layer, and even engraved the little markings on it with some success. However I failed to notice that my two x-axis motors were nearly 9mm out of alignment from previous problems. So whilst it cut fine, the outside profile wasn’t square/parallel in its lines, essentialy the y axis was not cutting at 90 degrees to the xaxis

Lesson 6:- similar to lesson 3, – recheck the machine setup before you start. including that the x-axis motors are still in alignment.

Fail 6:- the hits keep coming…milling the exterior profile of the layer followed by milling out the interior spaces means that there is less support for the cutting than doing it the other way around. the thin walls of the quite delicate design bow under stress, break through the very small holding tabs you configured thinking you didn’t want to have to cut out too much by hand. the whole layer pulls free and is destroyed

Fail 7:- You think that milling out the interior spaces before the exterior cut out will solve your problems and don’t increase the holding tab sizes…but you are wrong, the thin walls and pressures of the cuts are still not suitable and the thin holding tabs easily snap away, destroying another layer

Lesson 7:- holding tabs are important, and you probably need more than you imagine. and they should be big enough to provide real support. Yes there is a trade off of too much time cutting out later, but err on the side of caution


So I’ve had a lot of failures, and a lot of lessons learned. and I currently have about 4 layers I’m semi-happy with. And I think I no longer have enough 3mm hdpe sheet to finish the remaining layers ;-(
For all the failures I’m still pretty happy with how precise the machine is in terms of the path it follows. I think I have to chose a better cutter for this  material as the 2mm end mill I was using left a pretty rough surface. This has turned from ‘oh I’ll just cut out a box for the raspberry pi’ into a series of experiments to learn more about what it means to work with different materials and get reliable results.

Maybe the next one will be the ones that goes perfectly…

DIY CNC – handling EM inteference

February 16, 2014

So last time I wrote about my awesome new spindle. It is a serious piece of equipment and the rest of my machine now seems somewhat inadequate to deserve such a beauty of precision engineering.

One way in which the rest of my machine fell short was in its ability to cope with the Electro-Magnetic interference being thrown out by the variable frequency spindle. I noted last time that I had ordered some capacitors to try to resolve the issue.

So what have I learned about EM interference? Well, essentially every wire you run could pick up voltage blips from EMI. If these wires connect to digital signal lines, such as step and direction inputs to stepper drivers, then this gets picked up as random motion. If  those wires are connected to ground on your arduino… well that can cause it to crash. So… what do capacitors do to help?

I should pre-fix this by saying I have only what I would consider to be a pragmatic understanding of electronics, and I could be mistaken  in my understanding, however I have now fixed my problem so if nothing else there is that.

So the mental model I find most helpful is that an electronic circuit is a little like a closed system of water. In this model EMI basically causes ripples in the water that can be mistaken for the water flowing. A capacitor then is a little reservoir. they come in various sizes depending on how big of a reservoir you want. but even a very small one is enough to absorb a ripple without it making it to the outlet of the reservoir. Where a real signal is a more serious movement of the water, which easily fills and pushes through the reservoir. So capacitors act as filters for this ‘high frequency’ low but low power type ripple. They also act to ‘smooth’ power supply. essentially in our model the water in the system flows a little erratically around our desired rate, sometimes a littel fast, sometimes a little slow. for components that require a certain amount of flow in order to work, having a little local reservoir near their power input means that when the flow is a little fast the reservoir fills, and when it is slow the reservoir is depleted, but the component can keep drawing at a consistent rate so it looks like a nice smooth flow. Obviously depending on the peaks/troughs of flow, you may require a larger reservoir to have sufficient capacity to smooth out a larger variance.

Now with that model in mind. basically I put small 0.01uF capacitors between the step lines and ground, and also between the direction lines and ground. I then put slightly larger 0.1uF capacitors between the v+ and gnd of the stepper drivers. And lastly I put a big 10uF 25v capacitor between the v+ and gnd of the main 24v supply for all the steppers. In operation it is likely that there will be peaks of power usage across the stepper drivers, and the extra capacitor provides a chance to provide in these high use spikes without the power dropping lower than it should.

In addition to all these capacitors, I also had a problem with spikes on the ground line to the arduinio causing it to crash. I wasn’t really sure how to solve this because I didn’t really know where I would introduce a capacitor. The issue here is that the arduino needs to share a common ground with the stepper drivers in order that the signals be correctly detected. However there is really 2 quite different voltage circuits here. the arduino and its signals are on 5V, but the rest of the circuit is 24v for the motors, from a different supply. The ideal thing here I have discovered would actually be to properly isolate these two circuits.

How? there is a component called an opto-isolator. essentially this is an led in a package with a light sensor. the led is powered by one circuit, and the sensor is powered by the other. basically the two isolated circuits are able to signal each other via light, and keep their electrical systems independent. This is an obvious next step for me, as this would allow a more robust setup and might pave the way for future enhancements with even higher voltage motors.
However those haven’t arrived yet. Thankfully there was one more change I made that fixed the last of my issues.

It turns out there is a reason that computers come in metal cases, and those cases are earthed. This is what can also be described as a Faraday cage. These are used to essentially give any EM a path to ground.
When I originally set up my electronics I stuck it in an old cat food box. It just happened to be about the right size for my circuit board, and at the time I was only thinking of keeping components together and a little protected from dust.

But cardboard boxes do not screen EM. So I bought myself a cheap PC case, which even included a power supply and a fan. This was a bargain, I was able o use the pc supply to power fans in the case, and also cooling fans on the stepper motors. Whilst also neatly housing the electronics and running the cables neatly. It looks pretty good and the best part is that this seems to have completely eliminated the problems I had been having with interference in my circuit. yay!


One last note of improvements. nothing to do with interference but certainly an issue I was having was the steppers getting hot. at 24v they were getting too hot to touch, and given two of them are mounted using 3d printed parts, they were getting hot enough to warp the plastic. So I bought 2 AMD cpu heatsinks with integrated fans. These things were fairly cheap, and they are super effective. I’ve really only lashed them in place, literally using string and gaffer tape to hold them in position. But even after hours of operation those steppers are still cool to the touch. I only did this on the Y and Z axis. the X axis has 2 steppers and they both seem to run cooler anyway, well around 50C, I balance a long steel ruler on each to act as a bit of a heat sink and that seems to be sufficient to keep them from getting alarmingly hot.

So, do I now have a perfect machine?

Not yet…I still ahven’t managed to make a complex 3d carved object successfully. I got very close this week with a raspberry pi case that I was milling. But I’ve been plagued by human error in various forms. First attempt I messed up the model and the setup of wood. this meant the milling process first wiped out a wall of the box that it should not have, then it cut all the way through the stock when it was supposed to leave some material to hold things in place.
Then in my second attempt after about 4 hours of machining the bit slipped in the collets grip, causing it to cut far to deep and pull off course into the piece and ruining it. Frustration abounds, but I am trying to learn from these mistakes. I feel like I am close to making a really nice precision part. I just need the time!

Today – I am going to upgrade GRBL to the development branch to see if I notice any improvements in speed, and I’m going to push the speed of the machine higher. This is a real tradeoff, the faster I push it the more forces at work, and the higher the chance of a failure. However too slow and everything takes far too long, and I consume days and days of time, and still risk a failure screwing up. So I will at least try to go faster, but also to try machining parts one at a time, to reduce risk of failing half way through a pass on multiple bits. Wish me luck!

DIY CNC router – new 2.2kW water cooled spindle

February 1, 2014

For Christmas I was lucky enough to be given a new spindle for my DIY cnc machine. Until this point I had been using a combination of a small rotary tool, essentially a knock-off Dremel, and a bosh palm router.
the small rotary tool was good for small bits, however it was not really designed for continuous operation over hours of cnc time, and inevitably it burned out.
knowing full well that the bosh palm router was similarly not really intended for continuous operation I was keen to avoid the same problem. So I looked around and found the wonder that is a 2.2kW water cooled spindle. Then I dropped some heavy hints, and since I have the best wife in the world, she bought me one for Christmas.

Here it is:

It is epic.

the spindle weighs about 5.5kg, It comes with a separate box of electronics (VFD) for managing the 3 phase voltage frequency. essentially you dial up a frequency on the control box, and it sends that to the spindle which maps to a particular rpm.

This is a serious piece of industrial equipment, I needed to buy the appropriate power cabling, and wire it up. I did a lot of research and I have a pretty decent familiarity with doing this sort of thing, I would advise against doing this unless you are very confident. high voltage wiring is not something to take a chance on. I bought a crimping tool especially to make a nice job of the wiring, and be triple sure there were no stray wires making odd connections.

I was initially worried that the z-axis might not be able to lift the additional weight, it is significantly heavier than the bosh router. However it seems to cope just fine.

I also mounted the VFD onto a big metal plate, itself mounted off of a hardwood back piece. this ensures proper air clearance around the box, for cooling etc. the metal plate came from an old tv table I had. At this point that table has been cut up and used into all sorts of different things ;-)The hard wood back came from a hi-fi cabinet my dad made probably 20 years ago. I have a feeling the wood originally came from an x-ray machine room decommissioning (they used to have hard wood tool racks or something), since that is where he wound up with a bunch of such materials during his career as an engineer.

In any case I got everything wired up, and started up the spindle and was delighted by just how quiet this thing is. At full speed (24,000rpm) i can still easily hear myself talk. No more need for ear defenders!

Now this is water cooled, and whilst it will probably be a long time before I really push it hard enough to require the cooling. I set that part up also. I got a huge bucket (intended for wine making) and put in  70:30 mix of de-ionised water and anti-freeze coolant. submerged the pump in it and plumbed everything together. based on my research this much fluid should be able to passively cool around 400watts of heat. That number was an estimate assuming the worst case of a 2.2kW spindle, 80% efficient and thus putting out around 400W of that as heat. If it ever becomes a problem that it is not sufficient I can either add a load more fluid to the reservoir for passive cooling, or I could put a radiator inline. But I’m guessing it will not be an issue.

I have done a couple of test runs, and I’m super happy with how much power this thing has, I actually had an incident with the gcode generated by F-engrave, it was supposed to be metric, but for some reason grbl didn’t like a couple of  the commands and wound up ignoring the call to set metric mode. So rather than attempt to plunge 1mm into the surface, it tried to plunge 1 *inch* into the surface. luckily it was doing this along a path and slowly getting to depth so I was able to hit the brakes before it got too far, but by then it was already probably 10mm down and going strong. the spindle didn’t have any trouble at all maintaining 12000 rpm as it plunged on in. But I am not quite ready to stress test it…

The other great thing is that the spindle takes er20 collets which range from 1mm to about 13mm, this means I can use all my router bits, and all my Dremel bits, plus other specialist cnc bits that I bought. It’s a quick change to swap out the collet so no more having to remount different machines to do detail versus heavy work.

However, all this awesome is tempered by one issue which I can no longer ignore. As I have discovered over the course of this project, every time I fix an issue, it reveals another which was previously not significant enough to be noticeable. This time the issue was how poorly my electronics setup handles interference. Previously this had not been terribly evident, however now there is a big 240v variable frequency motor right there, and even with shielding it is obviously putting out some EM. In this case it is getting picked up on the step/dir pins of my easydrivers, and causing the axis motors to twitch (very evident when you start or stop the spindle) and this causes lost steps etc.

So for the moment I am still not able to achieve the accuracy I want, I have on order a bunch of capacitors and the plan is to essentially sprinkle them around the circuit board in an attempt to prevent the EM interference from causing a problem. If that doesn’t work, then I will likely return to the drawing board on the driver electronics, but I’m hoping it won’t come to that. Unfortunately despite having ordered my capacitors last weekend, I’m still waiting for delivery, and Maplin has failed me in that they hold essentially no stock, and 1 cap is not going to do it.


Get every new post delivered to your Inbox.

Join 99 other followers