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:

Custom Macro B Programming


Recommended Posts

There are so many different ways to use Macro programming and this there are tons fo examples and topic about this since I have been here in the last 10 years. I can give you one I just did one a lathe.

 

 

#110=1

N100

Warm up code goes here

#110=110+1

IF [#100LT10] GOTO 100

IF [#100EQ10] GOTO 200

N200 M30

 

This is a loop counter 10 times to warm up machines. Before the guy go home they are suppsoe to have the machien laoded and tested with these programs. Maintenace peoople come in fire up the machines, home them out and run these programs before the shop people show up. Machines have been warmed up and ready to go.

 

Another one I just did for a C axis toolpath was like this:

#100=.04(FINISH X DIAMETER)

#101=.16(START X DIAMETER)

#102=3.773(START Z DPETH)

#103=.05(DEPTH OF CUT IN Z KEEP POSTIVE FOR NEGATIVE CUT)

#104=-6.623(FINISH DEPTH IN 1ST Z)

#105=360(DEGREE OF INCREMENTAL C AXIS)

#106=3000(DEGREE PER MINUTE OF C AXIS)

#107=.001(X AXIS TRAVEL KEEP POSTIVE FOR NEGATVIE DIRECTON)

#108=.0005(Z AXIS TRAVEL KEEP POSTIVE FOR NEGATIVE CUT)

#109=-6.683(FINISH STEP IN 2ND Z)

#110=5.(FEED IN X AXIS)

N100G1Z#102H#106F#106(N100 1ST GOTO)

#102=#102-#103(MATH TO MAKE SPRIAL IN Z AND C AXIS)

IF [#103GT#106] GOTO 100

IF [#103EQ#106] GOTO 200

N200G1X#103F#110

G1Z#104

G1H#105F#106

#103=#103-#107

#104=#104-#108

IF[#103GT#100] GOTO 200

IF[#103EQ#100] GOTO 300

N300G1X#103F#110(RUN LAST PASS AT DEPTHS)

G1Z#104

G1H#105F#106

M30

 

This is cutting a sprial in Z and C axis from one depth to another , then from that depth if cuts a 45 deg x .06 chamfer using a flat endmill. The part was creating al types of havoc using a flat bottom drill, but swtiching to en endmill in a custom shrink fit holder it allowed us to create a mirror finish 6.683 deep in a .91 bore to a .79 chamfer diameter using a .75 diameter endmill. Kind of cool to watch this program run.

 

Mazak's conversational programs are all just big macros. I use to have copies of everyone one of them, but over the years loast track of where they are.

 

Macros are juts big math problems. Tons of great resources out there.

 

HTH

Link to comment
Share on other sites

I´d like some good advices :). We have tool height setters in some of our older Fanuc 18i vmc´s that we put on the machine table, touch of a tool to it and input that absolute position to tool height offset page manually. Id like to automate this process with a macro so we could just touch the tool, call the macro and press cycle start and the right offset would update. So I would need the macro to capture said work offset (G59 for example) absolute position, tool number that is on the spindle and then update that same number in the tool offset page with that absolute position.

I can think so many uses of macros but have zero skills in programming or understanding them..

Link to comment
Share on other sites

OK Cannon, this is what I came up with so I hope this helps you out. You will have to know how to access your variables page in order to use this program. All you should have to do is enter in the first tool number you want to set in variable #100 and the last tool you want to set in variable #101. The program will automatically bring up each tool after you set each one. After the last tool is set there will be no more tool changing and the program will stop. Let me know if you need anything else. This is assuming you are using a cleared out G54, G55, etc. Z being set at Z zero. This example starts the tool out at T1 and ends with T10.

 

O0001(AUTOMATIC TLO MACRO)

(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

Thanks cncchipmaker! We have reference tool zeroed to tool height setter In G59 and other tools will measure + or - from it. I would also like it to capture tool number that is on the spindle and use that to set right tool offset. One tool would be setted at a time but no inputting of tool numbers would be needed. Would it go like this, read the current absolute position from system variables and set it to #500 variables, read current tool in spindle and set that also. Then I would have to make command where setted tool number is the same as tool offset being inputted and input would be the current absolute position in the other setted variable?

Link to comment
Share on other sites

This is a loop counter 10 times to warm up machines. Before the guy go home they are suppsoe to have the machien laoded and tested with these programs. Maintenace peoople come in fire up the machines, home them out and run these programs before the shop people show up. Machines have been warmed up and ready to go.

Sort of OT...

We don't run macros, but for the warm up (spindle prog) we have a hidden 9000 prog that has 999 assigned to it.

So (talking fanucs here) the mill's get switched on in the morning with the last nights running prog in the memory, and all we do is load the tool to the spindle and in mdi type 'M999' (eob/enter) and it runs.

When the prog finishes (and spindle is warm), go into edit and last nights prog is still there, and then you can run with no worries.

 

This came about as we used to have a normal warm up prog in the memory that we had to select and run, and then after it finished, the incorrect prog got loaded back into memory and executed (bleary eyed). Luckily it didn't doo much damage...

Link to comment
Share on other sites

Cannon, after reading your second post I wasn't sure if you had any more questions. The macro should pick up the absolute postion (referencing your too setter in G59) in Z based on the current tool in the spindle and load the correct tool length offset for you automatically. If you are not sure just dry run the program. I also told you needed to change the macros in #100 and #101. You actually only have to change the numbers to the right of those variables inside of the program. If it were me I would just try to run this current program by bringing each tool down a little bit in Z. You can verify that each of the tools by recording the absolute position of that tool on paper. After you hit the cycle start button and the next tool changes verify your tool length offset of that tool to see if the correct number got stored.

Link to comment
Share on other sites

I will try it out, thanks!

I forgot to also tell you that you can just store a single TLO by simply making variables #100 and #101 the same number. Ex: #100=22. , #101=22. will store TLO number 22. Please let me know if it works on your control because if it does it should work on most FANUC based controls.

Link to comment
Share on other sites

Cannon, here is the corrected program:

 

O0001(AUTOMATIC TLO MACRO)

(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

 

I should have explained how it works to you in more detail earlier. I found that your system variables for storing a TLO should correspond like this: #2001=TLO#1, #2002=TLO#2 etc., and your current absolute postion in Z should be #5003. I had to find a way to upcount the TLO variable everytime there was a tool change. In order to do that I am adding a 1. to variable #100 evertime there is a tool set. The program keeps running until the loop is satisfied: IF[#100LT#101]GOTO1, this loop basically says go to line number 1 if the current tool in the spindle is smaller than the last tool in the spindle that you want to set by variable #101. If you look variable #102 is calculated based on the numbers #100+2000. If you add them together that will correspond to the current tool in the spindles TLO variable. Ex: If #100=10. then #102 = 10.+2000. Then #102 will store the correct TLO by setting #[#102]=#5003.

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

Does anyone know if it is possible and if it is how you would go about writing a macro That if you had staged tools where each time a tool breakage or wear automatic tool change to the next identical tool that it would count it and everytime a certain number of these took place that it would count and when it reached a certain number it would then notify me. Its for a Okuma OSP P200L control.

 

Basically what i am trying to do is count my insert changes to know when I need to order more inserts.

Link to comment
Share on other sites

Does anyone know if it is possible and if it is how you would go about writing a macro That if you had staged tools where each time a tool breakage or wear automatic tool change to the next identical tool that it would count it and everytime a certain number of these took place that it would count and when it reached a certain number it would then notify me. Its for a Okuma OSP P200L control.

 

Basically what i am trying to do is count my insert changes to know when I need to order more inserts.

 

Tool life management is standard in a P200L. You can set up tool groups and keep track of it that way.

  • Like 2
Link to comment
Share on other sites

Yes, I have macros that allow u to rough out a profile or just do a finish pass with spring passes. I also have another version that alows u to use rotation as well. Which ones would u like to have

? They were developed for the Makinos here at work.

z stepdown version would be great. spring pass at the bottom would be nice but beggars can't be choosers. :cheers:

 

i loaded the macro i linked to into the Haas. it alarms out as is, but admittedly i didn't really spend 5minutes with it yet.

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