2 variables, Programming – Lenze PM94P01C User Manual

Page 36

Advertising
background image

PM94P01C

34

Programming

The

Events section contains all scanned events. Remember to execute the EVENT <eventname> ON statement in

the main program to enable the events. Please note that not all of the SML statements are executable from within the
EVENT body. For more detail, reference “EVENT” and “ENDEVENT” in Section 3 of the manual. The GOTO statement
can not be executed from within the Event body. However, the JUMP statement can be used to jump to code in the main
program body. This technique allows the program flow to change based on the execution of an event. For more detail,
reference “JUMP”, in Section 3.1 (Program Statement Glossary) of this manual.

The

main program body of the program contains the main part of the program, which can include all motion and math

statements, labels, I/O commands and subroutine calls. The main body should be finished with an END statement,
however if the program loops indefinitely then the END statement can be omitted.

Subroutines are routines that are called from the main body of the program. When a subroutine is called, (GOSUB), the
program’s execution is transferred from the main program to the called subroutine. It will then process the subroutine
until a RETURN statement occurs. Once a RETURN statement is executed, the program’s execution will return back to
the main program to the line of code immediately following the GOSUB statement.

Fault handler is a section of code that is executed when the drive detects a fault. This section of code begins with the
“ON FAULT” statement and ends with an “ENDFAULT” statement. When a fault occurs, the normal program flow is
interrupted, motion is stopped, the drive is disabled, Event scanning is stopped and the statements in the Fault Handler
are executed, until the program exits the fault handler. The Fault handler can be exited in two ways:

-

The “RESUME” statement will cause the program to end the Fault Handler routine and resume the execu-
tion of the main program. The location (label) called out in the “RESUME” command will determine where the
program will commence.

-

The “ENDFAULT” statement will cause the user program to be terminated.

While the Fault Handler is being executed, Events are not being processed and detection of
additional faults is not possible. Because of this, the Fault Handler code should be kept as
short as possible.
If extensive code must be written to process the fault, then this code should be placed in the
main program and the “RESUME” statement should be utilized. Not all of SML statements
can be utilized by the Fault Handler. For more details reference “ON FAULT/ENDFAULT”,
in Section 3.1 (Program Statement Glossary) of this manual.

Comments are allowed in any section of the program and are preceded by a semicolon. They may occur on the
same line as an instruction or on a line by themselves. Any text following a semicolon in a line will be ignored by the
compiler.

2.2

Variables

Variables can be System or User. User variables do not have a predefined meaning and are available to the user
to store any valid numeric value. System variables have a predefined meaning and are used to configure, control or
monitor the operations of the PositionServo. (Refer to paragraph 2.6 for more information on System Variables).

All variables can be used in valid arithmetic expressions. All variables have their own corresponding index or identification
number. Any variable can be accessed by their identification number from the User’s program or from a Host Interface.
In addition to numbers some of the variables have predefined names and can be accessed by that name from the User’s
program.

The following syntax is used when accessing variables by their identification number:

@102 = 20

; set variable #102 to 20

@88=@100

; copy value of variable #100 to variable #88

Variable @102 has the variable name ‘V2”; variable @88 has the variable name ‘VAR_AOUT’ and variable @100 has
the variable name ‘V0’. Hence the program statements above could be written as:

V2 = 20

VAR_AOUT = V0

Advertising