LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Time stamping questions

Hi,
I am trying to write a program to time stamp TTL pulses in two independent digital inputs. I am using Labwindows CVI version 7.1
 and the traditional NIDAQ that comes with the CVI version 7.1.

I am using a PCI 6533 in conjuncion with a PCI 6035. I used an RTSI cable to connect the two cards. I use change detection and use a mask to only read changes in port 0, lines 0 and 1
I routed the REQ1 output of the PCI 6533  to the gate of counter 0 of the PCI 6035.
Then I looked at the following example
TimeStampChangeDetection.c which is available from the NI.com website.
This program was a good statrting point and it seems to work with my hardware, but there are a few things that I do not understand on it.
The questions I have are:

1) Is the function GPCTR_Read_Buffer supported for the PCI 6035?. Can I use continuous (double buffered) input for counting events with the STC counters?

2)Is the alignment of the DMA buffer required in my case?. I use a pentium III, and the cards use onlu PCI bus, so can I safely remove the function calls related to the alignment of the DMA buffer?

3) In the TimeStampChangeDetection.c example program, there is an instance that I can not understand. I see how the buffer for the PCI 6533 is being read in segments that are possibly larger than half a buffer. However what I do not understand is why in the case that the data has wrapped and started writting at the beginning of the buffer again
 the second call to memcpy uses:

//if there is new data at the beginning of the buffer, get it out as well.
memcpy ((void*)&FastBuffer[PreviousPointsRemaining], (void*)&piBuffer[ulBufferSize - PointsRemaining], sizeOfData*(ulBufferSize - PointsRemaining) );
 
 My  thought was that here I should use:

memcpy ((void*)&FastBuffer[PreviousPointsRemaining], (void*)&piBuffer[0], sizeOfData*(ulBufferSize - PointsRemaining) );

I believe that the example is right, but there is something that I do not understand or that I am missing, and I would appreciate it if this could be clarified to me.

4) I would like to cascade the tw counters in the PCI 6035 to be able to time stamp long sequences of pulses but with 50 ns time resolution (I would like to use the 20 MHZ clock on the pci 6035). I could not find an example of this in CVI. How should I proceed to get this?.

At this stage I would like to use the traditional NIDAQ because I will incorporate this program into an existing application that has been written using CVI and ftraditional NIDAQ.

I hope that I can acquire my data with the  cards that I have.

!Many thanks for your excellent products and support.

Fundadero

0 Kudos
Message 1 of 5
(3,457 Views)
 

Fundadero,

Thanks for posting to the NI Forums.  Let me see if I can begin to address some of your questions:

1)  Yes the PCI-6035 supports buffered counter measurements.  However, the FIFO on the PCI-6035 is only 2 samples deep.  As a result you generally cannot buffer counter measurements at more than about 150 kHz depending on system configuration.  

2) You are correct.  You should not need to use the Align_DMA_Buffer function since you are using the PCI bus and not the AT bus. Crossing page boundries do not have the same negative effect in this case.

3) I agree the example seems to be incorrect.  Have you confirmed that the operation is not as expected?  I think your approach is the correct way to read the data from the buffer.

4) There is not an example readily available that does exactly what you would like.  You are going to need to combine several examples to achieve the operation you are looking for.  I would recommend looking at the following example for how to set up cascaded counters in NI-DAQ Traditional:
https://download.ni.com/contrib/epd/B45EACE3EF1256A4E034080020E74861/STCCascadedCounters.zip

This example however does not employ buffered counter operations and you will need to combine the techniques used in the other example in conjunction with this example.

As a last little piece of advice I would highly recommend moving your entire application to DAQmx.  First, your Legacy code will become more and more difficult to maintain and modify as time passes.  You may be able to find answers right now but it will be harder to find them in the future.  The number of people that can effectively support Traditional NI-DAQ is dwindling.  We will always do our best to support these older applications but since the number of people that are using the driver is also falling the resources that can be dedicated to do so are very limited.  Second DAQmx is a more robust and more straightforward API.  Most people that put in the time to learn the new API find it much easier to use.  DAQmx takes care of buffering issues for you and counters are significantly easier to program.  It is also natively multithreaded.

For these reasons I highly recommend you consider making the jump.  Let me know if you have any additional questions or if I can help in any other way.

Regards,

Neil S.
Applications Engineer
National Instruments

 

Message Edited by Neil S. on 09-18-2006 03:15 PM

0 Kudos
Message 2 of 5
(3,415 Views)
Neil,

Thanks for your help. The
TimeStampChangeDetection.c  example runs but it crashes
 (the variable line becomes zero and that causes problem with the logarithm).
The program runs well when the buffer is copied from the beginning.
I am looking at the cascading example.
I have tried NIDAQmx, for another program that i wrote from scratch, and i struggled a lot. In addition I am not hapy with the performance, but that is becaus i did not write an optimum code.
I will move to NIDAQmx altogether when I rewrite the existing application which is the one I am quick-fixing now.
I found that the example codes where crucial to learn traditional NIDAQ, and i think that the same will
help for non professional programmers like me to get familiar with NIDAQmx.
I come across the benchmarks for buffered acquisition. 150 KHZ is plenty of speed.You Pointed out that the FIFO in STC counters
is only to elements. What NI counter  has a bigger FIFO?.
For the cascading of the counter,  example I am looking at it. I thnk that I can combine it with the buffered counting example that I am modifying.
Thank you

Regards,

Fundadero

0 Kudos
Message 3 of 5
(3,404 Views)
 

Fundadero,

I spent some time yesterday looking very carefully at the example and I agree that you should be reading the buffer from the beginning.  I am glad the example runs well when you make that modification.  Let me know if you run into any issues while trying to modify the example to use cascaded counters.

National Instruments just released several bus powered USB M-Series multifunction devices.  

These devices include a 1023 sample FIFO for the counters which greatly improves performance.  One of my colleagues was able to continuously clock in buffered counter operations at greater that 1 MS/s.   

Let me know if you have any additional questions.

Regards,

Neil S.
Applications Engineer
National Instruments

 

Message Edited by Neil S. on 09-19-2006 07:19 AM

0 Kudos
Message 4 of 5
(3,392 Views)
Neil,

Thanks for your sugestions.Those new cards look awesome, but at the moment I have to do with the cards I have.
I have one a question about the PCI 6533 not showing up unde NI-DAQmx devices in MAX,  but I will post in a different thread since is not related to this thread.

Thank you,

Fundadero
0 Kudos
Message 5 of 5
(3,363 Views)