Introduction, 9 if/else statements – Lenze E94P PositionServo with MVOB User Manual

Page 26

Advertising
background image

24

L

PM94H201B_13xxxxxx_EN

Introduction

;*************************** Initialize and Set Variables ******************************

UNITS = 1

;Define units for program, 1=revolution of motor shaft

ACCEL = 5

;Set Acceleration rate for Motion command

DECEL = 5

;Set Deceleration rate for Motion command

MAXV = 10

;Maximum Velocity for Motion commands

V1 = 25

;Set Variable V1 equal to 25

V2 = 75

;Set Variable V2 equal to 75

DEFINE

Output_On

1

;Define Name for output On

DEFINE

Output_Off 0

;Define Name for output Off

;*************************** EVENTS ***************************************************

EVENT SPRAY_GUNS_ON APOS > V1

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

OUT3= Output_On

;Turn on the spray guns (out 3 on)

ENDEVENT

;End event

EVENT SPRAY_GUNS_OFF APOS > V2

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

OUT3= Output_Off

;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

;Enable the Event

EVENT

SPRAY_GUNS_OFF ON

;Enable the Event

PROGRAM_START:

MOVEP 0

;Move to position 0 to pick part

OUT1 = Output_On

;Turn on output 1 to extend Pick arm

WAIT UNTIL IN_A1==1

;Check input to make sure Arm is extended

OUT2 = Output_On

;Turn on output 2 to Engage gripper

WAIT TIME 1000

;Delay 1 sec to Pick part

OUT1 = Output_Off

;Turn off output 1 to Retract Pick arm

WAIT UNTIL IN_A4==1

;Check input to make sure Arm is retracted

MOVED 100

;Move to Place position

OUT1 = Output_On

;Turn on output 1 to extend Pick arm

WAIT UNTIL IN_A1==1

;Check input to make sure Arm is extended

OUT2 = Output_Off

;Turn off output 2 to Disengage gripper

WAIT TIME 1000

;Delay 1 sec to Place part

OUT1 = Output_Off

;Retract Pick arm

WAIT UNTIL IN_A4==1

;Check input to make sure Arm is retracted

GOTO PROGRAM_START

END

1.9

IF/ELSE Statements

An IF/ELSE statement allows the user to execute one or more statements conditionally. The programmer can use an
IF or IF/ELSE construct:

Single IF example:

This example increments a counter, Variable “V1”, until the Variable, “V1”, is greater than 10.

Again:

V1=V1+1

IF V1>10

V1=0

ENDIF

GOTO Again

END

Advertising