Created and Maintained by the Real World Software Developers and Machinists at www.KentechInc.com ... click here to check it out !!

Wednesday, August 28, 2013

Fanuc Macro Programming Series - Part #5 : Arithmetic Functions / Control Commands

The power of the Custom Macro language lies in the use of a variety of arithmetic functions within the custom macro body. This features gives the user the power to re-define and re-calculate the values of variables "on the fly." This post is meant as a brief explanation and overall view of some of these functions available with a more in-depth view given in following posts in this series.

Types of Commands Available 

Definition and Substitution
( #100 = #101 )

Addition and Subtraction
( #100 = #101 + #102 )
( #100 = #101 - #102 )

Multiplication and Division
( #100 = #101 * #102 )
( #100 = #101 / #102 )

Logical Sum -- Exclusive OR -- Logical Product
(  #100 = #101 OR  #102 )
(  #100 = #101 XOR  #102 )
(  #100 = #101 AND  #102 )

Trigonometric Functions
( #100 = SIN(#101)) ----- Sine
( #100 = COS(#101)) ----- Cosine
( #100 = TAN(#101)) ----- Tangent
( #100 = ATAN(#101)) ----- Arc Tangent
( #100 = ASIN(#101)) ----- Arc Sine
( #100 = ACOS(#101)) ----- Arc Cosine

Other Mathematical Functions
( #100 = SQRT(#101)) ----- Square Root
( #100 = ABS(#101)) ----- Absolute Value
( #100 = BIN(#101)) ----- Conversion from BCD to BIN
( #100 = BCD(#101)) ----- Conversion from BIN to BCD
( #100 = ROUND(#101)) ----- Rounding Off
( #100 = FIX(#101)) ----- Discard fractions less than 1
( #100 = FUP(#101)) ----- Add 1 for fractions less than 1
( #100 = LN(#101)) ----- Natural Logarithm
( #100 = EXP(#101)) ----- Exponent with base
( #100 = ADP(#101)) ----- Addition of

Another powerful feature of the Custom Macro language is the ability for the user to control the flow of the programs execution. Using a variety of what is called CONTROL COMMANDS, the user can repeat areas, jump to areas and set conditions for program execution.Again, presented here is a brief explanation and overall view of some of these functions available with a more in-depth view given in following posts in this series.

Types of Control Commands Available 

DIVERGENCE
IF < condition> GOTO N----
When the <condition> is satisfied, the program execution jumps
to sequence number N----.
Example : IF [#100 = #102] GOTO N100

CONDITIONAL EXPRESSIONS EXPLAINED
The following are expressions that can be used to define conditional expressions :
EQ = equal to
NE = not equal to
GT = greater than
LT = less than
GE = greater than or equal to
LE = less than or equal to

ITERATION
WHILE < condition> DO <number>
......
END <number>

While the <condition> is satisfied, the program executes blocks between the WHILE statement and the END statement.

Example : 
WHILE [#100 LT #102] DO 1
( program commands )
( program commands )
( program commands )
#100 = #100 + 1 ( add 1 to #100 at the end of each body run )
END 1

BRANCH COMMAND
GOTO N----

Program execution jumps to sequence number N----
Example : GOTO N101

----------------------------

Being well versed in the information from this post will be a big help as we go forward with some macro programming examples in future posts.

The fun is just beginning ... Stay Tuned !!

No comments:

Post a Comment