4 until iteration, 5 wait iteration, Until iteration -16 – ElmoMC SimplIQ Software Manual User Manual

Page 45: Wait iteration -16

Advertising
background image

SimplIQ

Software Manual

4BThe

SimplIQ

User Programming Language

MAN-SIMSW (Ver. 1.4)

5-16

5.7.4

Until Iteration

Syntax:
until (expression) ;

The until keyword suspends execution of the program until expression becomes true
(nonzero). The expression can be logical and/or numerical.

Example:

until ((PX>=20,000)&IB[1]);

Suspend the program until the variable PX exceeds

20,000 and digital input 1 is ON.

The until expression can be useful for synchronizing threads for drives that support multi-
thread programs. For example, if there are two threads and the second thread must start
after the first thread finishes a certain procedure, a global variable should be defined to
indicate whether the first thread has finished or not. The second thread is suspended by the
until expression, as follows:

int IsFirstFinished ;

Global variable definition. Variable is initially set to zero.

The code of the first thread could be:

… Do some work…
IsFirstFinished = 1 ;

Signal that some work is complete.

The code of the second thread will include:

Prior to suspension code

Until (IsFirstFinished) ;

Second thread suspended until ** signal

… Continue

program.

To suspend the thread without terminating it, until can be used with a false expression.

5.7.5

Wait Iteration

Syntax:
wait (expression) ;

The wait keyword suspends execution of the program until the specified time elapses. The
expression can be within parentheses or without them. The expression specifies the waiting
time in milliseconds. It can be a numerical expression only, and is evaluated in a single
value.

Example:
PA=10,000

BG

until (MS == 0)

wait (20) ;

Wait

20

milliseconds

Advertising