mBed Based CNC machine

01 Jan 2010

Hi people,

I have been busy working on a mbed based CNC controller following the good work of the people at RepRap...

I already have a working solution based on the more basic version of their GCODE interpreter (modified for a CNC router (subtractive process)) ported over to the mbed however....

It lacks functionality such as lookahead, ramping etc,

I have an Arduino version of the interpreter which does this but i'm struggling to port over to the mbed (as it is an uphill struggle for one novice man!) as it uses timer interupt routines for stepping etc. If anyone is interested in a CNC controller (Can interpret Gcode from a file and perform 3 axis linear interpolation and 2 axis circular) please let your interest known to my self! (michael at mickduffin.com) or indeed here on this thread!

I have sucsessfully used the basic version I have to controll a 3 axis machine, It can Mill, engrave, laser etch.... whatever!




01 Jan 2010

Hello Mike,

I am interested in this as well, is there a link for the program?



02 Jan 2010

Mike, I'm also interested and would like to see your code, and details of what you've built.  RepRap is a 3D printer, it sounds like your project is more like contraptor?




02 Jan 2010
Steve Ravet wrote:

Mike, I'm also interested and would like to see your code, and details of what you've built.  RepRap is a 3D printer, it sounds like your project is more like contraptor?




Hi, Yes RepRap is a 3D printer, They use an Arduino that interprets GCODE and generates step & direction to control the machines movement. My machine is a conventional mill / router. The code will work for a subtractive process like milling as well as an additive process (extruding like the RepRap).

All I have done is strip out anything extruder related and put a few custom "M" codes in to turn on/off my router when required. The best thing about the RepRap controller is that the host or PC need only be capable of outputting strings of text over serial.

Eg; Connect mbed/arduino to pc. Send command "G1 X100 F400" over serial and the X axis will move 100mm at 400mm per min.


The version I would like some help porting is at the RepRap Forums, The one I have currently ported over is the more basic one available on the main RepRap page. (will post a link after I tidy it up a little!).

The mbed opens up a lot more options as we don't really need a PC at all to control the machine as we can simply read lines of GCODE straight off a memory stick/local file system.




13 Jan 2010

Hi Mike,

I'm working on mbed CNC machine controller for my Sherline mill (3-axis plus spindle and coolant control). I like the idea of an on-board G code interpreter. I wrote a simple version a few years ago for an engraving machine, and have software to convert CAD drawings to G-code. My version only did linear interpolation, could not get circular to work.

Right now I'm fighting my way through LPC1768 features not covered by the mbed library like  the 32-bit timers timer0 and timer1.

I would be happy to work with you on a joint project.


13 Jan 2010

Hi John,

Have you looked at the RepRap code? It does everything you should need for a 3 axis milling, I have been porting that over to the mBed but have had troubles.

Some of the Gcode generated by a package I use (and other packages) spline circular moves into loads of little linear moves, This is fine usually but as we need to either feed in GCODE line at a time over RS232 or (as I have been playing with) read the lines in through the Local file system. With all these tiny  (< 0.1 mm) the mBed can't keep up with all the processing, accel calcs and stepping.

I would also like to know how to use the aditional timers (no one resonded to my post asking for help! ). A simple idiots guide will do for now!!!! I think with a timer for each axis would be the best approach and would make linear interpolation very simple removing an amount of processing.

Again If it was in some way similar to the RepRap firmware I would do alot more processing out of the moves. By this I mean read the whole file line at a time parse & process then then generate a second file to be read from on the fly during the motion routines. It would contain step & output data only.  Eg, XXX,YYY,ZZZ,###. The XYZ would be number of steps for each axis (pos or neg) rather than measurment units for the given move followed by a handful of bits to set output states or PWM values for spindles/lasers etc.

Below is a photo I laser etched with a 150mw!! Blu-Ray DVD diode. The machine was powered with an mBed!! Was dead easy as only contained 2 axis linear moves. The GCODE for it was generated by a VB app I wrote that uses error diffusion dithering to create the darker/lighter areas.

Here's another etching some tufnell!

Here's a nice render of the machine.




13 Jan 2010 . Edited: 13 Jan 2010

Here is the published code if anyone is interested in HELPING!!!!



Now contains accel / decel .


13 Jan 2010

Thank you Mike!


13 Jan 2010
Angel Imaz wrote:

Thank you Mike!


No probs,

let us know how you get on!


16 May 2010

Hi Michael

I 'm interesting in that laser etching CNC you have above

Can you share some more info about it?

It;s a DIY project or a modified machine.


Thanks in advance


Y.S. I wish i can help in coding in Mbed but i 'm a novice with it..

28 May 2010
Michael Duffin wrote:

Here is the published code if anyone is interested in HELPING!!!!



Now contains accel / decel .


Hi Mike,

I'm late to the game but definitely interested in helping out here.  It's something I need for a new project I've just started.

But the link to your source doesn't work anymore.  Can you update it?



27 Sep 2010


Just got an mBed module myself and I was about to start porting code from an Arduino based CNC controller (http://groups.google.com/group/rstep) when I made a quick search for mBed + CNC and found your post.

I wonder if you are still looking at this as an option and perhaps give me some pointers. As you mentioned, timers/interrupts would be the way to go. Let me know if you still like some collaboration. I have done significant Cortex M3 programming to be of some use.



16 Nov 2010

Does any body have a copy of


that they could post as this link is no longer working and this would be really helpful to lots of people.


30 Apr 2011

Hi !

I just started coding a gcode interpreter for mbed, I'd be very very interrested to talk with you. Can you contact me at wolf.arthur@gmail.com ?

Thank you !

06 May 2011

Code for our XY laser project in online at


Please feel free to use and extent the functions. It is work in progress. It does not directly use GCODE (might do in the future). 3D printer use is one of the possible uses. It is combined with a CUPS printer driver and simulation program (See wiki.laoslaser.org) Contributions are welcome!

03 Sep 2011

Hi does anyone know of a laser that can be used to 'eatch' copper from FR4 PCB material ?

Ideal from UK source.



08 Sep 2011

google is your friend: search for etching with laser pcb :-)

28 Jan 2012


Idea today that they have a cod effort the Plc running on a different board: http://reprap.org/wiki/List_of_Firmware#Teacup

The board: http://www.3dprinting-r2c2.com/

So now it will be very easy as the code is for free from the Org and just need to set it and build a driver board.

What do yo think?

28 Jan 2012

If you want to do CNC with a mBed, you probably want to take a look at Smoothie : http://smoothieware.org/ it has been going forward very fast since my last post here. It can do CNC milling, laser cutting, and 3D printing, and has tons of features, like file-based config, composite mass-storage/cdc-serial usb interface, extremely good acceleration/planning support. It's also designed in a completely modular way, so if you want a basic CNC firmware to build on top of for your project, you probably want to take a look here : http://smoothieware.org/howitworks and here http://smoothieware.org/moduleexample Here is a guide on how to wire it on a breadboar also : http://smoothieware.org/howitworks

Cheers !

24 Mar 2016

Hello Mike

since I'm very interested on cnc and I'd like to make my version of pocket engraver (http://www.instructables.com/id/Pocket-laser-engraver/) could you please send me your code since , if I understood well, you did something similar (porting of grbl code into mbed right?) could you please share the code woth me in order to understand better it and so on? Many thanks for your help!!!!!!!!! Regards Lorenzo

28 Mar 2016

Hi Lorenzo, this thread is six years old. Might have more luck with a Personal Message rather than a forum post.