Acquiring Time-Sampled Position and Velocity Data

NI-Motion

Acquiring Time-Sampled Position and Velocity Data

NI motion controllers can acquire a buffer of position and velocity data that is firmware-timed. After you command the motion controller to acquire position and velocity data, a separate acquire data task is created in the real-time operating system that reads time-sampled position and velocity data into a FIFO buffer on the motion controller. You can read data in from this buffer asynchronously from the host computer, as shown in the following figure.

The acquire data task has higher priority than any onboard programs or housekeeping tasks, but it has a lower priority than the I/O reaction and host communication tasks. To achieve the best possible performance, keep host communications to a minimum when acquiring data.

The FIFO buffer is of a fixed size that can accommodate 4,096 samples for one axis. One sample consists of position data, in counts or steps, and velocity data, in counts/s or steps/s. As you increase the number of axes from which you are acquiring data, you also decrease the total number of samples you can acquire per axis. For example, you can acquire up to 1,024 samples per axis for four axes. You also can vary the time period between acquired samples from 3 ms to 65,535 ms.

Acquire Data Algorithm

The following figure shows a generic algorithm applicable to both C/C++ and LabVIEW code.

The data must be read one sample at a time. A four-axis sample uses the following pattern for returning the data.

Axis 1 position
Axis 1 velocity
Axis 2 position
Axis 2 velocity
Axis 3 position
Axis 3 velocity
Axis 4 position
Axis 4 velocity

If you request 1,024 samples, you must read each of the 1,024 samples individually.