Hi,
I am writing a gcode generator to create paths for ornamental turning
by simulating a rose engine. I have nearly completed the initial part
and am now looking at one of my further aims which is to allow me to
import a surface profile and then cut patterns following this profile. I
have the facility to import a probe file produced by emc which is all
working fine as is generating simple gcode, this is because I can access
the surface depth data directly in my program.
My problem is that I thought I would use a bit more of emcs gcode
capability. So an alternative gcode generator (I can select which to
use) wraps every path as a gcode subroutine which is called from within
a gcode loop, looping for depth of cut etc, see attachment which was
generated without the surface following functionality. (I ultimately
intend to save each path in its own code file and call them externally
as required but not there yet).
Now the subroutine case the decision about what depth to cut is taken as
the gcode is running rather than when the code is created.
By way of example
In my program I use three bool flags; use_surface - true if using a
surface profile, follow_surface which is set true if the cut is to
follow the surface profile and finally a flag called
surface_pre_machined which is true if the surface profile has already
been cut before the path is cut.
By way of explanation assume at a given point on the path the surface
depth is 10mm, the path depth is 6mm and the roughing cut depth is 2mm.
If both follow_surface and pre-machined flags are true then the first
cut depth should be 12mm and that I am cutting air for 10mm before I
reach the surface. So after a rapid move to the position at a safe
height I want a rapid move to depth 10mm then a linear feed move of 2mm.
So a total depth can be cut in three passes. (I have incorporated a
final finish cut pass but am ignoring that here).
If pre-machined is false then I will be cutting the whole of the 16mm in
8 passes on the assumption that the surface profile will be cut later.
However at each pass I dont want to move the cutter depth to cut into a
rising bit of surface profile deeper than necessary. So if at some point
the current cutter depth is say 10mm and the surface rises to 2mm I need
to raise the cutter to 8mm (2 + 6 path depth). Thus my need for depth
data at run time.
I had thought that a clumsy way of overcoming this problem would be to
set up a current_surface_depth variable and assign it as I loop through
the points on the path in my program but I would rather access the data
in array form if possible any suggestions?
Finally why am I doing it this way? Well I want to be able to take a
flat block of wood etc and cut my pattern as if it was on a domed
surface. Then fill the cuts with some coloured resin etc (easy to do on
a flat topped surface) and then cut the dome afterwards as a lid.
Why am I bothering with subroutines and not just sticking to simple
gcode? Well 1) the files are much smaller and 2) I like programming it
was my job before I retired so this is also part of my hobby as much as
the actual machining.
Last time I asked a question someone asked if I was releasing my code,
the answer is yes and I have started a blog describing the program at
http://wood at dyadica dot net/site/ obviously replace at with @ and
dot with . But I must emphasize that everything including the blog is
at weak alpha release.
So can someone suggest the best way of achieving my aim?
Thanks and sorry this is so long
Alan
(----------------------------------------)
(Date: 25/08/2009 00:00:00)
(Units used are MM)
(Code for 1 Paths)
(Using Rotary Table around A axis)
(Using surface file surf1)
(Following surface profile)
(Assuming surface is pre-machined so will be cutting air down to surface depth)
(Total maximum depth is 28.000 MM)
(Actual depth to cut is 8.000 MM)
(3 depth passes)
(Cut depths (a)Rough cut increment - 3.000 MM (b)Finish cut - 2.000 MM)
(EMC GCode generated automatically)
(----------------------------------------)
O1000 sub (Rapid move to safe Height)
G00 Z#[0]
O1000 endsub (End Rapid move to safe Height)
(----------------------------------------)
O2000 sub (Rapid move to Position (X, Y or C) at safe height)
G00 Z-10.000
G00 X#[0] A#[1]
O2000 endsub (End Rapid move to Position)
(----------------------------------------)
O3000 sub (Linear Feed to depth)
G01 Z#[0]
O3000 endsub (End Linear feed to depth)
O4000 sub (Rapid move to depth)
G00 Z#[0]
O4000 endsub (End Rapid move to depth)
(----------------------------------------)
O5000 sub (Calculate cutting Depth)
O5000 endsub (End of Calculating cutting Depth)
O6000 sub (PATH_0)
G90
O2000 call [156] [0] (Rapid move to position)
G90
O3000 call [28] (linear move to cutting depth)
G93
#<_feed_rate> = 40 (Using inverse feed rate)
G01 X153.387 A1.000 F15.000
........... etc....................................
G01 X156.000 A360.000 F30.000
G94
O1000 call [-10] (Rapid move to safe height in z direction only)
O6000 endsub (End of PATH_0)
(Loop to cut each path in turn)
(Uses the following global variables)
#<_depth_loop_count> = 0 (the current loop count)
#<_max_depth_loop_count> = 3 (the maximum loop count)
#<_rough_cut> = 3 (the cutter depth increment for rough cuts)
#<_current_depth> = 0 (the current cutter depth)
#<_max_depth> = 28 (The maximum depth of paths in the model)
O7000 while [#<_depth_loop_count> LT #<_max_depth_loop_count>]
O8000 #<_current_depth> = [[[#<_depth_loop_count> + 1]] * [#<_rough_cut>]]
O9000 if [#<_current_depth> GT #<_max_depth>]
#<_current_depth> = [#<_max_depth>]
O9000 endif (End of depth check)
O6000 call (Call PATH_0)
#<_depth_loop_count>= [#<_depth_loop_count>+1]
O7000 endwhile (End of cutter depth loop)
O2000 call [0.0] [0.0] (Rapid move to position)
M2
(-----End of Program-----)
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users