Building of a CNC router.

Since several months I couldn’t decide between a 3D printer and a CNC router. Their goals are definitely different but they are pretty similar in many ways. There were several possibilities : Buying a complete system, it’s more expensive but it’s safer, building my own creation from scratch, very risky, or a kit, which is a good compromise.

Finally, I’ve taken a fourth path, I’ve had the book 'Build your own CNC machine' on my hands and it has been a revelation … complete and detailed instructions on how to build your own CNC router which have a decent size ( workspace of  +/- 1000mmx500mm) built in MDF. This is not the state of the art for a router, but it looks feasable even if it was my first project of that size. Moreover, I’d just bought a table saw and it was the perfect project to test it. 

I will not go into technical details on how to make the router and even less post the plans, as everything is in the book. I will just post some pictures of the differents steps to make something that works.

The work you can see here is at least a hundred hours of work … maybe more, I’ve not really tracked the time spend building it. I’ve made some adjustements here and there, especially because the plans were in imperial units and I’m working in metrics.

For the mecanical parts, I’ve tried to find stuff around here, but it’s was pretty difficult to find what I really want. I’ve searched ebay and found a lot of stuff, but the prices weren’t that interesting … especially as I was still doubtful about the result and wanted to reduce the risks. Finally, I’ve ordered eveything on the website of the book (, where you can have cheap parts even when you consider the delivery. I’ve ordered the ball bearings, the stepper motors, the motor controllers and the couplings :

Once I had the material, I’ve started working on the base, which is made of 2 pieces of MDF of 1200x600x18mm bolted together. Two rails are attached to the panels, they will support the gantry : 

Before going any further, I’ve made my first correction : the original rails were a bit small and were not that reliable, especially if you consider that everything will be moving on top of them, I’ve changed them for bigger ones. It was much better and the bigger ones stays straight even when the bolts were tightened.

It’s far better! The gantry is also attached using two aluminium rails were I’ve placed four bolted ball bearings :

The placement of the ball bearings requires accuracy as the gantry needs to be extremely stable.

Before placing the gantry I had to finish the feet of the base. On those feet you can see 2 ball bearings which will drive the main axis. A perfect alignement is also required in order avoid any load on the motor :

The axis itself will be placed later. I’ve tried to find one which is longer than one meter, but it looks that it’s not standard at all over here. Ideally I had to use lead screw and anti backlash nuts, which are really made for this, but the price was a bit high, so I’ve chosen cheaper material. I can change that later if necessary.

The next step was the placement of the side and lower part of the gantry : 

The rails with the ball bearings are tightened by bolts. This is very strong and adjustable, which is necessary.

The final size of the lower part has been measured once the sides has been made, as it depends of the size of the rail and the position of the ball bearings.

You can also see ball bearings for the secondary axis : 

The top part of the gantry is reinforced in order to consolidate the structure. You can also see two aluminium rails that will support the mobile head.

And here we go for the last axis : 

I’ve then put the head together :

Once the three axis were done, I’ve chosen a router. I’ve bought a small and light model that will not affect the structure due to its weight. Moreover it was pretty cheap (+/- 60€). The on/off button is a push button and, as I was thinking about keeping the warranty valid, I’ve made a piece of wood that keep the button un place …

After thinking about the different ways of attaching the router to the base, I’ve finally disassembled the router (bye bye warranty) and placed the pad under it. It has two advantages : it lowers the router (so I can route deeper) and it allows an easy unmounting of the router when I’ll had to change the mill.

The axis of the router is close to the center of the structure, which is an ideal position that reduces the lever effect. 

The three axis can be installed now. I’ve started with the shortest one :

The placement looks simple, so ‘ve tried the secondary axis and the motor supports :

But after testing the motor, it was definitely unusable as there were too much vibrations. The sources of the problem were the spacing between the axis and the inside of the ball bearing as well as the spacing between the axis and the coupling : everything was off axis. I was unable to tighten the coupling and keep the axis centered, so I’ve used aluminium foil which does not compress at all. And, for the ball bearing, I’ve used teflon which is softer and handles all residual vibrations.

Same thing for the third axis, and I’ve started to manage my cables as well : 

I’ve used flexible insulation tubes for the cables coming from the stepper motors (4 wires per motor) : 

I still had the problem with the axis larger than one meter, so I’ve bolted two axis together with a larger bolt. That bolt is glued to the axis and I’ve placed another small bolt next to it to lock it.

After placing stepper motors and wiring them to controllers, I had to manage them. I’ve chosen a light solution as I’ve tried to avoid the full pc in my basement: an arduino seems correct to do the job. I’ve used a mega to simplify the wiring and avoid extra multiplexers and/or external chips. I’ve made an hardware debounce shield to handle the buttons of the panel. The result is clean and simpler on the software side.

The first revision of the panel was using pushbuttons very sensitive to dust, I’ve ruined two of them in two days …. So I’ve finally used sealed pushbuttons that I had in stock. They are harder to activate but better for the job. A joystick is used to control the manual operation of the router, it’s more intuitive than buttons placed in a plus shape.

When the router will be operational, I’ll certainly make another more polished panel.

Once everything was wired, I’ve run the integrated tests : 

So, as everything was running correctly, I had to send more complex stuff to the machine. That’s why I’ve added an SD card reader which allows me to read Gcode files, but some debugging is still necessary, the router tends to go deeper and deeper as the code gets complex … I had some cold sweats doing the tests, but it looks promising anyway : 

I still need to improve the software side in order to use it in a confortable manner.

Beside that, I’ve put two varnish layers on the MDF to stop the humidity. I’ve also placed some end curse switches which will allow me to calibrate the machine accurately.  This will ensure a good placement of the routing area. 

To conclude, here is a short video of the machine in action :

Hidden light control

I’ve bought recently some cheap dual axis magnetic sensors at SureElectronics (, I’ve tried first to use them as straight compass.

Annoying problem : it’s impossible to accurately compensate the tilt of the sensor without using a gyro sensor. On the other end, if you stay on the same horizontal plan, the measures are pretty accurate even if you consider their low price (6$), I was really surprised. Three axis sensor can simplify the problem but they are more expensive …

Usage of the sensor is pretty simple : the communication is based on I2C and you can read new data 50 times per second. Furthermore, there is a reset command that put the sensor back in its initial state, which is necessary when it has to handle strong magnetic fields.

After a few tries and some code, I was able to get the angle of the compass. For that, I had to calibrate it first to know the minimal and maximal values on each axis. The calibration procedure is easy : I’ve placed the sensor on the edge of my workbench, red the x and y values, then I’ve rotated it by 90°, then 180° and finally 270°. After that, I’ve taken the minimal and maximal values along both axis from the different orientations. 

The calibrated values are computed this way :


The calibrated values varies more or less between -1 and 1, the angle can be determined thanks to some trigonometry :

if (( cal_x ==0) && ( cal_y <0))
else if (( cal_x ==0) && ( cal_y >0))
else if (cal_x<0)
else if ((cal_x>0) && (cal_y<0))
      angle=-atan( cal_y/cal_x );
else if (( cal_x >0) && ( cal_y >0))
      angle=(2*PI)-atan( cal_y/cal_x );

While playing with some magnets borrowed from my fridge, I’ve noticed that the sensor can detect accurately the orientation of the magnet as well as its presence. The sensed values increase strongly but the angle calculus is still totally valid. The magnetic field intensity can be computed like this :


If there is no magnet, the intensity stays under 1.5 (unless I tilt the sensor) and it moves to higher values which depends on the distance between the magnet and the sensor and on the strenght of the magnet. Above a certain threshold, the sensor has to be reset as it gives totally random values. This is not a real problem for my specific usage as there will always be a minimal distance of an inch of wood between the sensor and the magnet, I just have to avoid strong magnets.

But there is a small data stability issue when you stay on the same orientation. To reduce that jitter, I’ve dampened the data depending on their variation : if the offset between the previous read and the new one is small, the data is slightly taken into account, on the other hand, if the offset is bigger, the data has more weight. This has the advantage of stabilyzing the data while ensuring a good reactivity when bigger changes are done.

Once all of this has been validated, I’ve prototyped a controller for an RGB led strip I’ve bought at SureElectronics as well ( That led strip runs on 12V and can pump up to 15w, so I’ve used IRLZ34N mosfets which can be driven directly from an Arduino pin without any extra components and can handle far more than my needs. The other advantage of using those mosfets is that they can handle the PWM mode, which allow me to control the intensity of each color channel of my strip. Here is the schematic of the project :  

I’ve not made a dedicated PCB for that project, I’ve just used a round prototype pcb instead and build it as an Arduino shield.

I’ve powered the Arduino on 12V as it’s still in the accepted votlage range. By doing so, I was able to get a 12V line on my shield (Vin pin) and the usual 5v line. A bended connector is soldered on the side to plug the rgb led strip :


The magnet is hidden in the pedestal of an Eizo Auditore’s action figure (from Assassin’s Creed) :


As I was able to control independently each color channel, I’ve fixed the color balance which was far too blueish. A well balanced white was finally obtained by reducing the blue by 65%.

The light intensity depdends on the orientation of the action figure : the more it faces the outside, the higher the intensity is. When you place the pedestal over the sensor, there is a smooth transition to avoid going from off state to on state in a snap, and also when the light is switched off.

There is still the small problem of non linear answer of the leds : a PWM of 50% does not match an average intensity (right bewteen maximal intensity and black). This phenomenon is also visible on tv screens and monitors ( and I’ve used the same ramp used on standard monitor (2.2) to have a far more linear answer from the leds. 

One just need to put the value to the power 2.2 which will counter balance the led’s response curve : 


To conclude, here is a video of the light control in action : 

And the current full code : 

// Led compass control
// By -Gil- (c)2012
#include "Arduino.h"
#include <Wire.h>
int calibration=-1;
int PreviousCompass_x=0;
int PreviousCompass_y=0;
int Compass_x=0;
int Compass_y=0;
float Compass_xcal=0;
float Compass_ycal=0;
int Compass_minx=1920;
int Compass_miny=1935;
int Compass_maxx=2131;
int Compass_maxy=2136;
float Compass_dist=0.0;
float ProximityFade=0.0;
int RotationValue=255;
float Compass_angle=0.0;
#define COMPASS_CARD_ADR B0110000  
const byte COMPASS_comp_reg_addr = B00000000;
const byte COMPASS_read_comp = B00000001;
const byte COMPASS_reset_comp = B00000100;
const byte COMPASS_set_comp = B00000010;
void setCompass()
void resetCompass()
void readCompass()
   byte x_msb = 0;
   byte x_lsb = 0;
   byte y_msb = 0;
   byte y_lsb = 0;
   // read data from the sensor
   Wire.requestFrom(COMPASS_CARD_ADR, 5);
   int avail = Wire.available();
   if (avail == 5)
      x_msb =;
      x_lsb =;
      y_msb =;
      y_lsb =;
   int newCompass_x=((int)x_msb)<<8 | (int)x_lsb;
   int newCompass_y=((int)y_msb)<<8 | (int)y_lsb;
   int deltax=abs(newCompass_x-PreviousCompass_x);
   int deltay=abs(newCompass_y-PreviousCompass_y);
   // Filter the result to avoid jitter
   float deltaxFriction=deltax/10.0f;
   float deltayFriction=deltay/10.0f;
   if (deltaxFriction>1.0)
   if (deltayFriction>1.0)
   // calibrate the values
   // compute magnetic field intensity
   // compute angle
   if ((Compass_xcal==0) && (Compass_ycal<0))
   if ((Compass_xcal==0) && (Compass_ycal>0))
   if (Compass_xcal<0)
   if ((Compass_xcal>0) && (Compass_ycal<0))
   if ((Compass_xcal>0) && (Compass_ycal>0))
void setup()  
      // reset the compass when starting/restarting
void loop()  
      if (Compass_dist>1.5) // Is there a magnet ?
            // Fade in
            if (ProximityFade>1.0)
            float intensity=(Compass_angle-PI/2)/(PI);
            if (intensity<0)
            if (intensity>1)
            // Fade out
            if (ProximityFade<0.0)
      int finalFade=RotationValue*ProximityFade;
      analogWrite(3, finalFade);         //R        
      analogWrite(5, finalFade);         //G      
      analogWrite(6, finalFade*0.35); //B (fixed)    

You can also follow Domoduino on Google+ here. Don’t hesitate to leave comments!

--Tagged under: Arduino--

--Tagged under: Magnetic sensor--

--Tagged under: Led strip--

--Tagged under: Domoduino--

Multifunction clock (Part 1)

Here is a project I’m working on since some months now and which is now decent enough to be shown here. The time I spend working on it is inversly proportionnal to the time I spend playing games on console … this explains that :-)

The idea is to have an autonomous multifunction clock that uses two 24x16 leds display … I’ve already talked about those displays : bought on SureElectronics for a very low price (14$), they are really well done, a bit uneven on the luminosity side (between displays), but globally, a very good investment.

On the functionnal side, you have, of course, the time, date but also temperature and relative humidity.

One of my goals was to make a clock that does not look like a breadboard prototype and have a nice design. I’ve bought a plexiglas panel where I’ve cut a front and a back panel. To avoid any kind of screws on the front, I’ve bought a tap kit so I can place the threaded rod directly on the plexiglas without any bumps on the front side … 

I’ve never done this before, but it’s pretty simple and the final result is clean and strong. I’ve bought a 40 inches threaded rod that I’ve cut to have my display, the arduino and my board between the front and back panels. The back panel is not yet in place right now, but you can already see what the front panel looks like :

To place the display at a given distance from the panel, I’ve cut small sections on an aluminium tube, so you don’t see the screw and I have even spacing everywhere. I’ve used 4 rods per display to have something sturdy.

On the electronic side : 

  • an arduino 
  • a DS1307 to have a good and stable time reference that keeps the time even in case of power outage.
  • DC-SS500 from sure electronics to get temperature and relative humidity.
  • an LDR to adjust the display intensity depending of the ambiant light.
  • a RFM12B for wireless communication.

The wireless part is not yet done, but there is already some room on the board for it … 

The led displays are managed thanks to the library of Miles Burton that you can find here. Very simple to use and it can control up to 4 displays daisy chained. For this project, I’ve used only two displays driven through 4 wires : clock, data, CS1, CS2 … and of course the power. I’ve added some stuff to the library, like ‘giant’ letters as I plan to have several display themes in the future. 

Here is the complete schematic (you can click on it to have a higher resolution display) :


As the wiring was pretty straight, I’ve used a small experiment board instead of a dedicated board : 

The arduino and my board are placed behind the displays using double sided tape, which also ensure electric insulation.

For the moment, the time is always displayed on the first line of text and on the second line you can see alternatively the day/date, humidity and the temperature. The code is pretty “experimental” right now … but as soon as it will be a bit cleaner, I’ll post it here.

Once the wireless part will be in place, I will link the clock to the other devices in my house. Doing so, I’ll be able to track temperature, humidity and light level on my central pc and also send commands to the clock like : 

  • synchronise clock to internet
  • change display theme
  • messages 

To be continued…

Arcade joystick V2.1

I’ve been confronted recently with a limitation of my home made arcade joystick : I’m unable to play Mortal Kombat with it, it lacks buttons. I’ve build my joystick on top of two xbox 360 joypads where I’ve connected the A, B, X, Y, LB and RB buttons. But it’s not enough as MK uses also the LT and RT triggers. The details on my joystick are only available on the french side of blog as I’ve made it some months ago … sorry about that. 

All the buttons I’ve connected so far were simple and straight on/off buttons, but here, the triggers are small potentiometers (10K Ohm) as you can see on the following picture :


To simulate the behaviour of the potentiometer, I’ve simply considered the two extreme positions by using an inverter button and two resistors. In idle position, one side is directly connected while the other goes through a 10K Ohm resistor. When pushed, it’s the other way round … The following schematic shows what I had before and what I have now : 

This is how it looks like once soldered on an arcade microswitch : 

The soldering on the joypad board was much more simpler than the other buttons. I just removed the potentiometers using a desoldering pump and than had a clean place to connect my three wires. The whole thing is covered with hot glue to avoid any unwanted wire movements.


For ergonomic reasons, I’ve put my two new buttons right under the other six ones.

I’d liked also to move the joypad leds on the front panel of the joystick in order to see if the joystick is switched on and who is connected. Unsodlering the surface mounted leds is not that simple, but soldering afterward wires on a such tiny surface … I just don’t feel it … If someone has already done that kind of stuff, I’m really intersted to know how and what tools to use :-) … 

Retro radio V1.1

Here we go for some improvement on my retro radio which integrates a PC/media player. The first version had an external touch screen which just ruin the overall look … So I’ve decided to integrate it in the radio itself.

I’ve stripped down the original speaker covering, everything was attached with screws, it was pretty simple to do.

A part of the ‘grid’ of the speaker is use to keep the touch screen in place. As this screen does not use the full opening, I’ve tried to keep the look of the radio as it was.

I’ve not cut the fabric right on the edge to be able to fold and glue it to have a nicer result.

I’ve glued the screen with a glue gun. It’s pretty harsh, I agree, but I don’t have the courage nor the tools to do a proper removable system.

The main point, beside the look of the radio, is the simplification of the cabling. The screen is now powered by the power supply of the PC and the VGA cable is kept inside the box.

Another improvement I’ve made is the ability of the system to communicate with external modules thanks to an arduino using a custom made RF shield.

The first wireless communication tests I’ve made were using Xbees, but they are expensive and I was never able to have more than 2 arduino exchanging data and staying fast and responsive enough. 

So, I’ve tried a simpler solution that fit my needs : RFM12B modules … very cheap (5.5€ @ Jeelabs) and pretty simple to use with the library you can find at Jeelabs. Here is my prototype :  

All the pins are wired as I’ll probably use them later on.

On the other side, I have anothe prototype of multifunctional module. This one is based on an arduino mini pro, a temperature and humidity senser (Sure electronics), a light level senser (Sure electronics) and two multicolored leds (BlinkM).

The idea is to build several of these modules to keep track of the temperature and humidity of my house’s rooms. I’ve added the leds here as I’ll use them to backlight my tv set, which is the first module I’ll put in place.

I’ve soldered the RF modules on pin headers that I’ve bend in order to be able to use them on breadboards and other standard protoboards.

The other modules : 

Everything assembled together with a regulator to allow the powering through a regular/cheap transformer : 

I’ve modified the interface of my media player to easily change the leds color, it’s still a rough one, but at least, it’s working.

I’ve not yet integrated the temperature, humidity and light values … The arduino sketches are already done, I just miss the c# part on the interface.

There is still room for improvement, mainly on the interface side, but for a daily usage, it’s ok ;-)

Timelapse …

Here is a little project around an arduino mini pro that was pretty simple to do and which allows me to go back to electronics as I’ve neglected it these months.

So, what’s a timelapse ? A function you can find directly on some camera or as an external device that you can plug on you camera which allows you to take pictures at a regular pace in order to make a video out of it. One of the most common usage is to take pictures of clouds and replay that at high speed. Here are two examples I’ve made with my system (canon 550d/sigma 50mm 1.4 + arduino timelapse) :

To interface with the camera, I simply use a 2.5mm jack which is used to remote control the shutter and focus. Here is the schematic for canon camera:  


To isolate the camera control from the rest of the circuit, I’ve used two optocoupleurs 4n35. They are plugged to a digital I/O pin of the arduino with a 560Ohm resistor. 

Now I need a nice human interface here … I’ve chosed a small LCD 1 and half inches large (HMC16223SG)  that I’ve bought online at Pollin. It’s controlled by a HD44780 that I use in 4bits mode to reduce the number of wires (7 instead of 11). There is just one drawback with this LCD, there is no backlight, but this is not really an issue here.

I’ve found a nice enclosure at my local store, 5x2.3x1.2 inches large with a 9v battery place and a translucent plastic windows for the LCD. I’ve struggled a bit to pack everything in, but it fits.   

Here is the inside view :


I’ve put 3 push buttons to navigate in the menu. I’ve already use those ones in a previous project, nice feeling and small enough.

And the outside view :

The two buttons on the right are used to navigate up and down in the menu, the left button select the entry and once an entry is selected, the right buttons allows you to change the current value.

Here is what you can find in the menu :

  • GO - start shoot session. 
  • Automatic (shoot count/interval/total time) - This allows you to choose the parameter that will be automatically computed. e.g. : if shoot count is selected, it will be deduced from the total time and the interval between shoots.
  • Interval - time between each shoot.
  • Shoot count.
  • Total time.
  • Use focus - Do or don’t do a focus before every shoot.
  • Focus duration.
  • Delay before first shoot.
  • Test mode.

There are two leds on the front, the green one is used to see if it is powerd on, the yellow one is use to know if the current menu entry is selected and also to know if we are in a shoot session (blinking every seconds).

I’ve also used the eeprom to store all the parameters, so you don’t have to set all your parameters everytime.

The software is 650 lines long, it’s not really optimized (well, I’m a bit lazy) but it’s working well, that’s all I ask.

I’m already thinking about some extensions, like triggers from sound or light events. There is still some room in the enclosure, not that much, but it can probably fit in.

If you are intersted in the software, I can post it … as I’ve sayed, it’s not optimized, not really well written, but it works.

Intro …

Welcome to the english-side of my blog. I’ve started it a bit more than a year ago and I post here all my electronic experimentations and developments …

Electronics is really a hobby for me, I’m learning  new stuffs every days … so, excuse me if sometimes I’m not really accurate or make mistakes …

This blog mainly talks about arduino and domotic stuff as it was my first goal when I’ve bought my first arduino months ago. But since then, I’ve tried other things not really domotic related and I’m sharing them anyways.

I’ll try to post new articles simultaneously in french and english, and from time to time I’ll probably translate old articles in english as well. If you have some specific requests, it doesn’t cost to ask :-) …

Don’t hesitate to comment articles or ask questions … this is also the goal of this blog.

Theme created by: Roy David Farber and Hunson. Powered By: Tumblr...
1 of 1