When

Description

The When statement is used for very fast response to certain input conditions. Upon encountering and executing the When statement, program execution waits until the specified condition is satisfied. When the condition is satisfied, the when-action is executed immediately and the program continues at the next line after the When statement. The syntax is as follows:

When when-condition, when-action

The following tables lists the possible when-conditions and when actions

When-conditions
DIN1.STATE = 0 or 1
DIN2.STATE = 0 or 1
DIN3.STATE = 0 or 1
DIN4.STATE = 0 or 1
DIN5.STATE = 0 or 1
DIN6.STATE = 0 or 1
DIN7.STATE = 0 or 1
DIN21.STATE = 0 or 1
DIN22.STATE = 0 or 1
DIN23.STATE = 0 or 1
DIN24.STATE = 0 or 1
DIN25.STATE = 0 or 1
DIN26.STATE = 0 or 1
DIN27.STATE = 0 or 1
DIN28.STATE = 0 or 1
DIN29.STATE = 0 or 1
DIN30.STATE = 0 or 1
DIN31.STATE = 0 or 1
DIN32.STATE = 0 or 1
DRV.HANDWHEEL < value
DRV.HANDWHEEL > value
DRV.TIME > value
EXTENCODER.POSITION < value
EXTENCODER.POSITION > value
FB3.P > value
FB3.P < value
MOVE.MOVING = 0 or 1

MOVE.INPOSITION = 0 or 1

PL.CMD < value

PL.CMD > value
PL.FB < value
PL.FB > value

 

When-actions
CAM.ACTIVATE = 0 to 8
CAMVM.GOREL
CAMVM.GOUPDATE
CAMVM.GOVEL
CAMVM.STOP
Continue
DOUT1.STATEU = 0 or 1
DOUT2.STATEU = 0 or 1
EGEAR.RATIO = value
EGEAR.ON = 0 or 1
MOVE.ABORT
MOVE.GOABS
MOVE.GOREL
MOVE.GOVEL
MOVE.GOABSREG
MOVE.GORELREG
MOVE.GOUPDATE
MOVE.GOHOME

Interrupts are active and will be serviced during the execution of a When statement. The execution of an interrupt service routine will not affect how quickly the when-action is executed after the when-condition is satisfied.

The When condition is checked every 250 microseconds. At the instant (within 250 microseconds) that the when-condition is satisfied, the values of the following variables are strobed into special When variables:

Variable When variable
DRV.HANDWHEEL WHEN.DRVHANDWHEEL
DRV.TIME WHEN.DRVTIME
FB1.MECHPOS WHEN.FB1MECHPOS
PL.CMD WHEN.PLCMD
PL.FB WHEN.PLFB
EXTENCODER.POSITION WHEN.EXTENCODERPOSITION

Example

MOVE.GOVEL
When DIN3.STATE = 1, MOVE.ABORT
Print "Motor position when Input 3 went hi, WHEN.PLFB=", WHEN.PLFB
Print "Current Position, PLFB =", PLFB

General Information

Type

Statement

Units

N/A

Range

N/A

Default Value

N/A

Data Type

N/A

Variants Supported

This statement is only supported on AKD BASIC drives.

Related Topics

WHEN.DRVHANDWHEEL | WHEN.FB1MECHPOS | WHEN.DRVTIME

WHEN.PLCMD | WHEN.PLFB