Command format - if, else and endif, Command format - if, else and endif example – Yaskawa SMC–4000 User Manual

Page 326

Advertising
background image

316

SMC–4000 User Manual

Command Format - IF, ELSE and ENDIF

Example:

Format:

Meaning

IF <condition>

Execute commands proceeding IF command (up to ELSE command) if
conditional statement(s) is true, otherwise continue executing at ENDIF
command or optional ELSE command.

ELSE

Optional command. Allows for commands to be executed when argument
of IF command evaluates not true. Can only be used with IF command.

ENDIF

Command to end IF conditional statement. Program must have an ENDIF
command for every IF command.

#TEST

Begin Main Program "TEST"

II,,3

Enable interrupts on input 1 and input 2

MG "WAITING FOR INPUT 1, INPUT 2"

Output message

#LOOP

Label to be used for endless loop

JP #LOOP

Endless loop

EN

End of main program

#ININT

Input Interrupt Subroutine

IF (@IN[1]=0)

IF conditional statement based on input 1

IF (@IN[2]=0)

2

nd

IF executed if 1

st

IF conditional true

MG "INPUT 1 AND INPUT 2 ARE
ACTIVE"

Message executed if 2

nd

IF is true

ELSE

ELSE command for 2

nd

IF statement

MG "ONLY INPUT 1 IS ACTIVE

Message executed if 2

nd

IF is false

ENDIF

End of 2

nd

conditional statement

ELSE

ELSE command for 1

st

IF statement

MG"ONLY INPUT 2 IS ACTIVE"

Message executed if 1

st

IF statement

ENDIF

End of 1

st

conditional statement

#WAIT

Label to be used for a loop

JP#WAIT,(@IN[1]=0) | (@IN[2]=0)

Loop until Input 1& 2 are not active

RI0

End Input Interrupt Routine without restoring
trippoints

Advertising