Example Code

Encoder Velocity Measurements and the NI 9361

Code and Documents

Attachment

Description

This example demonstrates how to continuously acquire velocity measurements using the NI 9361.

Steps to Implement or Execute Code


  1. Change the Counter Physical Channels and Input Terminal as necessary.

Refer to the NI DAQmx Help for the valid channel names for the Counter module.

Block Diagram Steps:

  1. Create a Frequency Task to measure the speed of the encoder.
  2. Create an Angular Encoder Task to measure the position and direction of the encoder.
  3. Configure the Timing and Triggering for the Task.
  4. Start the Task.
  5. Read the Frequency and Position of the Encoder. Use the direction of the encoder in order to change the Frequency into a velocity measurement.
  6. Stop the task, clear the task, and Display errors (if any).

I/O Connections Overview:

For instruction on how to connect your signals to the NI 9361, refer to your device documentation.

Note:

This example is not valid for two pulse encoders, X2, or X4 encoding.

Requirements


Software

DAQmx 14.5

Hardware

NI 9361

Rob W.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
JSwing
Member
Member
on

When I try to run this example with an NI-9361 in a cDAQ-9171, I get error -200022 "Resource requested by this task has already been reserved by a different task". What timing source do I have to use? The default is "Onboard Clock".

Philosophe
NI Employee (retired)
on

Hello JSwing,

This problem that your are running into is actually a known issue and is being look at by R&D @ NI. The only other information that I can offer you is that a fix is being worked on in a later version of DAQmx. Sorry for the potentially bad news.

Rob W.
Kalin_T
NI Employee (retired)
on

DAQmx 15.1 and later resolved the issue.

Kalin T.
Contributors