Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Read N samples after trigger

Hello,

 

I have a c# using measurement studio code to read some voltage from a NI DAQ card. I want to adquire samples with a Sample Clock Trigger, i. e. the trigger arrives in bunches of about 100 events at a 1 kHz frecuency, so I need to acquire those 100 samples. After that I read the data and I have no trigger for some miliseconds and the second bunch of trigger signals arrive to acquire 100 new samples. 

 

The way I am doing this now by using 

 

runningTask = analogInTask;

analogInReader.BeginReadWaveform(100, analogCallback, analogInTask);

 

and I have callback like this:

 

private void AnalogInCallbackNSamples(IAsyncResult result)
{

try
{

if (runningTask != null && runningTask == result.AsyncState)
{
acquiredData = analogInReader.EndReadWaveform(result);
runningTask = null;
}

}
catch (DaqException ex)

{

runningTask = null;

}

finally

{

analogInTask.Dispose();

}

}

 

The proble is that this work OK sometimes but it crashes many times. And, also, in this way I need to re-setup the parameters of the DAQ card after acquiring each bunch of data and I have to begin reading again...

 

The question is: Is it possible to setup the DAQ card only at the beginning and then just read 100 samples after the first trigger then read the data and wait for the next trigger and repeat it again? How can I do this?

 

Thanks for your help.

0 Kudos
Message 1 of 6
(4,624 Views)

Hi betelgeuse84,

 

do you have Measurement Studio installed on your machine?

 

If so, there is an example shipped with the installation, that contains nearly the functionality you need.

 

Please go in Visual Studio under Measurement Studio >> Measurement Studio Examples and open the following folder:

 

<National Instruments>\NI-DAQ\Examples\DotNET4.0\Analog In\Measure Voltage\AcqVoltageSamples_IntClkDigStartAndRef\CS

 

This example uses pre triggering, you need post triggering.

 

Best regards,

Melanie

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 2 of 6
(4,584 Views)

Thanks Melanie,


But this is not what I need. I need to acquire 100 samples with a reference trigger read them and wait for the next bunch of 100 triggers and acquire again the samples. 


Since I will have only 100 signals which are also synchronized with another acquisition equipment I cannot use a start trigger because I will miss the first pulse.... Therefore, I can only use reference trigger but I would like to know if there is a way to set it up in order to not to have to set up the acquisition every time after acquiring the 100 samples...

 

I think I need something like retriggering but using it only with reference trigger...

 

thanks

 


B.

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

Hi B.

 

if I got it right now, you only want to aquire the samples after 100 trigger pulses have come in. For this application you have to find a solution to not react on the 99 trigger signal coming in before.

 

You could do so by using a pulse counting task and generate a trigger from this task to the AI task everytime you counted 100 edges.

 

The trigger sent by the CI task can be used for the AI task as reference trigger then.

 

Hope this helps better.

 

Best regards,

Melanie

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 4 of 6
(4,577 Views)

Hi M.

 

Sorry, I explained wrong maybe. I need to acquire 100 samples, one after each trigger. Then read the 100 samples, and wait for the next burst of 100 trigger pulses to acquire 100 new samples.

 

Thanks


B.

0 Kudos
Message 5 of 6
(4,575 Views)

Hi B.

 

thank you for your answer.

 

Just to have a clear starting point now and to make sure I understood the requirements right now.

 

When receiving the first trigger pulse, you want to acquire 100 samples and read them from your DAQ device.

Then you want to wait for the next 100. trigger pulse and acquire the next 100 samples then.

 

Is that correct?

 

If not, please make a little illustration about what you expect to realize.

 

Best regards,

Melanie

Best regards,
Melanie Eisfeld
Senior Applications Engineer, National Instruments Germany
Certified LabVIEW Developer
Certified TestStand Architect
0 Kudos
Message 6 of 6
(4,563 Views)