Configure Buffer

NI-Motion VI

Configure Buffer

Configures a buffer for use in buffered operations.

Details     Remarks

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
Old Data Stop (True) indicates to the motion controller whether or not to stop reading from or writing to the buffer when older, unread data is encountered. This is only relevant when Total Points is greater than Buffer Size. In the output case, such as contouring, when Old Data Stop is true and Total Points is greater than Buffer Size, you must write new data to the buffer before the motion controller finishes the buffer and starts over at the beginning. Likewise, for an input buffer, if the controller (or an onboard program running on the controller) is writing data to the buffer, such as buffered high-speed capture data, you must read data out of the buffer before the controller wraps around and writes new data on top of the old data.

If you set Old Data Stop to false, the motion controller does not enforce the old data stop condition, and simply writes data to or reads data from the buffer as needed.

Requested Interval (10 ms) is additional data for the Position buffer type. The Position buffer type requires a Requested Interval parameter, and indicates the time between contouring data points in milliseconds. For all other buffer types, the Requested Interval parameter is ignored.

The controller uses the closest value it can that is greater than or equal to the interval value you requested. Your time interval must be an even multiple of the PID rate. Refer to the description for the Actual Interval parameter for more information.

When used with Breakpoint or High-Speed Capture, Requested Interval indicates how often, in milliseconds, the onboard data is updated from the hardware, and the value is a whole number.

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 is the Axis, Vector Space, ADC, or Encoder you wired into the VI. Use Resource Output to pass the resource to another VI and/or to display information about the device.
Buffer is the buffer to configure. Valid buffer numbers are 1 through 255 (0x01 through 0xFF).
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.
Buffer Type (Position) specifies the type of data in the buffer.

General-Purpose Input and General-Purpose Output

The general-purpose input and output buffer types allow you to allocate a buffer of memory on the motion controller for your own use. You can freely read from and write to the buffer from the host computer or from onboard programs.

The direction of a buffer is from the point of view of the host computer. An output buffer is typically written to by a program on the host computer and read from by an onboard program running on the motion controller. An input buffer is typically read from by a program on the host computer and written to by an onboard program running on the motion controller.

For General-Purpose Input and General-Purpose Output buffer types, the Resource and Requested Interval parameters are ignored.

Refer to the Example Uses section of this VI description for more information.

Position

The position buffer type allows you to specify a sequence of one, two, or three-dimensional position data points to the motion controller. To specify two or three-dimensional position data, the Resource parameter must be a vector space. The data is interpreted as absolute or relative contouring data depending on the value of the operation mode set through the Set Operation Mode VI.

After you configure an axis or vector space for absolute or relative contouring in the Set Operation Mode VI, and write the contouring data to the buffer with the Write Buffer VI, start the contouring operation by calling the Start Motion VI. The NI-Motion controller processes the contouring data by splining between successive points. The Requested Interval parameter indicates the time between points in milliseconds. You are responsible for providing the points in a way that results in the appropriate acceleration, velocity and deceleration.

Note  If you are running a contoured move with a stepper axis, it is possible that the contour velocity exceeds the maximum step rate of the controller. In this case, the controller kills the axis and sets the following error status to true. Refer to the Specifications section of your controller user manual for the maximum step rate of your controller.

It is important to realize that all contoured moves are relative, meaning motion starts from the position of the axis or axes at the time the contouring move is started. Absolute contouring and relative contouring refer to the way the contouring data is interpreted. Absolute contouring data indicates the absolute position at each time interval, where the starting position is considered to be 0. Relative contouring data indicates incremental position differences between contouring points.

For an example of relative versus absolute contouring, refer to the Example Uses section of this VI description.

Breakpoint

This buffer type allows you to specify a sequence of one-dimensional breakpoint position data points to send to the NI motion controller. The data is interpreted as absolute or relative depending on the value of the Mode (Absolute) you set in the Configure Breakpoint VI.

After you configure an axis to include breakpoints and write the breakpoint data to the buffer with the Write Buffer VI, you add the breakpoint by calling Configure Breakpoint.

High-Speed Capture

This buffer type allows you to specify a sequence of one-dimensional high-speed capture data points to send to the NI motion controller. This buffer is treated similarly to a general purpose output buffer, and you can freely read from the buffer from the host computer or from onboard programs. After you configure a buffer to contain high-speed capture data points and configure an axis to read the high-speed capture points from the buffer with the Configure High-Speed Capture VI, you read the high-speed capture data by calling Read Buffer.

Camming Position

This buffer type allows you to specify a list of slave axis positions that will be used to calculate the camming profile. After you configure and write the slave axis position data, you can enable camming for a single axis or for multiple axes.

Buffer Size is the size of the buffer in 32-bit data. If you configure a buffer for a three-axis vector space with 1000 3-dimensional points, the size of the buffer would be 3000.

Refer to the NI 73xx Controller Considerations section of this VI description for more information.

Total Points specifies the number of points that must be consumed before the operation is complete. In most cases a value of Buffer Size is appropriate. Valid values for Total Points range from 1 to 232–1, inclusive. If Total Points is greater than Buffer Size, the read and write operations automatically wrap around to the beginning of the buffer.
Note  If you set Total Points to 232–1, the buffer will run until the move is stopped, or the last counter data is written. Refer to Write Buffer for information about writing data to a buffer.
Actual Interval (ms) is the interval of time, in milliseconds, that the controller uses between successive points in the buffer. Actual Interval may or may not be the same as the Requested Interval. For example, if the Requested Interval is physically impossible, then a different value is used. This value is represented as Actual Interval.

For Breakpoint or High-Speed Capture,

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.
Resource Output is the Axis, Vector Space, ADC, or Encoder you wired into the VI. Use Resource Output to pass the resource to another VI and/or to display information about the device.
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.

Using This VI

After a buffer is configured, you can write to the buffer with the Write Buffer VI and read from the buffer with the Read Buffer VI.

A contour operation that uses a buffer is initiated when the Start Motion VI is called. You check the state of the buffer with the Check Buffer VI to determine how many points have been read from or written to the buffer by the motion controller.

After a buffered operation is complete, it is important to clear the buffer by calling the Clear Buffer VI. Otherwise, the memory allocated for the buffer in the onboard RAM is not available for other uses, such as the allocation of another buffer. Buffers must only be cleared when no motors are moving and no programs are running.

A buffer cannot be reconfigured or cleared while the buffer is in use. The VI generates a Buffer In Use error in such a case.

A buffer can only be used by one resource at a time. Multiple resources can be associated with a single buffer, but only one resource can use that buffer at any given time. Likewise, a single resource can make use of many buffers, but for buffers of the same type, only one of them can be associated with that resource at a given time. Refer to the NI 73xx Controller Considerations section of this VI description for more information.

Note  Configuring and clearing buffers is a processor-intensive operation on the NI motion controller that requires the allocation and de-allocation of memory. Configure and clear buffers only when motors are not moving and onboard programs are not running.

Example Uses

General-Purpose Input and General-Purpose Output Examples

Configure a 300-point output buffer and fill it with position, velocity, and acceleration values for a sequence of 100 moves. Then write an onboard program that reads values from the buffer and places them in onboard variables and execute Load Target Position, Load Velocity and Load Acceleration/Deceleration using the onboard variables as the source of their data. Finally, start the move with the Start Motion VI. This sequence can be repeated until all 100 moves execute.

As another example, you can configure an input buffer to hold analog input values. If you want to record the value of an analog input every time a particular digital input changes state, write an onboard program to wait for the digital input to change state, at which time read the analog input and write the value to the buffer with the Write Buffer VI. This can be done in a loop in the onboard program. When the operation is complete, or even while the buffer is being filled with analog input values, a program running on the host computer can read the values from the buffer with the Read Buffer VI.

Absolute and Relative Contouring

The following two examples of contouring data result in the same move taking place.

Absolute Contouring

1      3      6      10      14      18      22      25      27      28

Relative Contouring

1       2      3       4        4        4        4        3        2        1

If the axis was at position 0 to start with, it would end up at position 28 in both cases. If the axis was at position 10 to start with, it would end up at position 38 in both cases.

Choose the appropriate mode depending upon the kind of data you have or wish to provide. One benefit of the relative contouring mode is that you can specify multiple identical moves in the same direction with the same data.

For example, the following two-dimensional contour move would be possible with five iterations of a relative contouring buffer, but would not be possible with absolute contouring data unless you provided five times as much data.

Remarks

This section includes information about how the behavior of this VI differs among the controllers that support it.

NI 73xx Controller Considerations

The following list includes considerations you must make when you are using this VI with a 73xx motion controller:

  • Using input vectors and return vectors with the Read Buffer and Write Buffer VIs, you can write to and read from the buffer with data stored in onboard variables. You must limit the number of points to read or write because there are only 120 onboard variables. Data is read from or written to onboard variables sequentially starting at the variable specified by Inp Vect or Ret Vect in the Write Buffer VI or Read Buffer VI, respectively.

    Specify a Buffer Size of 0 to associate a resource (like an axis or vector space) to an existing buffer, without affecting the size of the buffer or the data contained in the buffer. The following examples illustrate the use of this technique:
    • A single resource, for example, an axis or vector space, can use buffer 1 for a contouring operation, and then switch to buffer 2 for a subsequent operation. You can set up the two buffers ahead of time, and when the first operation is complete, you can make an additional call to Configure Buffer with a Buffer Size of 0, the same value for Resource, and the new buffer number for Buffer.
    • If you wish to reuse a buffer with another resource, simply call the Configure Buffer VI with the same buffer number, a Buffer Size of 0, and a new value for Resource. Both resources can still use the single buffer, but not at the same time.

      A Buffer Size of 0 allows you to associate a resource with an existing buffer, without changing the contents of the existing buffer. Also, a Buffer Size of 0 can be used to leave the current buffer alone, but change the value of another parameter. When you reconfigure the buffer with a Buffer Size of 0, the read mark is set to 0. If the buffer is an output buffer, the write mark is set to Buffer Size. If the buffer is an input buffer, the write mark is set to 0.
    • After a contouring operation, the same buffer of points can be contoured again, with a different time interval between points, or number of iterations. Just pass in a 0 for buffer size and change the other parameters as appropriate.
  • When reconfiguring an existing output buffer by passing a Buffer Size of 0, the buffer is assumed to be full of data. If you want to change the contents of the buffer, do so before reconfiguring it.
  • When a buffer is saved to ROM using the Object Memory Management VI, and the association between the buffer and the resource—for example, axis or vector space—is lost (most likely through a power cycle or a call to Clear Buffer), the association between the resource and the buffer needs to be re-established before a buffered operation can be performed with the buffer. Because the buffer already exists in ROM, specifying a Buffer Size of 0 causes the NI motion controller to associate the specified resource with the specified buffer without allocating any new memory for the buffer. If the buffer does not exist, an object reference error is generated.
  • The maximum buffer size is 16,364 data points on a 7340 or 7350 controller. Besides the data stored in each buffer, some space is used internally for bookkeeping and state information. Refer to Buffered Operations VIs for information about the total amount RAM and ROM on each controller.
  • When a buffer is configured, memory for the buffer is allocated in the onboard RAM of the controller. The buffer persists until the buffer is cleared with the Clear Buffer function, or the controller is reset, usually through a power cycle. You can save the buffer to ROM with the Object Memory Management VI for later use, even after the power has been cycled. When using a buffer stored in ROM, you cannot write to the buffer.
  • The High-Speed Capture attribute is not supported for 7340 controllers.
  • The Camming Position attribute is not supported for 73xx controllers.
  • For the Position Data attribute, use the following equation to calculate the actual interval, rounded to the next microsecond:



    where r is the Requested Interval in milliseconds (ms)
    a is the actual interval in milliseconds (ms)
    p is the PID rate in microseconds (µs)

    For example, given a PID rate of 250 µs, a time interval of 11.2 ms between points is physically impossible, but a Requested Interval of 11.25 ms can be accomplished. So a call to Configure Buffer with interval set to 11.2 configures the buffer for 11.25 ms, because that is the shortest possible interval that is greater than or equal to the requested interval. The actual value being used, 11.25 in this case, is returned as an output parameter. The following table shows the minimum and maximum intervals for all valid PID rates.
    PID rate Minimum Interval Maximum Interval
    62.5 µs 10.0 ms 11.3125 ms
    125 µs 10.0 ms 22.625 ms
    187.5 µs 10.125 ms 33.9375 ms
    250 µs 10.0 ms 45.25 ms
    312.5 µs 10.0 ms 56.5625 ms
    375 µs 10.125 ms 67.875 ms
    437.5 µs 10.0625 ms 79.1875 ms
    500 µs 10.0 ms 90.5 ms
  • You can change the PID rate in MAX or with the Enable Axes VI.

NI SoftMotion Controller Considerations

The following list includes considerations you must make when you are using this VI with the NI SoftMotion Controller:

  • The NI SoftMotion Controller for Copley Controls' CANopen devices supports minimum (fastest) contour intervals as follows:
    • 10 ms for a motion control system that uses 1 to 8 axes
    • 20 ms for a motion control system that uses 9 to 15 axes
  • If you set Old Data Stop to false and Total Points is greater than Buffer Size, you must set Total Points to a multiple of Buffer Size. Otherwise, an error is returned.

    For example, to repeat a contour of 2,000 points 100 times, set Old Data Stop to false, Total Points to 200,000, and Buffer Size to 2,000.
  • The NI SoftMotion Controller supports only the Position and Camming Position attributes.
  • The size of the buffer is limited by the system resources.