Example, Multiple conditional statements – Yaskawa LEGEND-MC User Manual

Page 301

Advertising
background image

291

LEGEND-MC User’s Manual

Example of conditional jump statements are given below:

Conditional jumps are useful for testing events in real-time. They allow the LEGEND-MC to make
decisions without a host computer. For example, the LEGEND-MC can decide between two motion
profiles based on the state of an input line. Or, the LEGEND-MC can keep track of how many times a
motion profile is executed.

Example:

Move the X motor to absolute position 1000 counts and back to zero ten times. Wait 100 msec between
moves.

Multiple Conditional Statements

The LEGEND-MC will accept multiple conditions in a single jump statement. The conditional
statements are combined in pairs using the operands “&” and “|”. The “&” operand between any
two conditions, requires that both statements must be true for the combined statement to be true.
The “|” operand between any two conditions, requires that only one statement be true for the
combined statement to be true.

Conditional

Meaning

JP #LOOP,COUNT<10

Jump to #LOOP if the variable, COUNT, is less than 10

JS #MOVE2,@IN[1]=1

Jump to subroutine #MOVE2 if input 1 is logic level high. After
the subroutine MOVE2 is executed, the program sequencer
returns to the main program location where the subroutine was
called.

JP #BLUE,@ABS[V2]>2

Jump to #BLUE if the absolute value of variable, V2, is greater
than 2

JP #C,V1*V7<=V8*V2

Jump to #C if the value of V1 times V7 is less than or equal to
the value of V8*V2

JP#A

Jump to #A

#BEGIN

Begin Program

COUNT=10

Initialize loop counter

#LOOP

Begin loop

PA 1000

Position absolute 1000

BGX

Begin move

AMX

Wait for motion complete

WT 100

Wait 100 msec

PA 0

Position absolute 0

BGX

Begin move

AMX

Wait for motion complete

WT 100

Wait 100 msec

COUNT=COUNT-1

Decrement loop counter

JP #LOOP,COUNT>0

Test for 10 times through loop

EN

End Program

Advertising