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:

Macros: Automatic calculation of fixture offsets


powerfulp
 Share

Recommended Posts

I want the control to calculate fixture offsets for me by using macros (fanuc macro B). I'm not quite sure how to write the formula for this.

 

What I have is a horizontal machining center with a rotary B-axis. I want to manually enter the X-axis and Z-axis numbers (for the work offsets) at B0 (G54), then run the program and have the formula in the program enter in the rest of the work offsets at the other B-axis angles.

 

For instance, if I entered in ".0500" for X-axis and "9.0000" for Z-axis, the offsets at B180.000 would be just the opposite signs (-.0500 & -9.0000, respectively). That would be easy enough to write. But I need the formula to be able to calculate at "odd" B-axis angles, like say 103.250 (The answers would be X-8.7719, Z-2.0141), using trigonometry.

 

So for an example, if I had a G54 (B0) offset with the X & Z-axis numbers given (I enter and these numbers represent distance from c/l of index), I would want to calculate for the X & Z-axis numbers for G55 (@B103.250). I would want the formula to consider what is in the G54 X & Z work offsets (#5221 & #5224), then calculate for the new X & Z work offsets based on what's in the B-axis offset for G55 (#5246), and automatically enter in the table. I know I need to use SIN and COS, but I'm not sure exactly how and where...

 

I hope I explained that well enough.

 

Any help is appreciated....

Link to comment
Share on other sites

From Fanuc G54.2

 

The rotary table dynamic fixture offset function saves the operator the

trouble of re–setting the workpiece coordinate system when the rotary

table rotates before cutting is started. With this function the operator

simply sets the position of a workpiece placed at a certain position on the

rotary table as a reference fixture offset. If the rotary table rotates, the

system automatically obtains a current fixture offset from the angular

displacement of the rotary table and creates a suitable workpiece

coordinate system. After the reference fixture offset is set, the workpiece

coordinate system is prepared dynamically, wherever the rotary table is

located.

The zero point of the workpiece coordinate system is obtained by adding

the fixture offset to the offset from the workpiece reference point.

Link to comment
Share on other sites

That sounds cool, and I will look into it, thanks. However, I still want to know how to write this. I have mazak and mitusbishi and other controls that use custom macro B but aren't fanuc controls. Plus it would help me become more familiar with custom macro B, etc. I figured it out using excel (in a spreadsheet) but I'm not as familiar with custom macro B...

Link to comment
Share on other sites

Are you looking for something like this, you just set your offset on the macro variables and add the math in the program

(B0. OFFSET)

G0G90G10L2P1X#601Y#602Z#603

N88T9008(101240 ENDMILL)

M6

G65P7716B360.(COORDINATE ROTATION)

M11

G0G90G54B0.M8

M10

G0G90G54X.527Y.4103S2801M3T9004

G43H99Z2.

M98P1011

G0G90G55X.527Y.4103

Z2.

M98P1011

Z12.

(B60. OFFSET ROTATION)

G0G90G10L2P1X-[COS[60]*[#601]-[#603*SIN[60]]]Y[#602]Z-[#601*SIN[60]+[#603]*COS[60]]

M11

G0G90G54B60.

M10

G0G90G54X-1.3926Y.5

Z2.

M98P1012

G0G90G55X-1.3926Y.5

Z2.

M98P1012

M5

G0G91G30Z0.M9

G0G91G30X0.Y0.

M01

Link to comment
Share on other sites

That formula is exactly correct mathematically, but I don't understand the order of operations. If I use your model, my formula would look like this:

 

for the X-axis offset:

#5241=[COS[42]*[#5221]-[#5224*SIN[42]]] (Answer is -5.9850)

 

and for Z-axis:

#5244=[#5221*SIN[42]+[#5224]*COS[42]] (Answer is 6.7218)

 

I haven't tried this in the machine (I'm not at work till tomorrow), but doing it manually, I know what order to do the calculations. I can't tell what it's doing with the brackets, though. Ok, this is going to be a crazy question, but how do you know where to put them (the brackets)? I would like to write some other formulas ...

 

Thanks...

 

- Paul

Link to comment
Share on other sites

It can be a pretty simple macro. Or it can be pretty cumbersome. Depending on what you need for functionality.

 

I wrote one that simple takes one offset(g54...) and transfers compensated values to another offset (g55...). Works very well. Use it all the time.

 

A typical callup for me would be.

 

G65 P9050 A0. B123.222 C1. D2. E3. F2.

 

rotate G54.1 P1 to 123.222 and put into G54.1 P3

 

This would not physically move the machine but would set the offset to be used when you move there.

 

I am willing to give it up if you need it. But I find with on machine "software" like this it is best to write them yourself so you are familiar with it in case you are having problems and need to troubleshoot.

 

In a nutshell you need only do a few things.

 

establish centerline of rotation

 

calculate vector to C/L

 

rotate vector about c/l

 

output vector endpoint in cartesian coordinates

 

easy as pie.

 

Words of advice. Pay attention to your quadrants. Make sure to know how you trig functions act in each quadrant. Or as I didm just create different cases for each quadrant.

 

 

Good Luck

Link to comment
Share on other sites

Here is what I use

 

O9910

IF[#23GT49]GOTO50

IF[#23GE1]GOTO200

IF[#23EQ#0]GOTO3000

 

N50#100=[#23-53]

 

(W = WORK OFFSET TO BE USED FOR CALC)

(R = NEW WORK OFFSET NUMBER)

(B = INDEX AMOUNT)

(X = INC TO NEW X ZERO AFTER ROTATION)

(Z = INC TO NEW Z ZERO AFTER ROTATION)

 

#540=-19.682 (MACHINE POS X ROTATION)

#541=-42.13 (MACHINE POS Z ROTATION)

 

#542=#[5201+[#100*20]] (STORE CURRENT X OFFSET FOR CALC)

#543=#[5203+[#100*20]] (STORE CURRENT Z OFFSET FOR CALC)

 

 

#544=[#542-#540](DELTA X)

#545=[#543-#541] (DELTA Z)

 

#546=SQRT[[#544*#544]+[#545*#545]] (HYP FOR CALC)

 

#547=[ASIN[#544/#546]] (START DEG FOR CALC)

 

#548=[#547+-#2] (CACL DEG)

 

#549=[sIN[#548]*#546] (NEW DELTA X)

#550=[COS[#548]*#546] (NEW DELTA Z)

 

#551=[#549+#540] (NEW X OFFSET)

#552=[#550+#541] (NEW Z OFFSET)

 

IF[#18GT49]GOTO2

IF[#18GE1]GOTO20

IF[#18EQ#0]GOTO3000

 

M99

 

N200#100=[#23]

 

(W = WORK OFFSET TO BE USED FOR CALC)

(R = NEW WORK OFFSET NUMBER)

(B = INDEX AMOUNT)

(X = INC TO NEW X ZERO AFTER ROTATION)

(Z = INC TO NEW Z ZERO AFTER ROTATION)

 

#540=-19.682 (MACHINE POS X ROTATION)

#541=-42.13 (MACHINE POS Z ROTATION)

 

#542=#[6981+[#100*20]](STORE CURRENT X OFFSET FOR CALC)

#543=#[6983+[#100*20]](STORE CURRENT Z OFFSET FOR CALC)

 

 

#544=[#542-#540](DELTA X)

#545=[#543-#541] (DELTA Z)

 

#546=SQRT[[#544*#544]+[#545*#545]] (HYP FOR CALC)

 

#547=[ASIN[#544/#546]] (START DEG FOR CALC)

 

#548=[#547+-#2] (CACL DEG)

 

#549=[sIN[#548]*#546] (NEW DELTA X)

#550=[COS[#548]*#546] (NEW DELTA Z)

 

#551=[#549+#540] (NEW X OFFSET)

#552=[#550+#541] (NEW Z OFFSET)

 

IF[#18GT49]GOTO2

IF[#18GE1]GOTO20

IF[#18EQ#0]GOTO3000

 

N2

G90G10L2P[#18-53.]X#551Z#552B#2

G91G10L2P[#18-53.]X#24Z#26

M99

 

N20

G90G10L20P#18X#551Z#552B#2

G91G10L20P#18X#24Z#26

M99

 

N3000#3006=[(NO WORK OFFSET CHECK G65 LINE)]

M30

Link to comment
Share on other sites

Wow, these are all awesome replies, thanks. I will be experimenting with all of these.

 

Does anyone think my formula will work, though? I can't get on the machine to check it at this time, but here it is again:

 

for the X-axis offset:

#5241=[COS[42]*[#5221]-[#5224*SIN[42]]] (Answer is -5.9850)

 

and for Z-axis:

#5244=[#5221*SIN[42]+[#5224]*COS[42]] (Answer is 6.7218)

 

#5221 is the X-axis position at G54 (B0)which is +.0500

#5224 is the Z-axis position at G54 (B0)which is +9.0000

and the "42" is the B-axis angle that I am figuring out the offsets for.

 

The calculations are correct, I just don't know about the precedence (the use of the brackets). Will the formulas reach the same answers and I have above?

 

Thanks for any help....

Link to comment
Share on other sites

I think this will work, it's a little more simplified...

 

#7021=[#5321*COS[155.369]]-[#5324*SIN[155.369]]

#7024=[#5321*SIN[155.369]]+[#5324*COS[155.369]]

 

I can understand the order of operations in this one. COS of 155.369 degrees x #5321 minus SIN of 155.369 degress x #5324 = -2.1255 if #5321 is zero is #5324 is 5.1000. The next one equals -2.1255. The numbers come out correct and I believe the preferences are correct. I will find out when I try it on my machine, hopefully sometime this weekend....

 

Thanks everyone for the input! :)

 

- Paul

Link to comment
Share on other sites

Here's mine :welcome:

 

%

O9018(G2201 -- XZ COORDINATE ROTATION PROGRAM)

(PARAMETER 6058)

#10=[13980+[#4130*20]](CURRENT FIXTURE OFFSET NUMBER)

#11=[#10+1](NUMBER FOR CURRENT OFFSET X)

#12=[#10+2](NUMBER FOR CURRENT OFFSET Y)

#13=[#10+3](NUMBER FOR CURRENT OFFSET Z)

#14=[#10+4](NUMBER FOR CURRENT OFFSET B)

#15=[ABS[#921]-ABS[#[#13]]](Z LENGTH FROM PALLET CL)

#16=[#[#11]](X LENGTH FROM PALLET CL)

#17=SQRT[[#15*#15]+[#16*#16]](HYPOTENUSE LENGTH)

#18=ATAN[#16]/[#15](ANGLE FROM PALLET CL TO PART ORIGIN)

(NOW MAKING NEW G59 COORDINATES)

#19=[sIN[#18-#2]*[#17]](PART ANGLE + ORIGIN ANGLE X LENGTH)

#20=[COS[#18-#2]*[#17]](PART ANGLE + ORIGIN ANGLE Z LENGTH)

#5321=[#19](X G59 COORDINATE)

#5322=[#[#12]]

#5323=[#921]+[#20](Z G59 COORDINATE)

#5324=[#[#14]]

#19981=[#19](X G54P300 COORDINATE)

#19982=[#[#12]]

#19983=[#921]+[#20](Z G54P300 COORDINATE)

#19984=[#[#14]]

M99

%

 

Edit to add a snippet of the part programming...

 

.

.

.

END1

N113 WHILE[#[#539+600+[2-1]]EQ1]DO1 (SURFACE 3)

IF[#172EQ5101]GOTO211

IF[#172EQ5102]GOTO212

IF[#172EQ5105]GOTO211

#900=[#539+[2-1]]

G91 G00 X0 G54 P[#900]

G90 G00 B270.

G2201 B270. <<<<<<<<<<<<<<<<<<

G91 G00 X0 G59

M#173 P[#170+3]

GOTO211

END1

.

.

.

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

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