Introduction, 8 user variables and the define statement – Lenze E94P PositionServo with MVOB User Manual

Page 25

Advertising
background image

PM94H201B_13xxxxxx_EN

L

23

Introduction

;************************** Events ************************************************

EVENT SPRAY_GUNS_ON

APOS>25 ;Event will trigger as position passes 25 in pos dir.

OUT3=1

;Turn on the spray guns (out 3 on)

ENDEVENT

;End event

EVENT SPRAY_GUNS_OFF

APOS>75 ;Event will trigger as position passes 75 in pos dir.

OUT3=0

;Turn off the spray guns (out 3 off)

ENDEVENT

;End event

;************************** Main Program ******************************************

WAIT UNTIL IN_A3

;Make sure the Enable input is made before continuing

ENABLE

OUT1 = 0

;Initialize Pick Arm - Place in Retracted Position

WAIT UNTIL IN_A4==1

;Check Pick Arm is in Retracted Position

EVENT SPRAY_GUNS_ON ON

EVENT SPRAY_GUNS_OFF ON

PROGRAM_START:

MOVEP 0

;Move to Pick position

OUT1 = 1

;Turn on output 1 to extend Pick arm

WAIT UNTIL IN_A1==1

;Arm extends

OUT2 = 1

;Turn on output 2 to Engage gripper

WAIT TIME 1000

;Delay 1 sec to Pick part

OUT1 = 0

;Turn off output 1 to Retract Pick arm

WAIT UNTIL IN_A4==1

;Make sure Arm is retracted

MOVEP 100

;Move to Place position

OUT1 = 1

;Turn on output 1 to extend Pick arm

WAIT UNTIL IN_A1==1

;Arm extends

OUT2 = 0

;Turn off output 2 to Disengage gripper

WAIT TIME 1000

;Delay 1 sec to Place part

OUT1 = 0

;Retract Pick arm

WAIT UNTIL IN_A4==1

;Arm is retracted

GOTO PROGRAM_START

END

1.8

User Variables and the Define Statement

In the previous program for the pick and place machine constant values were used for position limits to trigger the
events and turn the spray gun ON and OFF. If limits must be calculated based on some parameters unknown before
the program runs (like home origin, material width, etc.), then this system data can be stored in user variables. The
PositionServo provides 32 User Variables V0-V31 and 32 User Network Variables NV0-NV31. Network variables have
an additional function associated to them (refer to ‘Send’ Command) but can, for most purposes, be considered as user
variables in the same way as the standard user variables (V0-31). Hence 64 user variables or data storage locations are
available to the programmer. In the program following the example DEFINE statements, the limit APOS (actual position)
is compared to V1 for an ON event and V2 for an OFF event. The necessary limit values could be calculated earlier in
the program or supplied by an HMI or host PC. The DEFINE statement can be used to assign a name to a constant,
variable, or drive Input/Output. In the program below, constants 1 and 0 are defined as Output_On and Output_Off.
DEFINE is a pseudo statement, i.e it is not executed by the program interpreter, but rather substitutes expressions in
the subsequent program at the time of compilation. Examples of the DEFINE statement:

; Definition of Constant Values

DEFINE Move_1 100

DEFINE BallScrewPitch 0.357

; Definition of Inputs/Outputs

DEFINE System_Run_IP In_B1

DEFINE Process_Run_OP Out1

; Definition User Variables

DEFINE Distance_Travelled V2

DEFINE Network_Healthy NV10

Programming the following statement: Distance_Travelled = Move_1 * BallScrewPitch

Is now the equivalent of writing: V2 = 100 * 0.357

Advertising