not really enough info. It can get quite complex.
However you seem to have worked out most of it yourself.
you can use SIN/COS/TAN in macros.
#1 = SIN[103.123]
#5221 = 945.567 - #1
(or whatever you want to calculate)
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 hope I explained that well enough.
Any help is appreciated....
not really enough info. It can get quite complex.
However you seem to have worked out most of it yourself.
you can use SIN/COS/TAN in macros.
#1 = SIN[103.123]
#5221 = 945.567 - #1
(or whatever you want to calculate)
This is what I have so far:
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)
The only thing is the order of operations - I'm not sure how to write it so it does what I want to do in order. Can anyone give me a brief explanation of use of the brackets??
Thanks....
See Post #6
Last edited by Kiwi; 02-02-2012 at 05:40 AM.
in general programming terms calculate the inner brackets first then move out to the next bracket pair and do that calculation. you may need to remember some numbers then apply them at the end. when using brackets there must be a pair of brackets for each calculation.
example....
a = (1+(2*3))*4
the answer is calculated as
2*3 = 6
then 1+6 = 7
then 7 *4
so a = 28
you really should google for an explanation on this. it's basic maths.
'Order Of Operations'
here's one example....
Order of Operations
#5241 = [#5221 * Cos[42]] - [#5224 * Sin[42]]
#5244 = [#5221 * Sin[42]] + [#5224 * Cos[42]]
Last edited by Kiwi; 02-02-2012 at 03:12 PM. Reason: Variables labeled incorrectly
Thanks your your help...much appreciated.
If you have many work offsets per operation, and a limited amount of work offsets, you may want to consider making your macro an integral part of your standard programming format.
For example, you put your original origin in G54 and your macro calculates each new position as the B-axis indexes in the main program, overwriting the 'temporary' offset position (eg G59) with every process.
Keeps things tidier, especially when running multiple pallets and/or if offsets need to be re-established for each part.
DP
Sounds interesting but I'm not getting it completely. Could you elaborate?
Thanks
Once you have your macro program formulae working correctly, assign a G-code to it and use it in your program instead of work offset calls. The B-AXIS ROTATION, work offset overwrite, and subsequent work offset call (G59 say), will always be in the macro program. This method means you only need to store one offset for each job and leave the G59 as your 'running' offset.
All the sequences in my main programs look like this: -
N5 (Operation)
G123 D1 R0 <------------- Call setup macro, defining the Datum to rotate by R
T# M6
S# M3
blah
blah
blah
M1
I use the extended work offsets (G54.1 P1 - P47) to define my original datum and P48 is the ALWAYS the offset that is written to (and called) by G123 BEFORE returning to the main program.
This means I can tweak my original offset if required and start without fear from any sequence number in the program.
Now that this format is standard, I have built so much more into G123 than simply offset calcs; eg safety retract based on workpiece/tool length, pallet load based on offset number, even skipping the current sequence entirely if required (eg multiple part fixture without a full complement of parts..).
DP
Last edited by christinandavid; 02-03-2012 at 05:10 PM.
That is definitely cool and some very good ideas. Would you be willing to share seem "complete" examples? (Willing to share the entire code of something so I can wrap my head around it)
Have attached a flowchart showing all the tasks my setup macro is responsible for. We can discuss any particular function you are interested in, in more detail if you wish.
How much of that lot you would want to adopt would depend on your control and your needs (unnecessary automation can be bad), as well as how much discipline you want to impose on your programming format.
My suggestion is to integrate one thing at a time, once you have decided it is necessary and have a fairly fool-proof way of working it in to your method. That is how my macro evolved, always taking into account that others will have to follow what you have done and must also reap the benefits - otherwise there may be some justified resistance...
DP