Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Recommended Posts

Most of these I wrote about five years ago when I first realized how powerful custom macro b was. I would have to say that most applications for these would be for tooling but we have used them for parts here at work. If it is not clear as to what something does for you guys please ask and I will gladly answer any questions for you. Remember if it says not proven it means I have not even cut any chips with it yet. So, it is worthy of a dry run if you want to play with it. I believe most or all of the toolpath I incorporated has a .100 thousandths clearance on all of the moves. If you would like to change something with one of them we can do that here as well. Just post the macro with your request and I can help you change it. One I forgot to add to the list was my most recent. It is a tool change macro that automatically sets each tool. Should work for most fanucs and robodrills.

 

O0001(AUTOMATIC TLO MACRO)

(CHANGE 2000 TO 2200 FOR ROBODRILL)

(YOU MUST MANUALLY SET #100 & #101)

(DO NOT FORGET THE DECIMALS)

M00

#100=1.(FIRST TOOL TO SET)

#101=10.(LAST TOOL TO SET)

N1T#100M06

#102=#100+2000.

M00

(TOUCH TOOL)

(HIT CYCLE START)

#[#102]=#5003

G91G28Z0

G90

#100=#100+1.

IF[#100LT#101]GOTO1

M30

Link to comment
Share on other sites

Here is what I use to manually set tool length.

 

 

 

%

O0004(TOOL LENGTH SET)

 

#100=26(START TOOL)

 

#101=0(END TOOL)

 

#102=1.(GAGE HEIGHT)

 

 

#550=-21.81(X POSITION)

#551=-5.32(Y POSITION)

 

M98P9300

 

 

M30

%

 

 

O9300(O0004 SUB)

IF[#101EQ0]GOTO200

GOTO201

N200

#101=#100

N201

IF[#101LT#100]GOTO300

#500=#550(X OFFSET POSITION)

#501=#551(Y OFFSET POSITION)

WHILE[#100LE#101]DO1

T#100

M6

G90G53G00X#500Y#501(X,Y TOUCH OFF LOCATION)

M00 (TOUCH OFF TOOL)

#502=#5023-#102

G90G53Z0

 

#[11000+#100]=#502(TOOL LENGTH OFFSET)

#[12000+#100]=0.0(CLEAR WEAR OFFSET)

 

#100=#100+1

END1

M99

N300

#3000=0(END TOOL ERROR)

%

Link to comment
Share on other sites

Here's my version of the manual tool length setter I wrote 10-11 years ago for our first three horizontals. We added laser setters starting with our fifth one.

 

%

O6002(MAIN TOOL LENGTH MEASUREMENT PROGRAM)

(START PROGRAM WITH SPINDLE TIP TOUCHING TOOL LENGTH PRESETTER)

 

G65P6003A0.B40.

(A = TOOL NUMBER TO BE MEASURED -- MAKE 0 IF SPINDLE IS TOUCHING PRESETTER)

(B = NEXT TOOL -- MAKE 0 IF LAST TOOL)

IF[#101NE0]GOTO2

M00(SPINDLE CALIBRATED)

GOTO1

N2IF[#102NE0]GOTO1

G91G30Z0

G30X0Y0

N1M30

 

O6003(SPINDLE CALIBRATION)

#101=#1

#102=#2

IF[#1NE0]GOTO1

#5221=#5021

#5222=#5022-1.0598

#5223=#5023

T#2

GOTO2

N1M98P6004

N2M99

 

O6004(MEASUREMENT PROGRAM)

IF[#5223EQ0]GOTO98

G91G30Z0.

G30X0Y0

M06T#101

#103=#4120

IF[#2EQ0]GOTO1

T#102

N1G90G00X0Y0G54

M00(TOUCH TOOL TIP TO TOOL LENGTH PRESETTER)

#[#103+2000]=ABS[#5223-#5023]

IF[#102NE0]GOTO99

#5221=0

#5222=0

#5223=0

GOTO99

N98#3000=99(SPINDLE TIP NOT CALIBRATED)

N99M99

%

Link to comment
Share on other sites
  • 1 month later...
  • 2 weeks later...

Yes, it is for using a hard tool touch off ike using a piece of .001 shim stock or a .5 inch Joe block. You would have to subtract these values after the touch of or you could just change the macro like this:

.001 shim #5003-.001 or .5 Joe Block #5003-.5.

Link to comment
Share on other sites

Here you go. You will have to create subs with your font and size of number starting with program 8100 representing zero, 8101 representing 1 and so forth. These subs should be posted in incremental.

 

O8116( S/N MACRO )

( USE OFFSET #100 FOR SERIAL # )

( 00.0001 WILL ENGRAVE 1 )

( 1ST NUMBER )

#138=[#100*.1]

#140=FIX[#138]

#141=#140+8100.

( 2ND NUMBER )

#138=[#140*10]

#139=FIX[#100]

#140=#139-#138

#142=#140+8100.

( 3RD NUMBER )

#138=[#139*10]

#139=FIX[#100*10]

#140=#139-#138

#143=#140+8100.

( 4TH NUMBER )

#138=[#139*10]

#139=FIX[#100*100]

#140=#139-#138

#144=#140+8100.

( 5TH NUMBER )

#138=[#139*10]

#139=FIX[#100*1000]

#140=#139-#138

#145=#140+8100.

( 6TH NUMBER )

#138=[#139*10]

#139=FIX[#100*10000]

#140=#139-#138

#146=#140+8100.

( ARGUMENT )

IF[#141GT8100.]GOTO1

IF[#142GT8100.]GOTO2

IF[#143GT8100.]GOTO3

IF[#144GT8100.]GOTO4

IF[#145GT8100.]GOTO5

IF[#146GT8100.]GOTO6

GOTO100

N1M98P#141

N2M98P#142

N3M98P#143

N4M98P#144

N5M98P#145

N6M98P#146

(UPDATE SERIAL NUMBER)

N100#100=#100+.0001

M99

Link to comment
Share on other sites
  • 2 weeks later...

I need to update one of the macros because I found an error in it when I was reviewing it, sorry I am not perfect. Please replace the ID-Cone Macro with this:

 

O6888(CUT 0-180 DEG ID TAPER)

(ABSOLUTE SURFACING MACRO)

(UNPROVEN)

(FORMAT G65/G66 AQDTSRZEF)

(A = #1 - INCLUDED ANGLE OF PART FROM BOTTOM)

(Q = #17 - STEPOVER IN Z/ CUSP HEIGHT)

(D = #7 - TOOL DIAMETER)

(T = #20 - TOOL RADIUS/ BALL OR BULL)

(S = #19 - PART ID/ TOP)

(R = #18 - R PLANE)

(Z = #26 - Z START ZERO)

(E = #8 - END OF TAPER IN Z)

(F = #9 - FEEDRATE)

(***********************************)

#100=ABS[#26]-ABS[#8]

#100=ABS[#100]

IF[[#26*#8]GE0]GOTO1

#100=ABS[#26]+ABS[#8]

N1#101=ROUND[#100/#17]

#102=#100/#101

IF[#102GT[#100/2]]GOTO1000

#103=#5001

#105=#5002

#113=#105

#115=[[#19/2]-[#7/2]]-.1

#115=#105+#115

#155=0

IF[#7EQ[#20*2]]GOTO10

#105=#105-[[#7/2]+#20]

#155=#155-[[#7/2]+#20]

N10#105=#105+[#19/2]

#155=#155+[#19/2]

#125=90.+[#1/2]

#105=#105-[#20/TAN[#125/2]]

#155=#155-[#20/TAN[#125/2]]

G0G90X#103Y#115

Z[#26+.1]

G1Z#26F#9

#106=#5003

G41Y#105

WHILE[#101GE0]DO1

IF[#101LT0]GOTO100

#101=#101-1.

G90G02J-#155F[#9]

#105=-[TAN[#1/2]*#102]

#155=#155-[TAN[#1/2]*#102]

G91G1Y#105Z-[#102]F[#9/3]

END1

N100G0G90Z#18

X#103Y#113

M99

N1000#3000= 1( Q VALUE TOO BIG )

Link to comment
Share on other sites

cncchipmaker, do you have code for circular interpolation using a mill? . Here's a video as an example of what I'm looking for.

 

]

 

 

boring circular holes or pockets in things. All the moves are made as climb milling passes, spiraling out from the center in quadrants of increasing radius, until the cutter has reached the finish pass allowance. It then plunges deeper, and repeats, until the full depth has been reached. On the last depth pass, the cutter spirals out further, completing the finish pass. it then returns to the hole center and retracts. I have code written in C that will generate a text file G -Code file, however I was looking for this functionality directly in Marco B.

 

#include <stdio.h>

typedef enum {

initial, Spiraling, finishing

} States_type;

typedef enum {

linear, arc

} Interp_type;

double CenterX, CenterY, ToolDia, BoreDia, BoreRadius, FeedRate,

WidthOfCut, FinishWOC, FinishFeed, Offset, CurRadius,

X, Y, Z, I, DepthPerPass, BoreDepth,

J, NX, NY, NR, CurX, CurY, CurZ, CentDist, ToolRadius;

double ArcCent, ArcRadius, OldRadius;

int Quadrant, FinQuadrant;

int true =1;

int false =0;

double LineNo;

States_type State;

Interp_type Interp;

char FileName[256];

int Done;

FILE *OutFile;

int FeedonLine;

int EXIT_SUCCESS=1;

int EXIT_FAILURE=0;

void OutNum(RealNum, SigFrac)

double RealNum;

long SigFrac;

{

double i;

int j;

char format[8];

for (i = 1.0, j = 0; j <= 6 && i<= fabs(RealNum); i *= 10.0, j++)

{}

j += SigFrac-1; /* J <= # int digits + 1 for decimal pt + #frac digits */

if (RealNum < 0.0 )

j += 1; /* add a position for the minus sign */

sprintf(format,"%%%d.%dlf",j,SigFrac);

fprintf(OutFile, format, (RealNum));

}

 

void WriteLineNo()

{

putc('N', OutFile);

OutNum(LineNo, 0L);

LineNo += 10.0;

putc(' ', OutFile);

}

 

main(argc, argv)

int argc;

char *argv[];

{

OutFile = NULL;

printf("Enter Starting X,Y (real):");

scanf("%lf %lf", &CenterX, &CenterY);

getchar();

printf("\nEnter Tool Diameter, Bore Diameter (real):");

scanf("%lf %lf", &ToolDia, &BoreDia);

getchar();

printf("\nEnter Feed Rate (IPM), Width of Cut (real):");

scanf("%lf %lf", &FeedRate, &WidthOfCut);

getchar();

printf("\nEnter Finish Feed Rate, Width of Cut (real):");

scanf("%lf %lf", &FinishFeed, &FinishWOC);

getchar();

printf("\nEnter Z Depth per Pass, Bore Depth:");

scanf("%lf %lf", &DepthPerPass, &BoreDepth);

getchar();

printf("\nEnter File Name for CAM output:");

scanf("%s",FileName);

putchar('\n');

OutFile = fopen(FileName,"w");

if (OutFile != NULL)

rewind(OutFile);

else

OutFile = tmpfile();

if (OutFile == NULL)

exit(EXIT_FAILURE);

LineNo = 10.0;

ToolRadius = ToolDia / 2.0;

BoreRadius = BoreDia / 2.0;

/* safety test on Width of cut */

if (BoreRadius - ToolRadius - FinishWOC <= WidthOfCut)

{

printf("Width of Cut too large to spiral out to requested bore.\n");

exit(EXIT_FAILURE);

}

/* loop to cut spiral path at each depth increment */

for (CurZ = -DepthPerPass;

CurZ >= -BoreDepth-DepthPerPass+0.001; CurZ -= DepthPerPass)

{

if (CurZ < -BoreDepth)

{

CurZ = -BoreDepth;

/* State = LastLevel; */

}

WriteLineNo();

fprintf(OutFile, "G01 "); /* Linear Interpolation */

Interp = linear;

putc('F', OutFile); /*set feedrate */

OutNum(FeedRate, 3L);

CurX = CenterX;

CurY = CenterY;

putc(' ', OutFile);

putc('X', OutFile); /* Move to Center */

OutNum(CurX, 4L);

fprintf(OutFile, " Y");

OutNum(CurY, 4L);

putc('\n', OutFile);

WriteLineNo();

fprintf(OutFile, "F");

OutNum(FeedRate/6.0, 3L);

fprintf(OutFile, " Z"); /* LOWER tool */

OutNum(CurZ,4L);

putc('\n', OutFile);

WriteLineNo();

fprintf(OutFile, "F");

OutNum(FeedRate, 3L);

CurRadius = WidthOfCut/4.0;

CurX += CurRadius;

OldRadius = CurRadius;

fprintf(OutFile, " X");

OutNum(CurX, 4L);

putc('\n', OutFile);

/* WriteLineNo(); */

/* fprintf(OutFile, "G03\n"); CCW Circular Interpolation */

Quadrant = 1;

FinQuadrant = 0;

State = initial;

Done = false;

FeedonLine = false;

/* loop to spiral out in quadrants */

do {

if (State == finishing) {

CentDist = CurRadius;

ArcRadius = CurRadius; }

else {

CentDist = CurRadius + WidthOfCut / 4.0;

/* compute where to put center of arc */

ArcCent=(OldRadius*OldRadius - CurRadius*CurRadius)/(-2.0*CurRadius);

ArcRadius = CurRadius - ArcCent;

OldRadius = CurRadius; }

switch (Quadrant) {

case 1:

NX = CenterX;

NY = CenterY + CurRadius;

NR = ArcRadius;

break;

case 2:

NX = CenterX - CurRadius;

NY = CenterY;

NR = ArcRadius;

break;

case 3:

NX = CenterX;

NY = CenterY - CurRadius;

NR = ArcRadius;

break;

case 4:

NX = CenterX + CurRadius;

NY = CenterY;

NR = ArcRadius;

break;

} /* switch */

if (FeedonLine == false) {

WriteLineNo();

}

FeedonLine = false;

if (Interp == linear)

{

Interp = arc;

fprintf(OutFile, "G03 ");

}

putc('X', OutFile);

OutNum(NX, 4L);

fprintf(OutFile, " Y");

OutNum(NY, 4L);

fprintf(OutFile, " R");

OutNum(NR, 4L);

putc('\n', OutFile);

if (State == finishing) {

FinQuadrant++;

if (FinQuadrant >= 5)

Done = true;

}

if (State == Spiraling) {

if (CurRadius <= BoreRadius - ToolRadius - FinishWOC - 0.001)

CurRadius += WidthOfCut / 4.0;

else {

/* printf("Cur Z = %12.4f BoreDepth = %12.4f\n",CurZ,BoreDepth); */

if (CurZ-.001 <= -(BoreDepth))

{

/* printf("State is finishing\n"); /* bore to finish diameter */

State = finishing;

CurRadius = BoreRadius - ToolRadius;

FinQuadrant = 0;

WriteLineNo();

putc('F', OutFile); /*set finish feedrate */

OutNum(FinishFeed, 3L);

putc(' ', OutFile);

FeedonLine = true;

}

else {

State = finishing; /* Bore to true circle, leaving FinishWOC */

CurRadius = BoreRadius - ToolRadius - FinishWOC;

FinQuadrant = 0;

}

}

}

if (State == initial) {

if (CurRadius > WidthOfCut)

State = Spiraling;

CurRadius += WidthOfCut / 4.0;

}

Quadrant++;

if (Quadrant > 4)

Quadrant = 1;

} while (!Done);

} /* for CurZ ... */

WriteLineNo();

fprintf(OutFile,"G01 X"); /* return to center */

OutNum(CenterX,4L);

fprintf(OutFile," Y"); /* return to center */

OutNum(CenterY,4L);

fprintf(OutFile,"\n");

WriteLineNo();

fprintf(OutFile, "G01 F50 Z0.1\n"); /* raise spindle above work */

WriteLineNo();

fprintf(OutFile, "M02\n"); /*End of Program */

if (OutFile != NULL)

fclose(OutFile);

OutFile = NULL;

if (OutFile != NULL)

fclose(OutFile);

exit(EXIT_SUCCESS);

}

/* End. */

Link to comment
Share on other sites

Give this a try. I did not have one written so I made up this new one. It is setup for horizontal milling so you can see in the Y axis where it starts and stops. Let me know if it works please. I do not get a chance to prove everything out here at work.

 

O6011(FINISH ID)

(ABSOLUTE MACRO)

(UNPROVEN)

(FORMAT G65/G66 TCDRZEFS)

(T = #20 - TOOL DIAMETER)

(C = #3 - CUTTER COMP DISTANCE)

(FROM EDGE OF TOOL)

(D = #7 - PART INTERNAL DIAMETER)

(R = #18 - R PLANE)

(E = #8 - END OF ID IN Z)

(F = #9 - FEEDRATE)

(S = #19 SPRING PASSES 3 MAX)

(*********************************)

#103=#5001

#105=#5002

#109=#19

IF[#109GT3.]THEN#109=3.

#113=#105

#115=#105+[[[#7/2.]-[#20/2.]]-#3]

#105=#105+[[#7/2.]-[#20/2.]]

#155=0

#155=#155+[[#7/2.]-[#20/2.]]

G0G90X#103Y#115

Z#18

G1Z#8F50.

G41Y#105F[#9/3.]

WHILE[#119GE0]DO1

IF[#119LT0]GOTO10

#119=#119-1.

G03J-#155Z#106F#9

END1

N10G90G03J-#155

G1G40Y#115

G0Z#18

X#103Y#113

M99

Link to comment
Share on other sites

Sorry, but that black lettering was hard to read. When you post a meesage please remove the formatting of what your pasting in so the board will put it in a way someone can see it thanks.

 

boring circular holes or pockets in things. All the moves are made as climb milling passes, spiraling out from the center in quadrants of increasing radius, until the cutter has reached the finish pass allowance. It then plunges deeper, and repeats, until the full depth has been reached. On the last depth pass, the cutter spirals out further, completing the finish pass. it then returns to the hole center and retracts. I have code written in C that will generate a text file G -Code file, however I was looking for this functionality directly in Marco B.

 

#include <stdio.h>
typedef enum {
initial, Spiraling, finishing
} States_type;
typedef enum {
linear, arc
} Interp_type;
double CenterX, CenterY, ToolDia, BoreDia, BoreRadius, FeedRate,
WidthOfCut, FinishWOC, FinishFeed, Offset, CurRadius,
X, Y, Z, I, DepthPerPass, BoreDepth,
J, NX, NY, NR, CurX, CurY, CurZ, CentDist, ToolRadius;
double ArcCent, ArcRadius, OldRadius;
int Quadrant, FinQuadrant;
int true =1;
int false =0;
double LineNo;
States_type State;
Interp_type Interp;
char FileName[256];
int Done;
FILE *OutFile;
int FeedonLine;
int EXIT_SUCCESS=1;
int EXIT_FAILURE=0;
void OutNum(RealNum, SigFrac)
double RealNum;
long SigFrac;
{
double i;
int j;
char format[8];
for (i = 1.0, j = 0; j <= 6 && i<= fabs(RealNum); i *= 10.0, j++)
{}
j += SigFrac-1; /* J <= # int digits + 1 for decimal pt + #frac digits */
if (RealNum < 0.0 )
j += 1; /* add a position for the minus sign */
sprintf(format,"%%%d.%dlf",j,SigFrac);
fprintf(OutFile, format, (RealNum));
}
 
void WriteLineNo()
{
putc('N', OutFile);
OutNum(LineNo, 0L);
LineNo += 10.0;
putc(' ', OutFile);
}
 
main(argc, argv)
int argc;
char *argv[];
{
OutFile = NULL;
printf("Enter Starting X,Y (real):");
scanf("%lf %lf", &CenterX, &CenterY);
getchar();
printf("\nEnter Tool Diameter, Bore Diameter (real):");
scanf("%lf %lf", &ToolDia, &BoreDia);
getchar();
printf("\nEnter Feed Rate (IPM), Width of Cut (real):");
scanf("%lf %lf", &FeedRate, &WidthOfCut);
getchar();
printf("\nEnter Finish Feed Rate, Width of Cut (real):");
scanf("%lf %lf", &FinishFeed, &FinishWOC);
getchar();
printf("\nEnter Z Depth per Pass, Bore Depth:");
scanf("%lf %lf", &DepthPerPass, &BoreDepth);
getchar();
printf("\nEnter File Name for CAM output:");
scanf("%s",FileName);
putchar('\n');
OutFile = fopen(FileName,"w");
if (OutFile != NULL)
rewind(OutFile);
else
OutFile = tmpfile();
if (OutFile == NULL)
exit(EXIT_FAILURE);
LineNo = 10.0;
ToolRadius = ToolDia / 2.0;
BoreRadius = BoreDia / 2.0;
/* safety test on Width of cut */
if (BoreRadius - ToolRadius - FinishWOC <= WidthOfCut)
{
printf("Width of Cut too large to spiral out to requested bore.\n");
exit(EXIT_FAILURE);
}
/* loop to cut spiral path at each depth increment */
for (CurZ = -DepthPerPass;
CurZ >= -BoreDepth-DepthPerPass+0.001; CurZ -= DepthPerPass)
{
if (CurZ < -BoreDepth)
{
CurZ = -BoreDepth;
/* State = LastLevel; */
}
WriteLineNo();
fprintf(OutFile, "G01 "); /* Linear Interpolation */
Interp = linear;
putc('F', OutFile); /*set feedrate */
OutNum(FeedRate, 3L);
CurX = CenterX;
CurY = CenterY;
putc(' ', OutFile);
putc('X', OutFile); /* Move to Center */
OutNum(CurX, 4L);
fprintf(OutFile, " Y");
OutNum(CurY, 4L);
putc('\n', OutFile);
WriteLineNo();
fprintf(OutFile, "F");
OutNum(FeedRate/6.0, 3L);
fprintf(OutFile, " Z"); /* LOWER tool */
OutNum(CurZ,4L);
putc('\n', OutFile);
WriteLineNo();
fprintf(OutFile, "F");
OutNum(FeedRate, 3L);
CurRadius = WidthOfCut/4.0;
CurX += CurRadius;
OldRadius = CurRadius;
fprintf(OutFile, " X");
OutNum(CurX, 4L);
putc('\n', OutFile);
/* WriteLineNo(); */
/* fprintf(OutFile, "G03\n"); CCW Circular Interpolation */
Quadrant = 1;
FinQuadrant = 0;
State = initial;
Done = false;
FeedonLine = false;
/* loop to spiral out in quadrants */
do {
if (State == finishing) {
CentDist = CurRadius;
ArcRadius = CurRadius; }
else {
CentDist = CurRadius + WidthOfCut / 4.0;
/* compute where to put center of arc */
ArcCent=(OldRadius*OldRadius - CurRadius*CurRadius)/(-2.0*CurRadius);
ArcRadius = CurRadius - ArcCent;
OldRadius = CurRadius; }
switch (Quadrant) {
case 1:
NX = CenterX;
NY = CenterY + CurRadius;
NR = ArcRadius;
break;
case 2:
NX = CenterX - CurRadius;
NY = CenterY;
NR = ArcRadius;
break;
case 3:
NX = CenterX;
NY = CenterY - CurRadius;
NR = ArcRadius;
break;
case 4:
NX = CenterX + CurRadius;
NY = CenterY;
NR = ArcRadius;
break;
} /* switch */
if (FeedonLine == false) {
WriteLineNo();
}
FeedonLine = false;
if (Interp == linear)
{
Interp = arc;
fprintf(OutFile, "G03 ");
}
putc('X', OutFile);
OutNum(NX, 4L);
fprintf(OutFile, " Y");
OutNum(NY, 4L);
fprintf(OutFile, " R");
OutNum(NR, 4L);
putc('\n', OutFile);
if (State == finishing) {
FinQuadrant++;
if (FinQuadrant >= 5)
Done = true;
}
if (State == Spiraling) {
if (CurRadius <= BoreRadius - ToolRadius - FinishWOC - 0.001)
CurRadius += WidthOfCut / 4.0;
else {
/* printf("Cur Z = %12.4f BoreDepth = %12.4f\n",CurZ,BoreDepth); */
if (CurZ-.001 <= -(BoreDepth))
{
/* printf("State is finishing\n"); /* bore to finish diameter */
State = finishing;
CurRadius = BoreRadius - ToolRadius;
FinQuadrant = 0;
WriteLineNo();
putc('F', OutFile); /*set finish feedrate */
OutNum(FinishFeed, 3L);
putc(' ', OutFile);
FeedonLine = true;
}
else {
State = finishing; /* Bore to true circle, leaving FinishWOC */
CurRadius = BoreRadius - ToolRadius - FinishWOC;
FinQuadrant = 0;
}
}
}
if (State == initial) {
if (CurRadius > WidthOfCut)
State = Spiraling;
CurRadius += WidthOfCut / 4.0;
}
Quadrant++;
if (Quadrant > 4)
Quadrant = 1;
} while (!Done);
} /* for CurZ ... */
WriteLineNo();
fprintf(OutFile,"G01 X"); /* return to center */
OutNum(CenterX,4L);
fprintf(OutFile," Y"); /* return to center */
OutNum(CenterY,4L);
fprintf(OutFile,"\n");
WriteLineNo();
fprintf(OutFile, "G01 F50 Z0.1\n"); /* raise spindle above work */
WriteLineNo();
fprintf(OutFile, "M02\n"); /*End of Program */
if (OutFile != NULL)
fclose(OutFile);
OutFile = NULL;
if (OutFile != NULL)
fclose(OutFile);
exit(EXIT_SUCCESS);
}
/* End. */

Link to comment
Share on other sites

rpadyk please give this a try:

 

O3333(SPIRAL ROUGH ID POCKET)

(INCREMENTAL AND ABSOLUTE MACRO)

(MUST HAVE START HOLE IN CENTER)

(UNPROVEN)

(FORMAT G65/G66 QSTDRZEFV)

(Q = #17 - STEPOVER IN Z/ DOC)

(S = #19 - STEPOVER IN X/ PERCENTAGE)

(T = #20 - TOOL DIAMETER)

(D = #7 - PART INTERNAL DIAMETER)

(R = #18 - R PLANE)

(Z = #26 - Z START/ TOP OF STOCK)

(E = #8 - END OF POCKET IN Z)

(F = #9 - FEEDRATE)

(V = #22 - 1 FOR VARIABLE FEEDRATE, 0 = FIXED)

(*********************************)

(CALCULATE DOC IN Z)

#100=ABS[#26]-ABS[#8]

#100=ABS[#100]

IF[[#26*#8]GE0]GOTO1

#100=ABS[#26]+ABS[#8]

N1#101=ROUND[#100/#17]

#102=#100/#101

IF[#102GT[#100/2.]]THEN#102=#100

(CALCULATE DOC IN X)

#103=[#19*.01]*#20

#104=[#7/2.]-[#20/2.]

#105=ROUND[#104/#103]

#106=#104/#105

IF[#106GT[#104/2.]]THEN#106=#104

#107=#5001

#108=#5002

G0G90X#107Y#108

Z[#26+.1]

G1Z#26F#9

#109=#5003-#102

#116=3.14*[#106*2.]

#119=#9

#126=#106

WHILE[#101GT0]DO1

IF[#101EQ0]GOTO10

#101=#101-1.

G90G1Z#109F#119

G91G41X#106

G03I-[#106]

#105=#105-1.

#106=#106+#126

IF[#105EQ0]GOTO20

WHILE[#105GT0]DO2

IF[#105EQ0]GOTO20

#129=#119*[[3.14*[#106*2.]]/#116]

IF[#22EQ0]THEN#129=#119

G03X-[#106*2.]I-[#106]F#129

#105=#105-1.

#106=#106+#126

IF[#105EQ0]GOTO20

#129=#119*[[3.14*[#106*2.]]/#116]

IF[#22EQ0]THEN#129=#119

G03X[#106*2.]I#106F#129

#105=#105-1.

#106=#106+#126

END2

N20

IF[#5001LT#107]GOTO30

G03I-[#106]

GOTO40

N30

G03I#106

N40

G90G1G40X#107Y#108F100.

#109=#109-#102

END1

N10

G90G0Z#18

M99

  • Like 1
Link to comment
Share on other sites
  • 3 weeks later...
  • 2 months later...

My newest macro for Haas machining centers. My brother needed a way to automatically set G52-G59 using any tool guage length.

O0001

(Use decimal point when changing coordinate system number.)

(Change #600)

#600=52.(Coordinate System)

(Coordinate System Variable Set)

#652=5203.(G52)

#654=5223.(G54)

#655=5243.(G55)

#656=5263.(G56)

#657=5283.(G57)

#658=5303.(G58)

#659=5323.(G59)

(SET Z)

#[600.+#600]=#5023+#[2000.+#3026]

M30

  • Like 3
Link to comment
Share on other sites
  • 1 month later...

Meh, macros aren't rocket science. To be honest when I get deep into writing macros I find myself longing for an OOP language versus the archaic CNC G code macro language.  

 

Here is one to cut a scroll compressor by macro calculations

 

#520=2.769
#500=#520
#501=1. (DIFF BETWEEN START AND END ANGLES DIVIDED BY POINTS)
#502=84 ([#502 IS START ANGLE)
 
N2000
G01 X=[2.593*[COS[#502]+[#502+[[.350/2.593]*[180.0/#500]]]]*[#500/180.*SIN[#502]]] Y=[-2.593*[sIN[#502]-[#502+[[.350/2.593]*[180.0/#500]]]]*[#500/180.*COS[#502]]] F500.
#502=[#502+#501]
IF [#502 LT 1135] GOTO2000
(84< #502 < 1134)
 
#510=#520
 
#511=1. (DIFF BETWEEN START AND END ANGLES DIVIDED BY POINTS)
#512=264 ([#502 IS START ANGLE)
 
N3000
G01 X=[2.593*[COS[#512]+[#512-72.96-[[.350/2.593]*[180.0/#510]]]]*[#510/180.*SIN[#512]]] Y=[-2.593*[sIN[#512]-[#512-72.96-[[.350/2.593]*[180.0/#510]]]]*[#510/180.*COS[#512]]] F500.
#512=[#512+#511]
IF [#512 LT 1135] GOTO3000
(84< #512 < 1134)
  • Like 2
Link to comment
Share on other sites

i need one for drilling with carbide drills to change rpm  and feed on entry and feed and rpm  on the push threw my 600 variables are free it would be nice to just replace the g81 line with all inputs in that line and use all position in absolute (i looked threw all drilling cycles i can change feeds but cant change rpm but i might of missed it mazack ?)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...