Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

"AI buffer Read" with trigger

I don't well undertand how "AI buffer Read" works when the AI is triggered :
- Does it wait for the trigger and return no data until it occurs ? or
- Does it read the buffer already before the trigger occur and return 0 until it occurs. (in this case, do I have to call this function in a while loop during waiting for the trigger) ??
Thank you all.
0 Kudos
Message 1 of 6
(3,367 Views)
When configured for triggering, the AI Read function will wait until the trigger has occurred before returning data. If the trigger does not happen within the given time limit, then AI Read returns no data and gives a timeout warning.

You can also configure pretrigger or posttrigger scans. Check out the LabVIEW DAQ examples for triggered Analog Input for a starting point on how to implement this functionality.
0 Kudos
Message 2 of 6
(3,368 Views)

Hi all !

I also have a problem,

I create differents ai task to read continuous sample from differents cards. These tasks are created to start with an external  trigger, and are all synchronized together with an external 10 MHz Clock . I may have a different frequencies for each board, these frequencies can go from 0.1 to 20000 kHz. My problem is the following: Immédiately after i generate the trigger, i want to read the samples available on each card in order to know if they are working properly.

It works good with high frequencies (i.e. 10 000 Hz ..) but when i use low frequency 0.1 Hz, i have no sample available, i only have sample after 10 seconds. I tought, that when i start the task, i immedialtly have one sample and i have the second after 10 s... But the test i made show me i have no sample during 10 seconds and then 2 samples . It seems, the sample is present in the buffer of the card, but this buffer is only transfered to the memory after the next cycle ....

I tried to modify the transfert property but there is no change ....      

Thanks in advance for your future help !

0 Kudos
Message 3 of 6
(3,228 Views)

Hello,

Unfortunately, I do not see a way around this situation.   Why do you need to read the samples right away?  The only way I see to do this is to increase the sample rate so you get those first samples faster and then throw away the extra data you do not need.

Regards,
Laura 

0 Kudos
Message 4 of 6
(3,194 Views)

Hi Laura, and thanks for your answer !

When i start the acquisition, i read one sample of each channel in order to know if the acquisition is working properly, i.e. the boards are not out of order, and the trigger lines are properly configure di n max... If i have no sample , i generate an error message, and i stop the acquisition. The problem is if i hav a frequencie of 0.1 Hz for one channel and 10 000 Hz for another one. I can wait 10 second to read the first sample, otherwise i will have an overflow in the buffer of the board wich contain a channel of 10 000 Hz ....

I also contacted NI support, and they gave me this explanation : If you use DMA transfert between the onboard memory of the card and the PC, the driver can only transfert 32 bits data. And one sample is 16 bits, therefore, you need to acquire two samples before they become available with the read function.  So if you want to read one channel at 0.1Hz, you will have to wait 10 seconds to read 2 samples ! If you use IRQ transfert you will not have the problem (but it reduces a lot the performance of the acquisition) ...

 One solution to avoid this problem is to acquire at least two channels per board, therefore the on board memory will have immediately 32 bits, and the samples will be  immediately available !!! I tested this solution and it works perfectly, but it's good to know how it's work!!! 

Thanks  again for your answer !

 

0 Kudos
Message 5 of 6
(3,187 Views)
0.1 Hz is slow enough that you COULD do software timing with good accuracy.
0 Kudos
Message 6 of 6
(3,179 Views)