Check Buffer

NI-Motion VI

Check Buffer

Returns information about the current state of the buffer.

Details

Device Compatibility

DeviceCompatibility
7330
N
7340
Y
7344
Y
7350
Y
7390
N
NI SoftMotion Controller for CANopen—Accelnet
Y
NI SoftMotion Controller for CANopen—Xenus
Y
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.
Buffer is the buffer to configure. Valid buffer numbers are 1 through 255 (0x01 through 0xFF).
Ret Vect indicates the destination for the return data generated by this VI. Available return vectors include return data to the host (0xFF), return data to a variable (0x01 through 0x78), return data to an indirect variable (0x81 through 0xF8), and do not return data (0). Refer to Input and Return Vectors for more detailed information.
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:
status is TRUE if an error occurred before this VI was called, or FALSE if not. If status is TRUE, code is a nonzero error code. If status is FALSE, code is zero or a warning code.
code is a number identifying an error or warning. If status is TRUE, code is a nonzero error code. If status is FALSE, code is zero or a warning code. Use the error handler VIs to look up the meaning of this code and display the corresponding error message.
source is a string that indicates the origin of the error, if any. Typically, source is the name of the VI in which the error occurred.
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.
Buffer Out is provided for flow control. You can string together NI-Motion VIs by wiring the Buffer Out terminal of one VI to the Buffer terminal of the next VI.
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.
status is TRUE if an error occurred, or FALSE if not. If status is TRUE, code is a nonzero error code. If status is FALSE, code is zero or a warning code.
code is a number identifying an error or warning. If status is TRUE, code is a nonzero error code. If status is FALSE, code is zero or a warning code. Use the error handler VIs to look up the meaning of this code and display the corresponding error message.
source is a string that indicates the origin of the error, if any. Typically, source is the name of the VI in which the error occurred.
Buffer State returns the current state of the buffer:
Buffer Not Exist     0     The buffer does not exist. This also returns error -70137.
Ready The buffer is configured but is not being used by any resource.
Active The buffer is configured and is being used by a resource.
Done The buffered operation is complete.
Old Data Stop The operation stopped on unread data that would be overwritten.
Backlog is the number of 32-bit data points that can be safely read from or written to the buffer without violating the Old Data Stop condition. This value is useful when Old Data Stop is set to true in the Configure Buffer VI.
Points Done gives the total number of points read from the buffer by the controller or written to the buffer by the controller since the operation started.

In the output case (contouring, for example), even after the buffer has been filled by the user but the move has not yet been started, Points Done is still 0, because the controller has not yet read any data from the buffer. After the move has started and some points have been read from the buffer by the NI motion controller, Points Done is non-zero. In the input case, for example, after the controller has filled the buffer once, Points Done is the size of the buffer, even if the user has not yet read any data out of the buffer.

Using This VI

The Check Buffer VI provides you with current information about the state of the buffer. In single iteration situations, meaning Total Points is less than or equal to Buffer Size in the Configure Buffer VI, the Buffer State parameter is most useful in determining that the operation has completed.

For a finer-resolution view of the state of the buffer, the Backlog parameter indicates the number of points that can safely be written to or read from the buffer without violating the Old Data Stop condition. Refer to Configure Buffer for more information.

Points Done is the number of points read from the buffer by the controller, in the case of an output buffer, or written to the buffer by the controller, in the case of an input buffer. Points Done is from the point of view of the controller, rather than the user.

As an example, in the case of contouring, Backlog helps you determine when you can write more data to the buffer, while Points Done tells you how many points have actually been splined together by the controller. Points Done reflects what is happening in the real world, where motion occurs.

Note  This VI returns data in the following order: Backlog, Buffer State, and Points Done.

Output Buffer Example

After you configure a 10-point buffer for contouring, the contents are indeterminate and both the read and write heads are at position 0.

Write: 0
Read: 0

In writing the values 1 through 5 to a buffer, the write head moves to the sixth position in the buffer, where the next write takes place. The read head is still at position 0 because it has read no data from the buffer. Likewise, Points Done is still 0.

                   Write: 5
1   2   3   4   5     

Read: 0

The contouring operation is started by calling the Start Motion VI, and the controller starts reading data from the buffer. After reading three points, the read head is at the fourth buffer element, with a value of 3. Points Done is equal to 3.

                    Write: 5
1   2   3   4   5     

          Read: 3

When you call the Check Buffer VI, Backlog is 8, meaning that eight points can be safely written to the buffer without overwriting data still remaining to be read by the controller. The Points Done parameter is still equal to 3. At this point, another Write Buffer call of eight points with values between 6 and 13 results in a write head with a value of 13 at the fourth buffer element. At the same time, the contouring operation instructs the controller to read another point from the buffer, causing the read head to advance by one.

             Write: 13

11   12   13   4   5   6   7   8   9   10

                     Read: 4