8variables and define statement, Variables and define statement, 8 variables and define statement – Lenze PMSS1000 Simple Servo User Manual

Page 19

Advertising
background image

Indexer-Programmer-Manual.pdf REV 1.3

1.8 Variables and Define statement

In the previous program for programmable limit switch we used hard coded numbers 3 and 6 :

EVENT

InLimits

ALWAYS

;scanned every 256uS

;

OUT1=APOS>=3 && APOS<=6

;Hard Coded Limit values

ENDEVENT

Using hard coded numbers is fine as long as these numbers are known at the moment when you
preparing program. (Or we call it "at compile time").But what if limits has to be calculated based on some
parameters unknown before program run? (i.e. home origin, material width etc.). Then you can use User
Variables instead of hard coded values. SSi has 32 User Variables available for calculation and storage
of intermediate data. Let's use variable V1 and V2 to hold the values of lower and upper travel limits:

;Modified program:
EVENT

InLimits

ALWAYS

;scanned every 256uS

;
OUT1= APOS>=V1 && APOS<=V2 ;Variables hold Limit values
ENDEVENT

It might be difficult to remember that V1 is the lower and V2 is upper travel limit later on. The DEFINE
statement lets a programmer define a meanful name to a variable. The program looks like this:

DEFINE

LowerLimit V1

;name alias for V1

DEFINE

UpperLimit V2

'name alias for V2

Define ALWAYS 1
EVENT

InLimits

ALWAYS

;scanned every 256uS

;
OUT0=APOS >= LowerLimit && APOS <= UpperLimit ;Variables V1 V2
;named by DEFINE statement
ENDEVENT

19

Advertising