Wait on ConditionInserts a conditional wait in a program.
| Device Compatibility
|
Timeout (1) is the wait timeout value in 100 millisecond increments. The range is 0 to 65,534. If you specify a timeout of 65,535, it is treated as an infinite timeout, and will wait until the condition is met. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Must Off
is the bitmap of bits that must be False to satisfy the condition:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Must On
is the bitmap of bits that must be True to satisfy the condition:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Board ID is a unique number assigned by Measurement & Automation Explorer (MAX) used to send and receive commands and data to or from a specific NI motion controller. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Resource (0) is the axis control or other resource involved in the condition. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Retn Vect indicates the destination for the return data generated by this VI. Available return vectors include return data to the host (0xFF), to a variable (0x01 through 0x78), to an indirect variable (0x81 through 0xF8), and do not return data (0). Refer to Input and Return Vectors for more detailed information. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Wait Type (Wait)
is the selector for the type of wait to perform, as follows.
Wait Or allows you to combine multiple, unrelated wait conditions into one wait where the program is waiting for condition 1 OR condition 2 OR condition 3 and so on. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
error in (no error) describes error conditions that occur before this VI runs. The default input of this cluster is no error. If an error already occurred, this VI returns the value of error in in error out. The VI runs normally only if no incoming error exists. Otherwise, the VI passes the error in value to error out. The error in cluster contains the following parameters:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Condition Code (Move Complete)
is the qualifying condition to end the wait. Conditions 0 through 6 are not applicable to waits and generate an error.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Match Type (All)
selects the type of match required for the bitmap, as follows.
Match Any means that a match of any bit (logical OR) is sufficient to satisfy the condition while Match All requires a complete pattern match (logical AND) of all bits. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Bd ID Out is provided for flow control. You can string together NI-Motion VIs by wiring the Bd ID Out terminal of one VI to the Board ID terminal of the next VI. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Condition Resource Out is the Axis, Vector Space, ADC, or Encoder you wired into the VI. Use Condition Resource Out to pass the device to another VI and/or to display information about the device. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
error out contains error information. If error in indicates an error, error out contains the same error information. Otherwise, it describes the error status that this VI produces.
|
Using This VI
The Wait on Condition VI controls the flow of execution in a stored program. It suspends program execution and waits until the specified condition is met or the timeout expires. When the condition is met, program execution is resumed with the next VI after the Wait on Condition. Even though the program is suspended, the program status read using Read Program Status is still running.
If the timeout expires before the condition is met, an error is generated and the program goes into the paused state. Refer to the Pause/Resume Program VI for information about resuming a paused program.
If you set a timeout of zero, the condition must already be true or an error is generated.
You can wait on virtually any instantaneous status of axes, encoders, programs, motion I/O, or general-purpose I/O. Where applicable, you can select the specified resource with the resource parameter.
When waiting on a program with the Program Completed condition, Must On, Must Off, and Match Type parameters are not required and their values are ignored. You set resource equal to the program number to wait on. The balance of the conditions test status bitmaps and VI similar to each other as described in the remainder of this section.
The Must On, Must Off, and Match Type parameters work together to define a bitmap of True and False bits that must be matched to satisfy the condition. Depending on the type of event, the Must On and Must Off bitmaps are either one based or zero based. If the event is tied to an I/O port resource the bitmaps start at bit 0 to correspond with line 0 on an I/O port. If the event is tied to an axis-based resource, such as an encoder or an axis, the bitmaps start at bit 1 to correspond with axis 1. The Match Type parameter allows you to select between an OR match, where any matching bit is sufficient, and an AND match, where all status bits must match the True/False bitmap defined by Must On and Must Off.
Using the Must On/Must Off protocol gives you tri-state control over each match bit: True, False or Don't care. A True in a bit location of the Must On bitmap sets the match bit to True, while a True in the corresponding location of the Must Off bitmap resets the match bit to False. A False in either bitmap has no affect, so leaving both the Must On and Must Off bits at False defines the bit as do not care. If you set both the Must On and Must Off bits to True, it is interpreted as a Must On condition and the match bit is set to True.
The Limit Input Active and Software Limit Active conditions create a combined status bitmap where if either the forward or reverse limit is active, the bit is True.
When the Retn Vect is set to anything other than zero (0), the condition code and status bitmap that satisfied the condition are returned to the destination specified, either to a variable or the host computer, as two 16-bit words (u16). In the host computer case, they can then be read from the RDB with the Read Return Data Buffer VI.
Waits are one of the most powerful and useful features on the motion controller. While a program is suspended waiting for a condition, NI-Motion is not wasting CPU cycles on it. The preemptive multitasking real-time operating system (RTOS) on the motion controller suspends the task until the condition is met or the timeout expires. This feature allows up to 10 programs to run simultaneously with little impact on command execution performance.
To perform a conditional wait on two unrelated conditions, store the Wait on Condition VI twice—the first with Wait Type = Wait Or and the second with Wait Type = Wait.
Note Two sequential Wait on Condition VIs both with Wait Type = Wait effectively implement a Wait AND, because both wait conditions must evaluate successfully before program execution is resumed. |
Example
In program one, you want to wait until axes 1 through 3 have found home or until program two is complete. To accomplish this, store a Wait on Condition VI with the following parameters:
Wait Type = Wait Or
Condition Code = Home Found (7)
Must On corresponds to the following bitmap
Must On 0 | Must On 1 | Must On 2 | Must On 3 | Must On 4 | Must On 5 | Must On 6 | Must On 7 | Must On 8 |
False | True | True | True | False | False | False | False | False |
Note Because you are waiting on axes, the bitmap uses bits one through eight. |
Must Off corresponds to the following bitmap
Must Off 0 | Must Off 1 | Must Off 2 | Must Off 3 | Must Off 4 | Must Off 5 | Must Off 6 | Must Off 7 | Must Off 8 |
False | False | False | False | False | False | False | False | False |
Note Because you are waiting on axes, the bitmap uses bits one through eight. |
Match Type = Match All (0)
Timeout = 100 (timeout after 10 s)
Retn Vect = 0 (throw the status away)
Immediately follow this with a second Wait on Condition VI with the following parameters:
Resource = 2 (for program two)
Wait Type = Wait
Condition Code = Program Complete (20)
Timeout = 100 (timeout after 10 s)
Retn Vect = 0 (throw the status away)
In this example, the home found status of axis 4—8 is do not care.
Note If you are doing onboard programming and are using Retn Vect to write data, this VI writes the variables starting at the memory address pointed to by Retn Vect in the following order: Wait Type, Condition Code, Must On, Must Off, Match Type, Timeout. |