Sample cnc code

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

lensman57

Well-Known Member
Joined
Apr 17, 2011
Messages
398
Reaction score
32
Hi,

I need to machine a cylinder in to a hexagonal shape. It is mounted on a rotary table and set up for manual machining. The mill is equiped for cnc and so is the rotary table, a Sherline 4" one, I do have a copy of Mach3, is there anyway of obtaining a cnc code to do this? I have absolutely no cnc experience and don't know where to start. The last cylinder that I manually turned in to a hexagon took me over two hours and I ended up with a very bad shoulder.

Any help is very much welcome.

Regards,

A.G
 
You need some CAD type software to draw what you need to machine and then some CAM software to generate toolpaths and produce G-code for Mach3 to run.
There is some fairly cheap and versatile software called CAMBAM, which has some CAD capability built in. You can download a free trial which is fully operational for the first 40 uses. (I'm not affiliated with them at all, but I have played with this software).

In reality, the learning curve for what you're trying to do is a little steep, and you will probably end up investing several days or more into getting this part machined. But of course the next part you CNC will be quicker.

Good luck!
 
There are wizards in mach that can be used to generate g code for common operations. In this case you might be able to use one that does simple flat surfacing. Set it for the area of the flat on one side of the hex, mill one flat, then use an MDI command to rotate the work to the next flat and run the surface program again.

Mach has many free wizards, I dont recall if any of them do the surface.

The Newfangled wizard set is a $50 addon to mach. It does the surface operation, but it also has a spline function meant to do splines (groves) in a cylinder. I think if you used it and asked for splines of a width to cover the flat it might work. I dont have time right now, but Ill check that out later today.

And your request will cause me to modify the new V4 wizards so that the spline op can do that.
 
Hi Lensman

Do you know any programming language? For very simple work you can write a little program to generate your gcode without using a cad/cam. Sometime I do that with Visual Basic.
I can post some example if anyone is interested.

Roberto
 
Hi to all,

Thanks to everyone who replied to my post, I have looked at the surfacing wizard and I think that I might be able to adapt it for what I want doing but then the rotary will have to be done manually, not a big deal. Will try and see what I could come up with. I don't know any programming but I guess that I could learn. No doubt I shall be back for more help.

Many thanks and regards to all.

A.G
 
The code to mill one face would be straightforward, and then you'd manually turn the rotab 60 degrees to mill the next. However, there are a lot of parameters that go into generating that code, including:

diameter of the work and its material
diameter of the hex
depth of cut
size and type of endmill plus # of flutes
spindle power and max RPM

Once you have the program running, you'd need to know how to adjust feed rate and/or spindle speed if you get chatter or other bad sounds. I can supply you a sample program if you provide me the above data.
 
Hi kvom,

I am very gratefull for your offer. The object is to be machined in to a hexagonal shape, is for the cranck case of a rotary engine.
The material is 6082 T6 Aluminium, the diameter of the cylinder ( workpiece) is 1.75" and the distance between the two flats is exactly 1.5" therefore the total depth of cut on each face is 0.125". The tool is a 1/4" dormer 4 flute HSS cutter, uncoated and the max speed of the spindle is 2500 rpm. The mill ( a standard Taig ) can take a cut of 0.025" quite hapilly. The width of the flats is about 0.866" by my calculations and the lenght of the cranck case is exactly 1.25" plus a few thou for parting off and facing cuts later.
I hope that these are enough data for code generation.

Many thanks and regards,

A.G
 
Get some machinable wax and work with that till you get your code worked out. easier on tooling.

Dave
 
Couple more questions:

1) I am assuming stock is held vertically on the rotab. If horizontally please clarify.

2) How far below the collet holder does the endmill extend? I am assuming that it's at least the 1.25" needed for vertical mounting. For horizontal mount much less is needed.
 
Hi Kvom,

The part is actually held horizontally, parallel to the Y axis as I need to bore the cylinder holes and the mounting screw holes and the air feed channels for each cylinder on every flat, in fact if this cnc thing works out I might as well zero the tool on the center of the cylinder hole and use one of the wizards to cut the 0.625" holes. The tool extends exactly one inch from the collet.

Many thanks and Regards,

A.G
 
The basics of programming for the repeats is pretty easy. Basically you just program the operations for one side, then insert a command for the RT to index to the next and repeat as needed.

I have a similar setup using the Monster Mill from A2Z CNC and a Sherline CNC RT for making spoked wheels for vintage model airplanes. I'm drilling the rims for 40 spokes and hub with 10 holes per side as I use a continuous piece of monofilament for the spokes. Changing my code to your needs would basically result in the following.

G00 A0 (Rotary Table to 0 deg)
<mill for cylinder #1>
G00 A60 (Rotary Table to 60 deg)
<mill for cylinder #2>
G00 A120
<mill for cylinder#3>
G00 A180
<mill for cylinder #4>
G00 A240
<mill for cylinder #5>
G00 300
<mill for cylinder #6>

You can see my setup in action in this video.

[ame]http://www.youtube.com/watch?v=J4gAIdgHU74[/ame]

Thayer
 
Attached is a zipfile with a program that "should" work. Always test a new CNC program by cutting air before metal. I assumed that the face of the stock was to the right of the rotab, but if it's to the left it's an easy job to reverse it.

The zero point for the machining is on the face of the stock away from the rotab (X zero) and the top of the stock Z zero. Y zero is the center of the stock. You have about a +/-.05" margin on the XY zero, as the program is coded to machine each face 1.26" along the Y axis. I assumed your machine not rigid enough for climb milling, so all cuts are conventional.

For zeroing Z you can start by touching the endmill to the top of the stock. However, the stock may not be exactly 1.75" in diameter. If Z is set too low, you'll get a hex but slightly too small; if too high the corners will be rounded. What I would do is as follows:

1) Touch the top of the stock and set Z to -.01.
2) Run the program for one pass of .025 cut (hit mach3 stop and then rewind the program at the end of the first depth).
3) Turn the stock 180 degrees and repeat
4) Measure the distance between the milled faces.

The theoretical distance you should measure is 1.72", as the cut would remove .015 from each face. If it differs, adjust to match. To do this, use the following steps:

1) Move Z axis to -.01 (old top of stock)
2) Zero Z
3) Jog Z up if cut was too deep or down if too shallow by half the difference between your measurement and 1.72
4) Zero Z

You could then rerun the test steps on a second pair of faces to check your work.

Once set up the program should run in about 4 minutes per face. Cutting speed was calculated (G-wizard) at 12 IPM and the radial engagement is .2". The first pass at each level cuts air away from the face, so you should be able to get a visual clue that all is set up properly. I would single-step in mach3 the first time you run this cutting metal.

View attachment hex.zip
 
A G

Using the numbers you have posted I drew up what I think is your part.

crankcase_zps9331b94f.jpg


Here is the 2D drawing that Alibre generated

crankcasedrawing_zps6f669ecc.jpg


You will also find the Gcode that CamBam generated. It is for only one flat and .625 hole.
You would need to modify the code or manually rotate the part one flat and run it again for each flat.

I would run it using machinable wax before I ran it in Alu part.

Dave

View attachment Gcode crank case.zip
 
Last edited:
Hi to all of you,

Many many thanks for your kind help and taking time to help me out with this problem. I am really indebted to you all for your advice and help.

Best regards,

A.G
 
The basics of programming for the repeats is pretty easy. Basically you just program the operations for one side, then insert a command for the RT to index to the next and repeat as needed.

I have a similar setup using the Monster Mill from A2Z CNC and a Sherline CNC RT for making spoked wheels for vintage model airplanes. I'm drilling the rims for 40 spokes and hub with 10 holes per side as I use a continuous piece of monofilament for the spokes. Changing my code to your needs would basically result in the following.

G00 A0 (Rotary Table to 0 deg)
<mill for cylinder #1>
G00 A60 (Rotary Table to 60 deg)
<mill for cylinder #2>
G00 A120
<mill for cylinder#3>
G00 A180
<mill for cylinder #4>
G00 A240
<mill for cylinder #5>
G00 300
<mill for cylinder #6>

You can see my setup in action in this video.

http://www.youtube.com/watch?v=J4gAIdgHU74

Thayer


I gotta say those are some sweet wheels you make! Very cool for vintage airplanes and being able to produce the size you need to boot... Very Cool ;)
 
The endmill stated above may not be center cutting, so doing the center hole as part of the same OP as the flats may fail. If you want to do so then a center cutting endmill is needed.

To avoid lots of tool changes, do an operation on all flats with each tool before changing.
 
If using a non center cut end mill. You tell CamBam to ramp into the cut using the correct angle and distance so the end mill will make the pocket.
I did not do that with this example but it can be done.

Dave
 

Latest posts

Back
Top