Hello Guest it is April 24, 2024, 11:24:07 AM

Author Topic: g code newbie  (Read 2961 times)

0 Members and 1 Guest are viewing this topic.

g code newbie
« on: May 05, 2011, 10:02:39 AM »
ok i just got my first cnc mill a few months ago and i have been writing g code for it using rhino cam and so far its been working well. my problem arose the other day when i tried to use rhino to program a 4th axis path to profile a part. the problem is at the beginning of the code it sets the feed rate to 18 which is fine for the actual pass but when the part needs to index on the a axis it keeps the 18 feed rate and its KILLING my cycle time and i know their has to be a better way. so i did some research into hand writing code and found out about sub routines. this looks like exactly what i want but im having a difficult time completely understanding how to get it to do what i want it to. here is a rough code for what i have now

(introductory code turning on spindle and coolant)

g00 z1
m98 01
m98 02
(end program lines)

o01
g1 z.5f20
(block of code to produce profile)
g00 z1
g00 x0
m99

(this is where i get lost)
o02
g1 a "+1" f300 (what i want to do is increment the a axis 1 degree untill a=360)
m99


if anybody has any ideas on how to accomplish this please help

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: g code newbie
« Reply #1 on: May 05, 2011, 08:47:08 PM »
You were close(;-) You just need to add the SUB name after the M98 call so mach know where to look for the code. I am not quite sure were you want to go in your o02 sub.  Do you want to increment the A axis 1 degree each loop or rotate the axis all the way to 360 in one shot?

g00 z1
m98 P01        ( P designates the program name call  P01 routes the code to the o01 line)
m98 P02
(end program lines)

o01
g1 z.5f20
(block of code to produce profile)
g00 z1
g00 x0
m99

(this is where i get lost)
o02
g1 a "+1" f300 (what i want to do is increment the a axis 1 degree untill a=360)
m99


(;-) TP


Re: g code newbie
« Reply #2 on: May 06, 2011, 10:42:43 AM »
how about this.

(open lines w/ g46)

m98 p 01 l 360

o 01
m98 p 02
m98 p 03

o 02
g1 z.5 f20
(lines of code for profile)
g00 z1
g00 x0
m99

o 03
g91
g1 a1 f300
g90
m99

(ending code)

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: g code newbie
« Reply #3 on: May 06, 2011, 10:28:19 PM »
The ending lines need to go after the parent call to the first sub.

(open lines w/ g46)

m98 p 01 l 360
(ending code)                 (ending code goes here)
M30

o 01
m98 p 02
m98 p 03
%

o 02
g1 z.5 f20
(lines of code for profile)
g00 z1
g00 x0
m99
%

o 03
g91
g1 a1 f300
g90
m99
%