From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

correlated analog and encoder readings with M-series

Hardware: PCI-6220
Driver: NI-DAQmx
Software: VC++ 6.0

My goal is to collect synchronized (correlated) analog and encoder readings to provide position-based voltage and current information.

First question is regarding the potential alternatives and which is the best approach between these options:
1) A single task that reads required analog and counter information into the same buffer, seems easy to align the data using this approach.
2) A task to read analog data and a second task to read counter information, complicated by the need to reliably align the informatio from seperate buffers.

Next question is simple: can the PCI-6220 read 2 seperate encoders?

Hopefully, last question: where can I find documentation about where to connect A, B, and Z? So far all my searches have resulted in E series or 6602 counter examples and nothing on M series.

Thanks, Ed
0 Kudos
Message 1 of 10
(3,547 Views)
Hi Ed,

To answer your questions:

>>First question is regarding the potential alternatives and which is the best approach between these options:
>>1) A single task that reads required analog and counter information into the same buffer, seems easy to >>align the data using this approach.
>>2) A task to read analog data and a second task to read counter information, complicated by the need to >>reliably align the informatio from seperate buffers

First of all, option one is not actually an option because you cannot have one task acquire two different types of data (eg analog and counter data). Therefore, option two is the way to go. It is not as hard as it seems. You can use Channel Z to trigger the analag input channels and once the analog and counter channels are triggered at the same time their data will automatically be aligned.

>>Next question is simple: can the PCI-6220 read 2 seperate encoders?

The PCI 6220 has two 32 bit counter channels, so it is possible to read two separate encouders. Here is a link to the product data sheet for this card: http://sine.ni.com/apps/we/nioc.vp?cid=14130〈=US

>>Hopefully, last question: where can I find documentation about where to connect A, B, and Z? So far all my searches have resulted in E series or 6602 counter examples and nothing on M series.

You are right, it is difficult to find out where to connect channels A, B, and Z! The easiest to find this information is to create an NI-DAQmx counter Task in MAX (Measurement and Automation Explorer). Once you have followed all of the steps to create the task you will see the task information in the middle of the screen. There will be a settings tab and inside this tab it will tell you what pins to connect A, B and Z to. I went ahead and created tasks for ctr 0 and 1 in MAX to get the information on which pins to connect to A, B, and Z.

For ctr0: For ctr1:
A: PFI8 PFI3
B: PFI10 PFI11
Z: PFI9 PFI4

Please let me know if you have any further questions. Have a great day!

Jennifer
0 Kudos
Message 2 of 10
(3,532 Views)
Thanks JenK especially for the pin connections. I don't believe I can create the task in MAX because we don't have LabView or LabWindows - correct me if I'm wrong. My rep told me that option was not available without their software.

About the 2 options, it seems there is some disagreement based on an e-mail I received today from my NI rep who is trying to help with this:

You are looking to do correlated analog / counter, so you are looking to do
buffered counter input with the AI sample clock locking in your counter
measurements. Below is a link to a correlated analog / digital example:
http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=E4C68BB4D82A126DE034080020E74861&p_node=%20DZ52321&p_submitted=N&p_rank=&p_answer=&p_source=External

How do you interpret this?

Ed
0 Kudos
Message 3 of 10
(3,519 Views)
Ed,

You do not have to have LabVIEW or LabWindows in order to have Measurement and Automation Explorer (MAX). As long as you have the DAQ driver (NI-DAQmx 7.3) you can use MAX. The driver automatically installs MAX.

I looked at the LabVIEW example that was attached to that link and it is doing the same thing that I suggested. It has two different tasks for the analog input channel and the digital input line (as I mentioned before you cannot have these two in the same task). This example program illustrates how to perform a finite, buffered, digital input task correlated to a concurrent analog input task.

It seems to me that we are both saying the same thing, but it may not have been communicated very clearly. The main thing is that you cannot have one single task that acquires both analog and counter data.

I hope this makes more sense.

JenK
0 Kudos
Message 4 of 10
(3,512 Views)
I probably didn't explain well enough, I cannot use the DAQ Assistance in MAX to create tasks because we don't have LabView or LabWindows. All of our software is using NI-DAQmx directly through C++, I know it is the hard way to go but so far the company hasn't footed the bill.

Since you seem to understand this very well, what we currently have is a system where the analog signals are being read at the desired frequency. What I want is to read the counters on the same sample clock as the analog signals and I'm not clear on how to accomplish that.

Ed
0 Kudos
Message 5 of 10
(3,510 Views)
Ed,

Here is an example in C that should help get you started. You won't be able to apply it directly to your application, but it will at least start you in the right direction.

Hope this helps.

JenK
0 Kudos
Message 6 of 10
(3,503 Views)
In order to take measurements on the buffered position measurement counter at the same time as the analog input task, you can simply select the "Sample Clock Source" from JenK's example to be "/DevX/ai/SampleClock". DAQmx will internally use the AI sample clock as the sample clock for your counter measurement.

I hope this helps!
gus....
0 Kudos
Message 7 of 10
(3,493 Views)
This is a huge help, especially the comment about using the ai sample clock for the other readings - I wasn't sure how to accomplish that. This looks like it will work out as required.

Thanks again, Ed
0 Kudos
Message 8 of 10
(3,489 Views)
As I was getting started with this today I realized that JenK's pin connections are not available on the PCI-6220:

For ctr0: For ctr1:
A: PFI8 PFI3
B: PFI10 PFI11
Z: PFI9 PFI4

This board does not have any PFI listed above 9, suggestions please?

Ed
0 Kudos
Message 9 of 10
(3,473 Views)
Sorry, I was looking at the E series pinouts. The M series has it as you said.

Ed
0 Kudos
Message 10 of 10
(3,469 Views)