2user variables, User variables, 2 user variables – Lenze PMSS1000 Simple Servo User Manual

Page 27

Advertising
background image

Indexer-Programmer-Manual.pdf REV 1.3


The header section of the program contains definitions of the names for user variables and constants
used in the program. If none of these are used in a program the header section is not required.

Events sections contain all scanned events sections. Remember to execute EVENT <eventname> ON
statement in main program to enable events. Not all statements are possible to use within event body.
See EVENT/ENDEVENT statement in Language Reference section for details on the statements
restrictions. While GOTO statement is prohibited within event code, you can use JUMP statement to jump
to code in main program body. You can use such technique if you need to change program flow by
occurrence of the event. See JUMP statement in Language Reference section for details.
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. Main body has to be finished
with END statement.
Subroutines are routines hat are called from the body of the program. When a subroutine is called,
program execution is transferred to the subroutine until a RETURN statement occurs. Then, program
execution returns to the body of the program following the GOSUB statement.
Fault handler is the special section of the program embraced with ON FAULT and ENDFAULT
statements. When any fault occurred normal program flow will be interrupted and statements in fault
handler will start to execute. When fault occurs the motion (if any) will be stopped and drive will be
disabled. Events scanning will be stopped until program exits fault handler. Fault handler can be
terminated two ways:
Using RESUME <label>.Statement will end fault handler end start execute code from location named in
<label>. Using RESET statement. Statement will reset program execution from first statement.
If ENDFAULT statement is met before RESET or RESUME statements user program will be terminated.
Fault handler should be kept as short as possible. If You need extensive processing of the fault create
such code in main program and make RESUME <label> as soon as possible. While fault handler is active
events are not being processed and detection of the other faults is not possible. Not all statements can be
used while program in the fault handler. See ON FAULT/ENDFAULT statement description in Language
Reference section for details.
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 that contains only the comment. Any text following a
semicolon on a line will be ignored by the compiler.

2.2 User

Variables

SML supports a fixed set of variables that the programmer can use to store data and perform arithmetic.
All user variables are of a single type(see below). Single type variables facility (typeless variables) relieve
programmer of the task to remember and apply conversion rules between types, thus greatly simplifying
programming.
Since SML is typeless language, there is no special type for Boolean type variables (variables that can be
only 0 or 1). Regular variables are used to facilitate Boolean variables. When assigning 0 value to
variable it is evaluated as "FALSE" in logic equations and non 0 value evaluates as "TRUE".
In addition to the user variables, system variables are also supported.
System variables are dedicated variables that contain particular values. For example, APOS contains
actual position of the motor shaft. System variables are discussed later in chapter "System Variables and
Flags".

Scope
SML variables are available system wide. Each of the variables can be read and set from any user
program, subroutine or Host Language Command at any time. There is no provision to protect a variable
from change. This is referred as global scope.

27

Advertising