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:

Variable Programming - Critique My Code, Please


NiCu2829
 Share

Recommended Posts

I've attached the blueprint of the part to be made and my code to machine the 5 slots in the OD. My goal is to have a program that regardless of the tool diameter, programmed radius or # of passes/DOC can be changed with relative ease. I'd like to make #527 passes where each pass is #528/#527 deep (the actual DOC is [#528/#527]/2 because the Y axis is diametrical).

I've never used variables to this extent so I'm hoping y'all will look it over and critique my code.

 

In the program I accounted for the key cutter tool radius when I programmed the tool path, so the R value on the offset screen=0. 

 

I'm cutting on the minus(-) side of Y0.

 

Thanks in advance! 

208.txt

DWG.pdf

Link to comment
Share on other sites

Attached is the latest edition of the program. It's still not working correctly. When I change #527 the absolute Y value changes. I want the toolpath to finish at the same Y axis location regardless of #527. The only thing I want to change dependent upon #527 is the DOC(depth of cut).

311.TXT

 

(PROGRAM IS IN METRIC)

$1


#522=12.249(KEY CUTTER TOOL RADIUS)
#523=12.7(ACTUAL PART RADIUS FOR KEY CUTTER)
#524=#523-#522(PROGRAMMED RADIUS FOR KEY CUTTER)
#527=10(# OF REPEATS FOR KEY CUTTER)
#528=8.179(16.358)(G50V SHIFT AMOUNT)
#529=4.83(4.699)(KEY CUTTER THICKNESS)
#540=[15.494*2]-[#523*2](DISTANCE FROM CENTERLINE OF PART TO BOTTOM OF ARC)
#541=[21.946-#540]/#527(DEPTH PER PASS)
#542=[[15.494*2]+[#541*#527]](FIRST PASS)
#543=#542


(AB TOOLS-KEY CUTTER)
(CARBIDE TOOL)
(6 FLUTES)
(DWG # )
(TOOL PROJECTION= 19.60MM-TO NUT)
(DIA= 6.28)
(*R VALUE ON OFFSET SCREEN=0*)
(#522=KEY CUTTER TOOL RADIUS)
(#523=ACTUAL PART RADIUS FOR KEY CUTTER)
(#524=PROGRAMMED RADIUS FOR KEY CUTTER)
(#527=# OF REPEATS)
(#528=G50V SHIFT AMOUNT)
(#529=KEY CUTTER THICKNESS)
(#540=DISTANCE FROM CENTERLINE OF PART TO BOTTOM OF ARC)
(#541=DEPTH PER PASS)
(#542=FIRST PASS)
(#543=#542)


(G10L10P7X0Y0Z15.Q0R0.)(R#522)
(G11)


/MB7
G40G97G98
M5
M80S3=871(=220SFM @ .9645" DIAMETER)
T0700
M18C0
G50W-15.
G50V#528
G0X#814+2.5Y-[#542+4.]Z[14.986-#524]T07
G0X-#529
G19
#543=#542
M98H100L#527
G0Y-[#542+4.]Z[14.986-#524]
G0C45.
#543=#542
M98H100L#527
G0Y-[#542+4.]Z[14.986-#524]
G0C90.
#543=#542
M98H100L#527
G0Y-[#542+4.]Z[14.986-#524]
G0C135.
#543=#542
M98H100L#527
G0Y-[#542+4.]Z[14.986-#524]
G0C180.
#543=#542
M98H100L#527
G0Y-[#542+4.]Z[14.986-#524]
G0X#814+2.5
G18
G50V-#528
G50W15.
(G50 Y0.)
G0Z-4.5
G0Z-4.5T0
M82
M20
M5
G18G99
/MB7
M1


M2
M99

N100


G1Y-#543F132.74(FEED/MINUTE)(=.001")
G3Y-#543Z[14.986+#524]R#524
G1Y-[#543+4.]
G0Z[14.986-#524]
#543=#543-#541(RECALCULATE DEPTH)


M99


 

 

Link to comment
Share on other sites
4 hours ago, David Colin said:

Hi,

Try changing :


#540=[15.494*2]-[#523*2](DISTANCE FROM CENTERLINE OF PART TO BOTTOM OF ARC)
#541=[21.946-#540]/#527(DEPTH PER PASS)

 

with:

 


#540=[15.494*2](DISTANCE FROM CENTERLINE OF PART TO CENTER OF ARC)
#541=[[21.946-#540]/2]/#527(DEPTH PER PASS)

 

311-MOD.txt

 

 

I'll try it. Thank you for your time!

 

 

Link to comment
Share on other sites
4 minutes ago, David Colin said:

I found glitches testing it...

Try this one instead: 311-MOD-2.txt

Here are modifications:


#540=15.494(DISTANCE FROM CENTERLINE OF PART TO CENTER OF ARC)
#544=21.946 (PART DIAMETER)
#541=[[#544/2]-#540+#523]/#527(DEPTH PER PASS)
#542=[#544/2]-#541+#523+#522 (FIRST PASS)

 

 

The machine is a Citizen L32. The Y axis is diametrical so if I G0 Y-21.946 (part diameter) it physically moves the tool half that amount (10.973). With that being said, should #540=15.494 or [15.494*2] ?

Link to comment
Share on other sites
1 hour ago, David Colin said:

I would leave #540 as a radius value as it's used for calculations

but I would change in initialization :


#542=2*[[#544/2]-#541+#523+#522]

and in sub:


#543=#543-2*#541(RECALCULATE DEPTH)

311-MOD-3.txt

 

The results of the test are as follows:

 

The absolute Y value at the bottom of the arc(max engagement) stayed the same regardless of #527 value, which is what I'm looking for. 

 

The current issue is the absolute Y axis value at the bottom of the arc=Y-54.584, it should be Y-30.086. It's to far away from centerline. 

 

Information I've gathered:

54.584-30.086=24.498

24.498-25.4(#523*2=25.4) = .902(#524*2=.902)

Currently #542=55.486(54.584(absolute Y axis value at bottom of arc) + .902 = 55.486) 

 

It's really close! I can't seem to see what's incorrect. Thanks again for your time!

 

Link to comment
Share on other sites
1 hour ago, David Colin said:

Mmmh...

could you try to change:


#542=2*[[#544/2]-#541+#523] (FIRST PASS)

 

 

It corrected the Y axis value at the bottom of the arc. It's currently Y-30.086 which is correct, but the start position(FIRST PASS) is now coming down on top of the part(to close to centerline).

 

 

Link to comment
Share on other sites

Yes i saw that. I left my CAM desk until monday but if toolpath is correct you should be pretty close!

You just need to adjust first pass entry point.

G0X#814+2.5Y-[#542+4.]

I guess you should calculate this whole Y safety value and put it in a variable (using part diameter #544 and cutter radius #522).

 

Link to comment
Share on other sites
1 minute ago, David Colin said:

Yes i saw that. I left my CAM desk until monday but if toolpath is correct you should be pretty close!

You just need to adjust first pass entry point.


G0X#814+2.5Y-[#542+4.]

I guess you should calculate this "+4" safety value and put it in a variable (using part diameter #544 and cutter radius #522).

 

 

WIll do. Time to make it happen.

Thanks again for all the support!

Have a great weekend!

 

Link to comment
Share on other sites
5 hours ago, David Colin said:

Hi,

Here is modification for entry/exit point.

311-MOD4.txt

 

Good day David. Thank you for your support and thoroughness! I was able to get it to work on Saturday. I made some considerable changes. Here's the code, please feel free to critique. Thanks again for all your help!

 

#522=12.249(KEY CUTTER TOOL RADIUS)
#523=12.7(ACTUAL PART RADIUS)
#524=#523-#522(PROGRAMMED RADIUS FOR KEY CUTTER)
#527=15(# OF REPEATS FOR KEY CUTTER)
#528=16.36(G50V SHIFT AMOUNT)
#529=4.83(KEY CUTTER THICKNESS)
#530=16.36(TOTAL MATERIAL REMOVED)
#531=#530/#527(DEPTH PER PASS)
#544=21.946(PART DIAMETER)
#545=[#544+[#522*2]](EDGE OF TOOL ON OD)

 

(KEY CUTTER)
(TOOL PROJECTION= 19.60MM-TO NUT)
(DIA= 6.28)
(*R VALUE ON OFFSET SCREEN=0*)
G40G97G98
M5
M80S3=87
T0700
M18C0
G50W-15.
G50V#528
G0X#814+2.5Y-[#545+4.]Z[14.986-#524]T07
G0X-#529
G19
M98H100L#527
G50V#528
G0Y-[#545+4.]Z[14.986-#524]
G0C45.
M98H100L#527
G50V#528
G0Y-[#545+4.]Z[14.986-#524]
G0C90.
M98H100L#527
G50V#528
G0Y-[#545+4.]Z[14.986-#524]
G0C135.
M98H100L#527
G50V#528
G0Y-[#545+4.]Z[14.986-#524]
G0C180.
M98H100L#527
G50V#528
G0Y-[#545+4.]Z[14.986-#524]
G0X#814+2.5
G18
G50V-#528
G50W15.
G0Z-4.5
G0Z-4.5T0
M82
M20
M5
G18G99
M1

M2
M99

 

N100


G50V-#531
G1Y-30.988F1000.
G3Y-30.988Z[14.986+#524]R#524
G1Y-[30.988+4.]
G0Z[14.986-#524]


M99


 

 

~ 217.txt

Link to comment
Share on other sites
1 hour ago, David Colin said:

You changed your mind and now use shift work offset. If that gets the job done then it's great!

 

Agreed. It's what made sense to me. Now I'm trying to add a finish pass so to speak. I'd like to leave a certain amount of material for the last pass regardless of the DOC of the previous passes. Any thoughts?

Link to comment
Share on other sites

It won't be straight forward.

You can add a variable #546

N100
G50V-#531
G1Y-30.988F1000.
G3Y-30.988Z[14.986+#524-#546]R[#524-#546]
G1Y-[30.988+4.]
G0Z[14.986-#524+#546]

then call your sub with different #546 values like this

#546=0.1(SUREP.)
G0X#814+2.5Y-[#545+4.]Z[14.986-#524+#546]T07
G0X-#529
G19
M98H100L#527
#546=0.(FINISH)
G0Y-[#545+4.]Z[14.986-#524+#546]
M98H100
G50V#528
G0Y-[#545+4.]Z[14.986-#524]

If you want to implementit in one and only sub i guess you will need to count pass and test to add your finish pass after last pass.

 

  • Like 1
Link to comment
Share on other sites
On 1/24/2019 at 10:33 PM, NiCu2829 said:

Would you provide an example. This is relatively new to me. Thank you for your time!

IF[#541 GT 1]#3000=0(STEPOVER TOO LARGE, TOOL WILL BREAK)

If that doesn't work, put THEN between ] and # characters.

I think it is good practice to always check user inputs.

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...