Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

N channels N samples problem.

Hi,

 

First of all, I'm using an NI PCI-6229 DAQ card.

 

In the following VI, I'm trying to take 5 samples from each of four channels every time an encoder pulse comes in.  Eventually I will average them all, so it ends up being like an N Channels 1 Sample. (Which by the way works fine in the following VI.)

 

I have about 3775 pulses/second coming out of my encoder.  (566 pulses/rev * 400 rev/min)

 

When I run this VI, I expect that the loop will iterate once every time a pulse comes in, so I should have 147,160 reads in my case.  But when I do run it I only get about 30,000 reads.  This number is the approximately same whether I run at 60 rpm or 400 rpm (3775 pulses/sec or 566 pulses/sec)

 

Does anyone have any idea how I can configure this VI to do what I want.  Or is it even possible?

 

untitled.PNG

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 1 of 7
(3,766 Views)

Hi Tim,

 

What is the clock signal coming from on PFI8?  I'm assuming PFI3 is the encoder pulse that you want to trigger off of at ~3775 Hz. 

 

I think we need to revisit the architecture a bit--the 6229 does not support retriggerable analog input so I don't think this task is going to be working the way you think it is.  The way you have it now, the AI task will start off of the first rising edge of your encoder and will continuously sample based off of the sample clock being input on PFI 8.  If you are only getting 30,000 reads (measured by the loop count) then this would mean you are getting 150,000 rising edges on PFI 8 after the first encoder pulse occurs (since we are reading 5 samples per read).

 

Do you need to use an external sample clock?  If not, you could use a Retriggerable Finite Pulse Generation as the sample clock for a Continuous Analog Input task.  Try looking at this example:

Retriggerable Analog Input Using Digital Trigger

 

 

I can't guarantee that the loop will be able to keep up with the data coming in (the loop would have to run at 3775 Hz), but you can always read more than 5 samples per iteration.  I hope this helps!

 

 

Best Regards,

John

John Passiak
0 Kudos
Message 2 of 7
(3,757 Views)

John P wrote:

Hi Tim,

 

What is the clock signal coming from on PFI8?  I'm assuming PFI3 is the encoder pulse that you want to trigger off of at ~3775 Hz. 

 

I think we need to revisit the architecture a bit--the 6229 does not support retriggerable analog input so I don't think this task is going to be working the way you think it is.  The way you have it now, the AI task will start off of the first rising edge of your encoder and will continuously sample based off of the sample clock being input on PFI 8. 

 

If you are only getting 30,000 reads (measured by the loop count) then this would mean you are getting 150,000 rising edges on PFI 8 after the first encoder pulse occurs (since we are reading 5 samples per read).


The way our program works is this: Our encoder spins and spits out 566 pulses/revolution on PFI8.  PFI3 is the index pulse (1 pulse/revolution) that we use to trigger so we know our acquisition started at the same point in the rotation every time.  I don't want it retriggerable; I want it to trigger once off PFI3, and thereafter to read data every time a pulse comes off PFI8. 

 

We can get this to work fine when using NChan1Samp, but not NChanNSamp.  The read seems to take too long, even though our DAQ (I think) is rated at 1M, and we're only looking for 20K)

 

The second part of your response seems telling to me.  Our encoder puts out just over 147000 pulses in the time of my acquisition.  The way I picture NChanNsamp working is that I get 5 points for each pulse (totalling 735K points)  not 1 point per every 5 pulses (totalling ~30000) like you're saying.

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 3 of 7
(3,742 Views)

elset191 wrote:

Hi,

 

 

In the following VI, I.  Eventually I will average them all, so it ends up being like an N Channels 1 Sample. Smiley Wink

 

 

Does anyone have any idea how I can configure this VI to do what I want.  Or is it even possible?

 

 


DAQmxbug

 

Surprisingly, there is a bug reported by myself just a bit ago.  I would suggest that you try the NChan N samp WFM instance.  I haven't checked myself but it may not have the same resource issue as the DBL instance


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 7
(3,717 Views)

Hi Tim,

 

It sounds like the confusion is coming from the number of samples per channel input of DAQmx Read.  Setting this to 5 does not mean that we will read 5 samples per sample clock tick, but rather that DAQmx Read will bring in 5 samples per call into LabVIEW memory.  Looking again at your numbers, 147000 pulses would cause the loop to run 29,400 times.  It sounds like this is about what you are seeing.

 

The code I posted earlier should be more in line with what you need to do if you want to take multiple samples every time the encoder pulses, but this will require the use of both counters on the 6229.

 

 

Best Regards,


John

John Passiak
0 Kudos
Message 5 of 7
(3,712 Views)

John P wrote:

Hi Tim,

 

It sounds like the confusion is coming from the number of samples per channel input of DAQmx Read.  Setting this to 5 does not mean that we will read 5 samples per sample clock tick, but rather that DAQmx Read will bring in 5 samples per call into LabVIEW memory.  Looking again at your numbers, 147000 pulses would cause the loop to run 29,400 times.  It sounds like this is about what you are seeing.


 Oh.  Yeah, that's where the confusion is. 
 
My co-worker told me not to worry about doing this anymore, so It's not a real pressing concern, but I will take a look at the other code you posted.  Thanks.
 
I'm not real sure what is going on with your thread, John...
 

 

--
Tim Elsey
Certified LabVIEW Architect
0 Kudos
Message 6 of 7
(3,706 Views)

Yeah it doesn't seem like Jeff's bug is related to what you are doing here.

 

 

Jeff, thanks for pointing out the bug--it's currently being worked on by R&D.  You can check the readme of future DAQmx versions when they are released to look for the fix--although we don't necessarily include all bug fixes in the readmes.  If you keep the CAR ID handy you can always contact support if you want to check the status of the issue.

 

 

-John

John Passiak
0 Kudos
Message 7 of 7
(3,703 Views)