03-02-2009 01:31 AM
So in our system we have a PMT that will be recording the number of pulses from scattered laser light . More specifically what we want to do is have our card (which, by the way, is a PCI-6621 M-series card) poll the PMT (this is our signal source) every 5 ms and thus know how many pulses we get each 5ms. We want to do this at least 100,000 times and do it continuously (i.e. no dead time between each 5ms timestep); i.e. measure how many pulses we get in 5ms timesteps for at least 8 minutes.
When purchasing the card, we wanted to ensure it could handle this, and so one of the NI engineers checked that the rate at which we capturing data would overload the system. In doing so, he passed this onto me:
“The application can be accomplished using a buffered event counting task. If you need to count the edges every 5ms, then we can use a 200Hz sample clock. With buffered event counting, the source of the signal you want to count is connected to the counter input, and then the other counter on the device (assuming you are using a device with 2 counters) can be used to generate the source clock at 200Hz. The article Buffered Event Counting (http://zone.ni.com/devzone/cda/tut/p/id/5404) explains this pictorially.
By default the counter task uses unsigned 32 bit numbers to represent the counts. At the rate that you need it is 32bit/sample*200 Samples/S (one every 5ms) = 6400bits/s, which is well below both the HDD and PCI band width that you are worried about.”
Hence I am looking to setting up a buffered event counting vi using the one shown in the link as an example, and thus, at the moment, I am after some help to ensure the assumptions I am making in my vi are correct and also any suggestions as to what else I can do. I am not after someone to finish it off for me, as I do need to understand how it all works.
For the create virtual channels.vi, I need to select how I am going to count the edges, but I am not sure if there are advantages/disadvantages to counting either the rising or falling edge. Otherwise I think I have an understanding here of what I need
On the sample clock.vi I have selected the sample clock source as being the di/sampleclock and then setting the rate to 200; ie I am assuming this represents the 200Hz I need for the 5ms sampling rate. Is this correct? For samples per channel I have used a control, but would normally put 100000 here.
On the DAQmx read.vi I am uncertain as to how I should approach the timeout function; ie should I just set it to -1, or just leave it unwired. Also should this be set to 1 sample or N sample? I ask this because the next vi (the write.vi) does not, as far as I can tell, allow for N samples
So onto the write.vi, here I am not entirely what I need to do especially given that in the read.vi it is possible to select for N samples, but with this vi you only have a choice between how many channels you ar eusing (which in my case is one). Also, I think I need to use ticks and not freq or time, but if I do I still don’t understand how to use it given that there are high and low ticks here.
Furthermore, I want to be able to write these data points to a data file (of some sort). Originally I was thinking of using binary because I thought I would need to stream the data. But I think given that the data will be in a buffer and then read to the computer that I can write to a txt file. For this do I then connect the data function to write to a text file (or something along those lines).
With the data I also want to convert it from a 1D data set with just the number of pulse counts to a 2D dataset that contains the corresponding times to the acquired data; ie 5ms, 10ms, 15 ms etc. Would it be better to include that here or to do it afterwards, or would it not really matter? Of course how I will do those I still need to think about.
My apologies on the long post and numerous question, but any help will be truly appreciated.
Scott
03-02-2009 01:33 AM
03-03-2009 12:00 PM
Hi scottum,
To begin, I am assuming you meant your device is the PCI 6221, not 6621 as you stated.
There is no advantage to selecting either the rising edge or falling edge for the counter. It's just a matter of which edge you would like to reference.
You are correct in your assumption that setting the rate to 200 means a sample interval of 5 ms.
The timeout setting is up to you. If you would like the read to wait for available samples indefinitely, set it to -1. The default, and what I would recommend for getting started, would be 10 seconds (eg if you dont wire anything to this input it will remain at 10).
The difference between setting the the DAQmx to read N samples or setting it to -1, is whether you would like it to read continuously or for a set amount of samples (that you know and define).
From my understanding of your application, I do not believe you need the DAQmx write vi.
In order to write to a file, I recommend using the write to measurement file express vi. Simply wire the data output of the read to a "convert to dynamic data" vi, and from there, to the signals input of the write to measurement file express vi. Within this express vi you can specify to append newly read data to the existing file (depending on whether you want to read continuously or read a finite number, as reading a finite number will wait for all data before passing data to the output, and thus negating the need to append).
With regard to appending time data to the 1D array that results from the read, I would do it before writing to the file (eg append to the array that you then convert to dynamic data that you then connect to the signals input of the express vi).
Regards,
David
Applications Engineer
National Instruments
03-06-2009 01:29 AM
Thanks For that David, it is proved quite helpful, but I still have some additional questions.
Firstly I should note that you were right, the device is a PCI-6221. I should also note that I am currently working on this vi on a machine not connected to the device (I am currently using a simulated 6221 device until I can access the instrument computer).
I have modified the vi and have wired it up. However I am still unsure if I have a few things correct.
Firstly, the source for the sample clock is /Dev1/di/SampleClock, is the correct setting since I do not know if it connects to the second counter which from my email from the applications engineer (as quoted in my first post) indicated that the send counter is used to generate the source clock.
I have added a For loop in there to generate the time data and then appended that to array which then goes to the write to measurement vi. The reason I have used a for loop is so that its iteration number is that same as specified in the sample per channel control, which here I have connected to the for loop. To get the times (ie the sample interval), and given that this is dependant on the rate, I am dividing 1 (ie 1 sec) by the rate so that after each iteration the array is appended such that each new entry to the array is increased by 5ms (if, for example, the rate is 200).
As far as I can tell I have I can see I have wired the Write to measurement file correctly. So given that I couldn't see anything wrong with my vi visually I ran it. Unfortunately I got an error (which may in part result from the fact that I am not actually connected to an actual device at the moment). It was gave an error number of -89136 and the source of the error was given as:
DAQmx Start Task.vi:1<append>
<B>Property: </B>SampClk.Src
<B>Property: </B>SampClk.ActiveEdge
<B>Source Device: </B>Dev1
<B>Source Terminal: </B>di/SampleClock
<B>Task Name: </B>_unnamedTask<0>
I have also attached the lvm (saved as an excel spreadsheet) file that resulted from me running this vi (which clearly shows nothign much happened!). Also is there any way (within the vi as I have set it up) to give the y axis data (ie the data aquired from the counter) a title.
Also something I hadn't thought to consider until I read this thread was the role the DMA channels play here. Does my current setup access (and thus enable) the relevant DMA channels? Or do I need to specify that somewhere.
Thanks for any help.
03-09-2009 02:04 AM
"Firstly, the source for the sample clock is /Dev1/di/SampleClock, is the correct setting since I do not know if it connects to the second counter which from my email from the applications engineer (as quoted in my first post) indicated that the send counter is used to generate the source clock."
So since I posted this i have found out how to access a larger choice of terminals for this by right clicking on the DAQmx physical channel control and selecting the I/O name filtering. From reading the help menu I think I need to use the CtrnGate terminal as we need to use the sample clock functionality for buffered edge counting. Am I correct in my assumption here?
Thanks
03-09-2009 12:15 PM
Hi scottum,
First, the sample clock is the proper setting. According to the M series DAQ user manual, route the counter sample clock to the gate input of the counter for buffered edge counting.
The error you are seeing most likely due to the fact that there is no hardware available for the Sample Clock signal your vi is looking for.
Measurement file labeling information can be found in this thread.
With regard to DMA, there is a DMA controller for each counter / timer on the board. As such, your current setup enables DMA transfer.
Regards,
David
Applications Engineer
National Instruments
03-10-2009 01:24 AM
Hi David,
Just to clarify should I use the sample clock setting as per this: /Dev1/di/SampleClock or an advanced setting like this: /Dev1/Ctr1InternalOutput as alluded to in my (much) briefer last message?
Thanks again for your help.
Scott
03-10-2009 02:56 PM - edited 03-10-2009 02:57 PM
Hi scottum,
Go ahead and use the sample clock setting /Dev1/di/SampleClock.
Regards,
David
Applications Engineer
National Instruments
03-25-2009 10:55 PM
Its been a little while since I was last working on this, but I am back at it now and I still need some help/advice.
The card is now in the computer (PMT is not attached; by the way, the PMT will be connected to a BNC 2110 which will then connect to the card) and thus my source is now the actual card, not the simulated card I had been working on with my other computer.
So now when I run the program with the source for the sample clock as /Dev1/di/SampleClock, what I get is this (which is error code -89136):
DAQmx Start Task.vi:1<append>
<B>Property: </B>SampClk.Src
<B>Property: </B>SampClk.ActiveEdge
<B>Source Device: </B>Dev1
<B>Source Terminal: </B>di/SampleClock
<B>Task Name: </B>_unnamedTask<7>
Now if I change the source to something like what I get is this (which is error code -200141):
DAQmx Read (Counter 1D U32 1Chan NSamp).vi:1<append>
<B>Task Name: </B>_unnamedTask<4>
or when the cource is Dev1/Ctr1Gate, I get (which is error code -200284):
DAQmx Read (Counter 1D U32 1Chan NSamp).vi:1<append>
<B>Property: </B>RelativeTo
<B>Corresponding Value: </B>Current Read Position
<B>Property: </B>Offset
<B>Corresponding Value: </B>0
<B>Task Name: </B>_unnamedTask<5>
My problem is I do not know how to take this information and use it to fix my vi as I can't tell what I have done wrong from this description (I have again attached the vi).
My second concern refers to this statement in the M-series manual:
"The count values returned are the cumulative counts since the counter armed event. That is, the sample clock does not reset the counter. "
I don't want a cumulative count, I want the count after each time step. Or is how I have set up my vi allowing for the the number of count (ie pulses) to be counted for each timestep.
Thanks for any help.
Scott
03-25-2009 11:23 PM
The source for I did not include here:
Now if I change the source to something like what I get is this (which is error code -200141):
DAQmx Read (Counter 1D U32 1Chan NSamp).vi:1<append>
<B>Task Name: </B>_unnamedTask<4>
was /Dev1/Ctr1Source
sorry about that