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

Wednesday, August 14, 2013

Fanuc Macro Programming Series - Part #4 : System Variables

The last type of Fanuc Macro Variables we will cover in our series are called SYSTEM VARIABLES. System Variables are fixed variables and read and reflect on conditions or values found somewhere in the CNC system. There are a variety of System Variables available to the user but they can for the most part be classified into some major groups :

INTERFACE SIGNALS :
The status of various input / output signals can be read using System Variables #1000 thru #1035, #1100 thru #1115 and #1132 thru #1135. Users should consult with their own individual electrical diagrams as specific input / output signals can be designed differently by different machine tool builders. But the general configuration looks like this :



TOOL GEOMETRY OFFSET VALUES :
Tool offset values as well as work offset values can also be read and modified through the System Variables as well. Those variable configurations look like :


WORK OFFSET VALUES :
Work offset values ... G54 thru G59 ... can also be read and modified through the System Variables as well. Those variable configurations look like :


ALARM GENERATION :
Users have the ability to generate ALARMS with user defined message using System Variable #3000. The format for using System Variable #3000 is :

#3000 = XX ( error message defined here )

In the above format ... XX is the error message # ( must be less than 999 ) and the error message to display is defined between the (   ) . For example :

#3000 = 123 ( ERROR ENCOUNTERED )

When the macro program executes the line as above, the machine would enter the alarm condition ... the CRT will display Error #123 followed by the message ERROR ENCOUNTERED. Clearing the alarm condition is as normal.

The user has complete control over the Alarm # and the message to be displayed.

SUPPRESSION OF MACHINE FUNCTIONS  :
Through the use of the System Variables as outlined below ... users can suppress certain machine functions. Users should exercise caution when using these System Variables.


MODAL INFORMATION :
Modal information ... up to the current block ... can be read using the System Variables as outlined below :


POSITIONAL INFORMATION :
Using the System Variables as outlined below, the position of each axis of the machine can be read. The chart outlines the type of position ... and whether or not the tool offsets are considered.


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

Now that we have all the definitions out of the way ... the next posts in our series will put all these definitions to use. THE FUN BEGINS ... Stay Tuned !!