Monthly Archives: November 2014

ShapeOko 2 tutorial – Dominion turntable – part 4

If you missed part 3, please find it here.

Splitting g-code

So far we have created a drawing in OpenSCAD and generated 4 g-code files in FreeMILL: two files with a flat tool and a step distance of 2,8 mm (one in each direction) and two files with a ball nose tool and a step distance of 0,4 mm (one in each direction).

The two files created for at ball nose tool and a step distance of 0,4 mm are going to be used for the last two runs to finish the surface and to make it nice and smooth. The other two files are going to the split into several smaller files that will allow the CNC machine to work its way down into the material one millimeter at a time.

For that purpose I created a small program (with some valuable input from my friend Mads) which will do just that. It’s called G-Code Utility and can be downloaded here. Use it at your own risk! It comes with no warranty so please test the generated g-code before using it – for your own safety! G-Code Utility is built for this purpose only: Splitting g-code generated in FreeMILL as described in my earlier post! Remember: Carefulness is essential when working with high powered, fast spinning sharp tools like a CNC machine. I cannot stress that enough…

G-Code Utility

Since the g-code generated by FreeMILL describes the surface of our Dominion turntable and the ShapeOko 2 isn’t capable of milling the deepest holes (the deepest hole is 18 mm deep compared to the surface of the stock) in one run, we have to do something.

What G-Code Utility does is this: Finds the deepest place on the surface (here it is -18 mm), adds one millimeter (can be changed) and generates a file with the g-code that will cut anything below that limit (in this case -17 mm). Adds another millimeter to the limit and generates a new file with the g-code that will cut anything below this new limit (in this case -16mm) and so on.

Furthermore, it adds the current limit to the z-values in the file so we can run all of them from the same zero and it will try to choose the next path to be the one closest to the current machine position. This may sometimes generate an odd choice for the next path since it’s a mathematical calculated value – and not the logical choice for a human!

Β Splitting the g-code in the x-direction

When you start G-Code Utility it looks like this:

The G-Code Utility interface

The G-Code Utility interface

Go to File -> Input file and select the g-code file generated by FreeMILL and press “Open”. Remember, we are using the file we generated for a flat tool 3,2 mm i diameter and with a step distance of 2,8 mm. In my case it’s called “mads5c_3.2_flat_2.8_step_x.nc” as seen in the screen dump.

Input file selection

Input file selection

Now, got to File -> Output file and type in the name that you want to prefix your output files and press “Save”. In my case I choose “mads5c_3.2_flat_2.8_step_x_mod.nc” (“mod” for “modified”).

Output file

Output file selection

G-Code Utility will then generate files with file names on the form “mads5c_3.2_flat_2.8_step_x_mod(limit -X.XX).nc” where X.XX is the limit used in that particular file.

Go to Setup -> Options to display the options:

Options

Options

The default options displayed above are the option I use for my ShapeOko 2. They should be quite easy to understand but here’s the explanation anyway:

Decimals -> Reduce decimals

Check to reduce decimals in the code. There is no reason to use more than 4 decimals when sending coordinates to the g-shield.

String length -> Reduce length

Check to reduce string length. The g-shield can only take strings of length 50 characters. You can change it if you use another shield.

Step size -> Step size in mm.

Change to change the difference in depth used in the files generated by G-Code Utility. Never use a value larger than half the diameter of the tool you’re going to use.

Step size -> Split output into several files

If unchecked G-Code Utility will only generate one output file with the g-code for each step collected in section so the CNC machine will first run g-code for maximum depth plus limit, then code for maximum depth plus 2 time the limit, and so on.

Path optimization -> Optimize path

If unchecked G-Code Utility will not try to take the closest path as the next one. Instead it will simply take the next path in the original file.

Speed -> Movement speed

The movement speed (when not cutting) in mm per minute.

Speed -> Cutting speed

The speed in mm per minute when cutting.

Speed -> Engagement speed

The speed in mm per minute used when moving the cutter into the stock (downwards). Should in my experience never be more than 1000 mm/minute. Values higher than 1000 can cause the z-axis stepper motor to skip some steps.

Speed -> Retraction speed

The speed in mm per minute used when moving the cutter out of the stock (upwards). Should in my experience never be more than 1000 mm/minute. Values higher than 1000 can cause the z-axis stepper motor to skip some steps.

Safety height -> Safety height in mm

Determines the distance above the stock where the CNC machine can safely move without cutting. Should never be less than 1.

Processing

When you’re satisfied with your choices, press “Start processing” in the main window. It will process the file in the background and tell you the result in a dialog. The three progress bars will tell you how your job is progressing.

Thats it! We’ve now split the original file into several files with limits from -17 mm to -1 mm. Now we just need to repeat the process with the file for the y-direction.

Output files

Output files

Control the g-code files generated by G-Code Utility

I always check the generated g-code files with a g-code viewer (there are several versions available – even on-line versions) just to see if it looks reasonable to me. In this case I’ve shown the file “mads5c_3.2_flat_2.8_step_x_mod(limit -7.00).nc” viewed in Universal Gcode Sender in file mode.

The file with limit -7.00 viewed in Universal Gcode Sender

The file with limit -7.00 viewed in Universal Gcode Sender

When you feel comfortable with the g-code you’ve generated it’s time to go to the workshop! πŸ™‚

PS! Bug reports and suggestions for G-code Utility are very welcome.

Part 5.

ShapeOko 2 tutorial – Dominion turntable – part 3

If you missed part 2, please find it here.

Generating g-code in FreeMILL

In part 2 we created the drawing in OpenSCAD and generated STL-files for each quarter. Now It’s time to generate some g-code so we can start milling soon. πŸ™‚

If you (like me) downloaded FreeMILL from MecSofts homepage you’ll have noticed that FreeMILL is actually a plug-in in the VisualCADCAM demo. This is exactly the way it’s supposed to be!

When you start the VisualCADCAM demo you’ll get two splash screens. The first one disappears when you click ‘Ok’. In the second splash screen simply select FreeMILL and click ‘Ok’ to open VisualCADCAM in FreeMILL mode.

VisualCADCAM splash screen

VisualCADCAM splash screen

VisualCADCAM then opens the help window and the main window shown below. It has the FreeMILL wizard opened to the left – this is what we will be using.

VisualCADCAM main window with the FreeMILL wizzard to the left

VisualCADCAM main window with the FreeMILL wizard to the left

First we have to open one of the STL-files that we created in OpenSCAD. Do this by clicking File -> Open and select your STL-file. VisualCADCAM will ask you if you want to save the current file – if you just opened VisualCADCAM you can safely answer ‘No’ because the initial file is empty. In the photo below I’ve opened the 3rd quarter STL-file:

VisualCADCAM with STL-file loaded

VisualCADCAM with STL-file loaded

Now it’s time to put the FreeMILL wizard to work. The wizard contains 7 steps which we will complete one at a time.

1) Set cutting direction

Just leave it as it is (World Z selected). I’ve never changed it and to be honest: I have no idea why I ever should!

2) Create Part Bounds Stock

I set ‘X Off’ to 10 mm and ‘Y Off’ to 10 mm and leave ‘Z+ Off’ to be 0. I do this to prevent FreeMILL from getting the idea of trying to do something fancy on the edges. I’ve seen this in a few cases and it spells trouble for my project.

Step 2: Create Part Bounds Stock

Step 2: Create Part Bounds Stock

3) Set Work Zero

Now, this is important! Viewed from above the ShapeOko 2 is working in a Cartesian coordinate system in the x, y plane. In our case we’re going to cut the quarter of the Dominion turntable where both x and y have negative values (the 3rd quarter), so we select ‘Set to part box’, ‘Highest Z’ and ‘North East’ like in the photo below. This will cause FreeMILL to create g-code with negative x and y values since everything will be calculated from that point.

Ste 3: Set Work Zero

Step 3: Set Work Zero

For the 1st quarter STL-file I will select ‘South West’, for the 2nd quarter STL-file I will select ‘North West’ and for the 4th quarter STL-file I will select ‘South East’. In other words: I will always select the corner that represents the center of the Dominion turntable as my work zero and leave the cutting direction as it is!

4) Create Cutting Tool

In the first run we’ll be using a roughing tool path so we’ll be using a flat cutter. Select the flat cutter icon and set the diameter, flute length and the tool length. In my case I’ll use a 3,2 mm diameter cutter tool with flute length 15 mm and tool length 20 mm. Holder length and holder diameter I leave as is.

Step 4: Create Cutter Tool

Step 4: Create Cutting Tool

5) Set Cutting Feeds and Speeds

Again, these values depends our what CNC-machine you are going to use. In my case (ShapeOko 2 with a Kress FME 800 spindle) I set the following speeds: Spindle speed 30000 RPM, Cut Feed (Cf) 1000 mm/min, Engage Feed 500 mm/min and Retract Feed (Rf) 500 mm/min. After some trial and error I’ve found these feeds and speeds to be a good choice for the ShapeOko 2.

Step 5: Set Cutting Feeds and Speeds

Step 5: Set Cutting Feeds and Speeds

Β 6) Create Machining Operation

Since we are creating a roughing operation I select a step distance of 2,8 mm so I get a little overlap (my tool is 3,2 mm i diameter). Then select the cut direction to ‘Along X’ and press ‘Generate’. FreeMILL will then generate the tool path and display it as blue lines in the window.

Step 6: Create Machining Operation

Step 6: Create Machining Operation

If you press ‘Simulate and select ‘Display cut model’ you’ll see what the model will look like after we cut it. The jagged edges are caused by the fact that we’ve used a flat cutter and a step distance of 2,8 mm.

Simulated cut model

Simulated cut model

7) Post-Process Operation

This is where we will generate the actual g-code that we’re going to use. VisualCADCAM comes with a lot of post-processors for a large variety of CNC-machines. To generate g-code that the ShapeOko 2 understand (or actually the Arduino and the g-Shield), please select ‘WinCNC_MM’ as your post-processor. If you’re using a different kind of CNC-machine you might have to select a different post-processor.

Step 7: Post-Processing Operation

Step 7: Post-Processing Operation

When you press ‘Post’ you’ll be asked for a file name (saving the file will take some time). I tend to use file names like ‘Dominion_C_3.2_FLAT_2.8_STEP_X.nc’ but feel free to find your own system to identify the correct files later on. When FreeMILL has saved the g-code in a file, it will open that file in notepad for you to inspect the g-code.

More steps to complete…

We then repeat steps 6 and 7 (leaving the choices in steps 1 to 5 as before) to create a roughing operation in the y-direction by selecting ‘Along Y’ in step 6 (same step distance, etc.) and generate a tool path in the y-direction.

Furthermore, we repeat steps 4, 5, 6 and 7 again (leaving the choices in steps 1 to 3 as before) in both directions but in step 4 we create another tool: A ball mill (in my case 3,2 mm diameter, 15 mm flute length and 20 mm tool length) with the appropriate dimensions.

Ste 4: Creating a ball mill tool

Step 4: Creating a ball mill tool

Step 5 will be the same as before but in step 6 we select a ‘Step Distance’ of 0,4 mm for both the x and the y-direction.

Step 6: Step distance of 0,4 mm in both directions

Step 6: Step distance of 0,4 mm in both directions

Now we have created 4 g-code files: two files with a flat tool and a step distance of 2,8 mm (one in each direction) and two files with a ball nose tool and a step distance of 0,4 mm (one in each direction). We now have the g-code files we need for cutting the 3rd quarter of the Dominion turntable. πŸ™‚

Part 4.

ShapeOko 2 tutorial – Dominion turntable – part 2

If you missed part 1, please find it here.

Drawing in OpenSCAD

OpenSCAD is a software for creating solid 3D CAD objects. It is free software and available for Linux/UNIX, MS Windows and Mac OS X. Take a good look at the homepage where you’ll find tutorials, cheat sheets and other documentation.

When you open OpenSCAD it will already contain an empty drawing. If not, please create a new drawing by pressing <Ctrl>+N or by clicking File -> New in the menus.

First of all the turntable is a very low cylinder with radius 274 mm and height 26 mm: The following code will create just that:

cylinder(h=26,r=274);

Press F6 to make OpenSCAD compile and render the drawing. Furthermore, I like to have the upper surface located at (0,0,0), so we will translate the cylinder along the z-axis by -26 mm because the cylinder-command draws the cylinder above z=0 by default. The code will look like this:

translate(v=[0,0,-26])
{
    cylinder(h=26,r=274);
}

To compile and render your drawing, press F6. Our drawing is just a cylinder at the moment with no space for the cards. We’ll change that by subtracting a set of boxes from our cylinder but first we will make a function (called a module in OpenSCAD) that can draw a box with a given set of dimensions. Our module called box looks like this:

module box(xdim, ydim, zdim)
{
    translate(v=[0,0,-zdim/2])
    {    
        cube([xdim, ydim, zdim], center = true);
    }
}

The built-in function cube draws the box given a vector of x-, y- and z-dimensions. The parameter center=true will make OpenSCAD draw our box centered around (0,0,0), so we translate the box along the z-axis by half the given height (the parameter zdim).

Our box (or actually holes for the cards) will have the dimensions 94x62x15 mm, so we need to draw the cylinder, draw the box and make OpenSCAD subtract the box from the cylinder to create the effect that we want. The keyword for subtracting one solid from another is difference so our code put together looks like this:

difference()
{
    translate(v=[0,0,-26])
    {
        cylinder(h=26,r=274);
    }
    box(94,62,15);
}

module box(xdim, ydim, zdim)
{
    translate(v=[0,0,-zdim/2])
    {    
        cube([xdim, ydim, zdim], center = true);
    }
}

After compiling and rendering the drawing looks like this:

Cylinder minus box

Cylinder minus box

We want 8 holes for the stacks of cards in the center: 5 holes 15 mm deep and 3 holes 5 mm deep. Furthermore, we want the walls between the holes to be 12 mm so we’ll translate them (94 + 12)/2 = 53 mm (and – 53 mm) along the x-axis and (62 + 12)/2 = 37 mm (or i*74 + 37 mm for some value i ) along the y-axis. Thus we add another module (called boxes) to draw the holes and to translate them to the right positions. It looks like this:

module boxes()
{
    for (i=[-2,1])
    {
        translate(v=[53, i*74 + 37, 0])
        {
            box(94,62,15);
        }
    }
    for (i=[-1,1])
    {
        translate(v=[53, i*37, 0])
        {
            box(94,62,5);
        }
    }
    for (i=[-1:1])
    {
        translate(v=[-53, i*74 + 37, 0])
        {
            box(94,62,15);
        }
    }
    for (i=[-2])
    {
        translate(v=[-53, i*74 + 37, 0])
        {
            box(94,62,5);
        }
    }
}

The construction for (i=[-2,1]) makes i take the values -2 and 1 during the two loops, while the construction for (i=[-1:1]) makes i take the values -1, 0 and 1 during the three loops. Thus the four loops will draw 8 boxes all together. We then change the first code to:

difference()
{
    translate(v=[0,0,-26])
    {
        cylinder(h=26,r=274);
    }
    boxes();
}

and press F6 to compile and render the drawing again. We now have:

Cylinder minus holes

Cylinder minus holes

Much better! But there is a problem: It’s almost impossible to get a card from the stack in the holes, so we’ll have to add some space for the players fingers in the walls between the holes. We’ll makes this space by subtracting boxes with dimensions 40x24x18 mm and translate them into their right positions in a new module named fingerholes.

module fingerholes()
{
    for (i=[-2:2])
    {
        translate(v=[53, i*74, 0])
        {
            box(40,24,18);
        }
        translate(v=[-53, i*74, 0])
        {
            box(40,24,18);
        }
    }
}

Again we’ll add a call to our new module in the code making the subtraction:

difference()
{
    translate(v=[0,0,-26])
    {
        cylinder(h=26,r=274);
    }
    boxes();
    fingerholes();
}

Press F6 to compile and render:

Cylinder minus boxes and finger holes

Cylinder minus boxes and finger holes

To finish the center of the turntable we’ll add four holes for coins and tokens. These holes will be the shape of a drop (sort of) and be created by subtracting a convex hull constructed over two spheres with radius 16 and 32 mm translated to the places outside the 8 holes already created. Thus we add a new module called holes:

module holes()
{
    hull()
    {
        translate(v=[138, -32, 20])
        {
            sphere(r=32, center=true);
        }
        translate(v=[127, -87, 4])
        {
            sphere(r=16, center=true);
        }
    }
    hull()
    {
        translate(v=[-138, -32, 20])
        {
            sphere(r=32, center=true);
        }
        translate(v=[-127, -87, 4])
        {
            sphere(r=16, center=true);
        }
    }
    hull()
    {
        translate(v=[138, 32, 20])
        {
            sphere(r=32, center=true);
        }
        translate(v=[127, 87, 4])
        {
            sphere(r=16, center=true);
        }
    }
    hull()
    {
        translate(v=[138, -32, 20])
        {
            sphere(r=32, center=true);
        }
        translate(v=[127, -87, 4])
        {
            sphere(r=16, center=true);
        }
    }
}

We’ll add a call to our newly created module to the code at the beginning of our file:

difference()
{
    translate(v=[0,0,-26])
    {
        cylinder(h=26,r=274);
    }
    boxes();
    fingerholes();
    holes();
}

After compile and render our drawing looks like this:

Cylinder minus boxes, finger holes and holes

Cylinder minus boxes, finger holes and holes

Now we’re almost done. All we need is to create a ring of 16 holes at the perimeter of our turntable but these holes will not be regular boxes: we want the holes to have a slope towards the center of the turntable by making them have a depth of 5 mm farthest away from the center and a depth of 8 mm closest to the center. In other words we’ll subtract a ring of wedges from our cylinder.

Furthermore, we would like to make a notch (in the shape of a quarter sphere) at the edge of the cylinder in each hole so the stack of cards can easily be removed all at once. The wedge and the corresponding sphere are created by the following module:

module wedge()
{
    translate(v=[0,-94,0])
    {
        polyhedron(points = [
            [-31,0,-5],
            [31,0,-5],
            [31,94,-8],
            [-31,94,-8],
            [-31,0,0],
            [31,0,0],
            [31,94,0],
            [-31,94,0]
            ],
            faces = [
            [0,1,2,3],
            [1,5,6,2],
            [0,4,5,1],
            [0,3,7,4],
            [2,6,7,3],
            [4,7,6,5]
            ]
        );
        translate(v=[0,0,-5])
        {
            sphere(r=10);
        }
    }
}

A wedge is drawn using the command polyhedron that takes a list of points and a list of faces. The wedge is constructed from 8 points and 6 faces, where each face is defined as a list of points listed clockwise seen from the outside of the wedge (take a look at the documentation: they explain it much better than I can). At the end we add a sphere with radius 10 mm.

The code above defines a wedge with 5 mm depth in one end and 8 mm depth in the opposite end. The deep end is located at (0,0,0). To make it a ring of 16 wedges we then create the following module that creates the wedges, translates them -180 mm along the y-axis and finally rotate them i*1/16 + 1/32 of a full circle, for i = 1, 2, … , 16:

module wedgering()
{
    for (i=[1:16])
    {
        rotate(i*360/16 + 360/32,[0,0,1])
        {
            translate(v=[0,-180,0])
            {
                vedge();
            }
        }
    }
}

Finally, we create the entire drawing as a module and replace the code in the start with a call to that module:

drawing();

module drawing()
{
    difference()
    {
        translate(v=[0,0,-26])
        {
            cylinder(h=26,r=274);
        }
        boxes();
        fingerholes();
        holes();
        wedgering();
    }
}

We then add the value 1 to an internal variableΒ $fa at the very top of the file. This value will cause OpenSCAD to make a smoother drawing:

$fa=1;

drawing();

After compile and rendering (which takes quite some time) we have the final drawing:

Dominion turntable drawing

Dominion turntable drawing

The final OpenSCAD-file can be downloadedΒ here as a zip-file.

To export the drawing as an STL-file (which we will need in the next step), select File -> Export -> Export as STL. This will give us a STL-file of the entire turntable but since the ShapeOko 2 has a work area of 300×300 mm we need to break it down into smaller pieces. We do this by adding a little more code to the OpenSCAD file:

intersection()
{
    rotate(0,[0,0,1])
    {
        translate(v=[0,0,-20])
        {
            cube([300,300,40]);
        }
    }
    drawing();
}

By using rotate(0,[0,0,1]), rotate(90,[0,0,1]), rotate(180,[0,0,1]) and rotate(270,[0,0,1]) we get the following four quarter circles:

1. quarter

1st quarter

2. quarter

2nd quarter

3. quarter

3rd quarter

4. quarter

4th quarter

We then export each of them as a STL-file so we can generate g-code for each quarter separately. My plan is to mill each quarter separately (or actually two together by moving the board between milling each quarter) but more on that later.

We now have the STL-files we need for the next step in the process.

See you next time. πŸ™‚

Part 3.

ShapeOko 2 tutorial – Dominion turntable

Introduction

This is the first part of my tutorial on using the ShapeOko 2 for building a Dominion turntable looking a little like this one.

First of all you’ll need a CNC machine. I got mine from Inventables and upgraded it with a Kress 800 FME spindle (the ShapeOko forum has some nice posts on the bigger Kress 1050 spindle). I posted some posts about building my ShapeOko 2 (here’s another one). I’m very pleased with the performance of my new spindle. The stock spindle (the Dremel clone) wasn’t strong enough for continuous work in my opinion.

Then there is software: there is a lot of free and open source software out there for the purpose of drawing, generate g-code and sending the g-code to the ShapeOko 2. I find the following combination of software useful:

OpenSCAD: An open source CAD program. It doesn’t have a lot of fancy drag and drop features but it is solid and gets the job done. There is a lot of documentation and tutorials on the homepage for the beginner so don’t be scared by the programmatic approach (which suits a mathematician and programmer like me very well πŸ™‚ ).

Inkscape: Another open source program for drawing SVG files which sometimes are handy when creating simple tasks for the ShapeOko 2. Again the homepage contains a lot of useful information for the beginner: tutorials, videos, blogs and a strong community.

MakerCAM: An on-line g-code generator. It’s simple to use and I use it for simple tasks. A good tutorial on how to use Makercam can be seen here and some more useful information can be found here.

FreeMILL: A free program from MecSoft (thank you for making this excellent program free πŸ™‚ ). If you get fascinated by making things on a CNC machine (like me) then you should consider some of their non-free products (no, I don’t get paid for writing this!).

Grbl Controller: A open source g-code sender for communicating with the CNC machine. There is also a tutorial on how to run Grbl Controller on a Raspberry Pi. A list of g-code senders can be seen here.

Last but not least: I needed a small utility for breaking down the g-code generated by FreeMILL so I made one (I will make it available for download later on). The thing is that FreeMILL generates g-code describing the surface of a solid (imported as STL) which often isn’t possible for the ShapeOko 2 to run directly because the cuts are simply too deep for the machine to handle in one run. Therefore, I created a small tool to break down the file from FreeMILL so it can be milled a few millimeters at a time. I’ll write more about it, when we reach that part. πŸ™‚

At the end of this tutorial we’ll have created something like this:

Dominion turntable

I’ll take you through the process step by step and tell you about my experiences with the ShapeOko 2 along the road (Murphy has been a very frequent but uninvited guest in my workshop since I got my ShapeOko 2!). πŸ™‚

Part 2.

New season

It’s been a long and nice summer and it’s been a while since my last post. But now I’m back in woodworking mode. πŸ™‚

A fiend of mine asked me if I can make a Dominion turntable on my ShapeOko 2. The turntable should look a little like this one but with some changes to his likings and made from a nice hardwood. This is a challenge and an opportunity that I cant pass.

It’s a challenge because I have to make two halves since the ShapeOko 2 has an effective working area of 290×290 mm.

And it’s an opportunity because I can make it a tutorial presenting some of the tools I find useful when working with my ShapeOko 2.

/Henning