Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: rbjem on January 10, 2013, 05:18:32 PM
-
I have made a macro (only after I found out I couldn't do it solely with gcode) to create some gcode, and have an issue with stuttering that I am wondering if anyone could shed some light on.
First background info...
I am trying to create a helical toolpath so that I can quickly change parameters for different situations. I have it coded to the macro to: (starting from the bottom of the cut) make a vertical move, helix around at a desired pitch and radius until I reach a certain z height, then exit the cut vertically. This then repeats after increasing the cut radius by a small stepover. So far I have gotten this all to work.
My issue is that when executing the macro, the machine moves like it is in absolute stop (G61) mode rather than constant velocity. I am guessing the issue is due to the way the code is calculated for each step, but am unsure if it is due to my code, or if this is a limitation of mach3. When the angle increment is set to a low value motion slows to a crawl.
Here is the snippit of code that I am having an issue with:
(I made the program in polar coordinates (G16), so Y is equivalent to angle)
Do 'Begin helical interpolation
CURRENT_Z_HEIGHT = (CURRENT_Z_HEIGHT +(PITCH * ANGLE_INCREMENT / 360)) 'increment height for this move
CURRENT_ANGLE = (CURRENT_ANGLE + ANGLE_INCREMENT) 'increment angle for this move
CODE "G1 Y" & CURRENT_ANGLE & "Z" & CURRENT_Z_HEIGHT
If CURRENT_Z_HEIGHT >= (TOTAL_HEIGHT - FLAT_LENGTH) THEN 'stop at top of helix
Exit Do
Else
End If
Loop
This portion executes then is looped back up to the top after incrementing the cut radius. So essentially I am trying to program a loop in a loop. Maybe there is a method to do this entriely in a gcode file, but so far it has eluded me.
Any suggestions, insight, or alternative methods would be appreciated.
-
Why not simply use G2/G3? What you're doing will be very slow, because you're generating lots of very short, straight lines, which is a terribly inefficient way to generate any circular move.
Regards,
Ray L.
-
More testing.... same stuttering :-\
I have rewritten the offending part of the macro so now the helix loop has no calculations and does not check to see if the z height is at the max. I set it so it now uses a FOR loop in incremental coordinates. Now, before the loop, it calculates how much to increase the z per angle increment and how many steps needed to get to the correct height. There should be a lot less computation going on now since nothing is changing.
This is what that section now looks like:
Z_INCREMENT= (PITCH * ANGLE_INCREMENT / 360)
Steps = Round((HEIGHT - (2 * FLAT_LENGTH)) / Z_INCREMENT)
For i=0 to STEPS 'Begin helical interpolation
CODE "G91 Y" & ANGLE_INCREMENT
CODE "Z" & Z_INCREMENT
Next i
-
I agree about the inefficiency. I thought about G2/G3 and didnt initially think of a way to do it easily in Gcode. I guess now that Im writing a macro, that should be more doable. I'll think about it more tonight.
-
That brings up another question. Although it should be quite easy to do in what I want using cartesian coordinates, I was wondering yesterday if it is possible to do a circular move (like a G2 or G3) while in polar coordinates.
-
IF you mean G15/16 then no is the answer. The big question would be WHY? As Ray stated G2/G3 is your answer and using parameteric Gcode with subs is the answer for a programable helix. Of any diameter, pitch or height. Mach3 macros are never going to be the fast solution especially when you mix VB and Gcode.
Just a thought, (;-)
-
Thanks for the replies. This is the first time I've written a macro that generates gcode, so I wasnt sure if the stuttering was fixable or not.
Anyways, I'll make a new version using arc moves, I'm confident that will work better.