PDA

View Full Version : Code to plunge Z gradually and then retract along length of a profile path.



Wal
05-02-2015, 01:08 AM
Vectric's Cut 2D does an admirable job of generating 2D tool-paths, but I'm wondering if there's a bit of G-code that's available to add in which will plunge the cutter to a specified Z depth as it travels to it's halfway point along the 2D path and then retracts the cutter as it travels along the second half of the path. I imagine many of the programs that carve letter-forms into wood use this technique, but is the Z-depth explicitly specified in each line as the G-Code is generated, or is it controlled by a clever bit of programming at machine level?

http://www.mycncuk.com/attachment.php?attachmentid=14588&stc=1

Wal.

Boyan Silyavski
05-02-2015, 09:33 AM
Fluting Toolpaths
Vcarve Pro and Aspire have it.

http://www.mycncuk.com/attachment.php?attachmentid=14594&stc=1


http://www.mycncuk.com/attachment.php?attachmentid=14591&stc=1http://www.mycncuk.com/attachment.php?attachmentid=14592&stc=1

Wal
05-02-2015, 11:51 AM
>Vcarve Pro and Aspire have it.

Indeed they do, but I'm not using either of 'em... I was after a manual tweak that I could make to my standard profile code. Any chance you could output me some G-code for a fluted straight and a fluted curved line to see how it's being done? (If you could do examples of a linear and a smooth ramp that would be cool!)

Cheers!

Wal.

Neale
05-02-2015, 11:57 AM
Quick answer is that the gcode instruction to cut a straight line (G1) generally has up to three coordinates included. If you are cutting in 2D, then these are the X and Y coordinates to which the tool should move; no Z coordinate so the tool stays at same height. If you want height/depth of cut to vary along the path, then you add a Z coordinate and the motion control software will calculate the tool path so X, Y and Z all vary at the right rate to get to the end point in a straight line. So the answer to your question is that yes, the Z move is part of the generated gcode. Aspire, vCarve, etc, all do this when generating 3D cutting gcode. If you were really keen, I suppose that you could find all straight cutting moves, and edit them to include an intermediate point with lower Z point plus original Z value in the original point. Doesn't sound like an easy job to me! Probably why Cut3D costs rather more than Cut2D...

Boyan Silyavski
05-02-2015, 12:07 PM
14601 100 mm OD circle, 100mm line and 100mm/10mm arc

Hope that will help
http://www.mycncuk.com/attachment.php?attachmentid=14599&stc=1http://www.mycncuk.com/attachment.php?attachmentid=14600&stc=1

Wal
05-02-2015, 12:16 PM
Cheers Neale.

Yeah, I have Cut3D - another excellent piece of software from Vectric - but the way that it generates its cut files isn't exactly practical (and very long-winded) for simply adding a couple of fluted lines to a face.

Heh - I don't fancy scrolling down through thousands of lines of code and manually adjusting z-depths...

Perhaps a G19/G18 arc might be worth exploring?

http://www.cnczone.com/forums/g-code-programing/16753-z-axis-arc-g-code.html

Hmm, but thinking about it they're in X/Z or Y/Z so anything other than a straight vertical or horizontal line isn't possible...

Wal
05-02-2015, 12:17 PM
Cheers Boyan. Much appreciated! As Neale said - new z value on each line, which is what I suspected.

Thanks again!

Wal.

Rufe0
17-11-2015, 04:26 PM
Just out of interest why would you want to arc in and out with the Z?

Wal
17-11-2015, 05:06 PM
Just out of interest why would you want to arc in and out with the Z?

In my case it was for aesthetics - I was looking at engraving into 3-ply acrylic (black/white/black) with a ball-nose cutter, using this technique would have given me a variation in line thickness along the path. Kinda like this:

16551

Wal.

Rufe0
17-11-2015, 05:50 PM
Ok yeah well if its exactly that shape you want to make (spiral) you should learn some gcode, its very simple to do in gcode. Something like

G0 X10 Y10
G2 X20 R5
G2 X11 R4.5
G2 X19 R4
G2 X12 R3.5
G2 X18 R3
G2 X13 R2.5
G2 X17 R2
G2 X14 R1.5
G2 X16 R1

Then it would be trivial to add your Z depth.

If you wanted to use code generated by a program its probably going to be 1000s of tiny straight line moves. I could perhaps make a small program for you that will tack on the Z depth but it wouldn't be as good as hand written code.

Wal
17-11-2015, 07:01 PM
Hi Rufe0,

You're right, I should learn some G-code..! You're also right about my G-code being a series of thousands of smaller moves (as output by Vectric's cut 2D) so adding z-variation to existing code wouldn't be as straightforward as perhaps it ought to be. Unfortunately (heh, or fortunately, rather) it's not just spirals I need to do..!

Out of interest - how would you go about adding the z-arc on the code you've used above..?

Wal.

Rufe0
17-11-2015, 07:24 PM
Assuming 3mm thick with each ply being 1mm thick and the cutter just touching the surface at 0mm
G21
M6 1
M3
G0 Z20
G0 X10 Y10
G0 Z0.2
G1 Z1 F30
G2 X20 R5 F1000 Z-1.2
G2 X11 R4.5 Z-1.4
G2 X19 R4 Z-1.6
G2 X12 R3.5 Z-1.8
G2 X18 R3 Z-1.8
G2 X13 R2.5 Z-1.6
G2 X17 R2 Z-1.4
G2 X14 R1.5 Z-1.2
G2 X16 R1 Z1
G0 Z20
M30

Wal
17-11-2015, 07:30 PM
Ah - ok, so the Z's still going in manually - wouldn't doing it like this leave each G2 arc on a 'step' (as opposed to a smooth dip in and out along the entire length)..?

Wal.

Rufe0
17-11-2015, 07:39 PM
It should look fairly smooth, seems to in the simulation software i'm using anyway. It's because its going smoothly in and out, if you did it in steps like this you would see it
G21
M6 1
M3
G0 Z20
G0 X10 Y10
G0 Z0.2
G1 Z1 F30
G2 X20 R5 F1000
G1 Z-1.2
G2 X11 R4.5
G1 Z-1.4
G2 X19 R4
G1 Z-1.6
G2 X12 R3.5
G1 Z-1.8
G2 X18 R3
G1 Z-1.8
G2 X13 R2.5
G1 Z-1.6
G2 X17 R2
G1 Z-1.4
G2 X14 R1.5
G1 Z-1.2
G2 X16 R1
G1 Z1
G0 Z20
M30

Rufe0
17-11-2015, 07:49 PM
Yeah I didn't explain that very well.

Say you have

G1 X10 Y10 Z0
G2 X20 R5 Z10

It will go smoothly from Z0 to Z10 along the length of the arc, so half way through it will be at Z5. Same as if you do

G1 X0 Y0
G1 X10 Y10

It won't do all the X movement and then all the Y movement, it will smoothly move between the two points.

Wal
17-11-2015, 07:52 PM
Okay - I see now, the Z is 'dropping' from its previous value as it draws the arc.

Cheers Rufe0 - I'm sure that this'll come in handy, even if it's a springboard into looking at a bit more G-code, which I really ought to.

Wal.

Rufe0
17-11-2015, 08:50 PM
If you must use program generated code I made this little program that might help you. Copy in only the shape you need altering. All it does is add Z depth onto the end of every line.

Download and rename the file ProgramForWal.html and open in your web browser.

Wal
17-11-2015, 09:01 PM
Hey man, that's awesome. Thanks a lot for that..!

Just heading back home to have a closer look at it. Thanks again.

Wal.

Rufe0
17-11-2015, 11:44 PM
Fixed a few little things and added a new feature, it's possible todo any number of down ups.

Wal
18-11-2015, 01:04 AM
Fixed a few little things and added a new feature, it's possible todo any number of down ups.

Hi Rufe0,

Very cool - I'm always blown away by the skills of programmers. Just amazing. I have a couple of observations, although I'm pretty certain you'll be aware of 'em. When using the script on a rounded rectangle, there's a more pronounced drop on the 'rounded' segments due to the extra lines of Cut 2D code that are forcing extra incremental drops in the Z-axis:

16558

The next pic shows that despite asking for a drop of 20 on this square, the Z only drops to 14.44, other shapes have dropped the specified amount, so perhaps this is an incompatibility between your script and the way Cut 2D formats it's code when dealing with different shapes..?

16559

Hey, but seriously - I'm really impressed and very grateful to you for taking the time to help me out..!

Wal.

JAZZCNC
18-11-2015, 11:20 AM
Just out of interest why would you want to arc in and out with the Z?

To save cutter wear would be another. It means Not plunging into material but still being able to have Arc lead-in. Something I use often when cutting out of material were tool can't avoid plunging into material and I don't want or can't ramp.

Rufe0
18-11-2015, 11:49 AM
Fixed a few little bugs in V2.2


When using the script on a rounded rectangle, there's a more pronounced drop on the 'rounded' segments due to the extra lines of Cut 2D code that are forcing extra incremental drops in the Z-axis:
Yeah thats the problem with just addind a Z on the end of every line. Todo it properly it would need to read every line, figure out how long the move is and then adjust the Z accordingly. That would be alot more work... but i'll think about it.

Wal
18-11-2015, 12:53 PM
That would be alot more work... but i'll think about it.

Heh, add the ability to ease in/out to the z-depth and you've got a marketable utility there..! Excellent stuff.

Wal.