8 variables and define statement, Introduction – Lenze PM94P01C User Manual

Page 25

Advertising
background image

PM94P01C

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 **************************************
PROGRAM_START:

;Place holder for main program loop

ENABLE

;Enable output from drive to motor

EVENT SPRAY_GUNS_ON ON

;Enable ‘spray guns on’ event

EVENT SPRAY_GUNS_OFF ON

;Enable ‘spray guns off’ event

WAIT UNTIL IN_A4==1

;Make sure Arm is retracted

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

;Loop back and continuously execute main program loop

END

1.8

Variables and Define Statement

In the previous program for the pick and place machine constants were used for position limits to trigger the event 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 use the User Variables. The PositionServo provides 32 User Variables
V0-V31 and 32 User Network Variables NV0-NV31. In the program below, 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.
DEFINE Value2

2

DEFINE Value10

10

V1 = Value2+Value10 ; result is 12
V1 = 2+10

; does exactly same as above, the result is 12

Advertising