From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop acquisition with a Trigger with NI PCIe 6323

Solved!
Go to solution

Hi all,

 

i'm wondering if is it possible to stop acquiring data from ni pcie 6323 with a trigger pulse the same way as i start acquiring samples with a trigger pulse in finite sample mode.

 

Thanks in advance 

 

MR

0 Kudos
Message 1 of 14
(5,296 Views)

I've found this related post (http://forums.ni.com/t5/Measurement-Studio-for-NET/How-to-read-from-start-to-reference-Trigger/m-p/1... )that seems the solution i need but since i'm using 

 

BeginReadWaveform() and BeginMemoryOptimizedReadWaveform() function calls to work asynchronously i'm asking you the right way to start and stop acquisition with a trigger and reference trigger in C#.NET 

0 Kudos
Message 2 of 14
(5,292 Views)

The idea is to configure a reference trigger (which will stop the acquisiiton) but instead of reading relative to the first pretrigger sample (the default), read the data continuously as it is acquired.  I don't have the .NET libraries currently installed and it's been a while since I have used them, but I believe it should look something like this:

 

  1. Create a new task.

  2. Create an analog input channel with the desired specs.

  3. Configure finite timing (Task.Timing.ConfigureSampleClock).  The samplesPerChannel input determines the buffer size so make sure it is large enough to avoid underflow (depends on your desired sample rate).

  4. Configure a reference trigger (Task.Triggers.ReferenceTrigger.ConfigureDigitalEdgeTrigger).  You have to have a minimum of 2 post trigger samples so the pre-trigger samples should be configured to be 2 less than the samplesPerChannel chosen in the previous step.

  5. Create the reader stream.

  6. Set the ReadRelativeTo property for the stream to be CurrentReadPosition.

 

From there, the task will behave like a continuous input task except when the reference trigger is received the acquisition will stop (2 samples after the trigger).  

 

 

Best Regards,

John Passiak
0 Kudos
Message 3 of 14
(5,276 Views)

Hi,

this white paper can help you: http://www.ni.com/white-paper/2835/en/

 

For stop acqusition with trigger you have to use "Reference Digital Edge" DAQmx Trigger block.

0 Kudos
Message 4 of 14
(5,260 Views)

Thanks for the answer, i will try soon this... in the meanwhile i'd like to ask you also the following:

 

I'm configuring my task this way:

 

analogInputTask.Timing.ConfigureSampleClock(
ClockSource
, SampleRate   //1Khz
, ActiveEdge     //PFI0 rising
, SampleMode   //finite samples
, samplesPerChannel);   // ?????

 

 

I haven't understood clearly how to set correctly the samplesPerChannel number... Can you please explain me this ? is this number that i have to set to 1/10 of sample rate? (1Khz -> 100 samplesPerChannel??)

 

how relate this .net function call to the Max Task Time Settings Configuration Page where Acquisition mode, samples to read and rate have to be set??

 

Thanks in advance

0 Kudos
Message 5 of 14
(5,257 Views)

In Finite Acquisition, samplesPerChannel set the number of samples you want to acquire.

in Continuos Acquisition, samplesPerChannel set the dimension of the buffer for storing data.

0 Kudos
Message 6 of 14
(5,255 Views)

Hi! Thanks for your interest,

 

let me check if i got it:

In finite acquisition i set samplerate = 1000 (1Khz)

if i set samplesPerChannel = 100 what i get is a undersampling of factor 1:10? acquiring signal @ 100Hz instead if 1Khz specified in the samplerate variable?

 

Thanks

0 Kudos
Message 7 of 14
(5,252 Views)

With sample rate = 1000 and SamplesPerChannel = 100 means that you acquire 100 samples at 1KHZ (you acquire 100 samples in 0.1s).

0 Kudos
Message 8 of 14
(5,245 Views)

so sampleperchannel value defines the acquisition duration:

 

if i acquire data @1Khz and samplesperchannel is 100K samples, Whole Acquisition will last 100s ( 100k [samples]/ 1k [samples/s] = 100 [s] ) so i have to set my PCIe 6323 read timeout accordingly... how can it be done in .net c#?

 

Have you some sample code in c# to read asynchronously data in these conditions?

 

I mean: 

 

 

  1. Acquisition mode = Finite sample
  2. start trigger = PFI0 rising edge
  3. reference trigger = PFI0 falling edge

 

0 Kudos
Message 9 of 14
(5,239 Views)
Solution
Accepted by topic author Mariano76

The samplesPerChannel which you specify when configuring the sample clock sets the total number of samples for the finite acquisition.  In your case, you will be reading the pre-triggered data continuously so in effect this parameter really only sets the buffer size.  So you just want it to be large enough to avoid underflows (although... if the window you are acquiring from is potentially very short, you might want to explicitly configure the buffer size to something larger and keep the samplesPerChannel value low so that the reference trigger can be accepted sooner).

 

The numberOfSamples which you specify when you start the reader sets the number of samples for the next read call.  So you can read smaller windows of data continuously to avoid having a blocking call with a large timeout.  If you do want to change the timeout it is a property of the DAQStream class.

 

The "continuous" examples (e.g. this one) should show how you can read back data asynchronously as it is being acquired.  Your configuration is more like a "continuous" example.

 

 

 

Since you want to start and stop using the same line as a trigger, perhaps an alternative to changing the default read pointer would be to configure a continuous analog input task with a pause trigger.  The caveat to this is that the pause trigger does not stop the task and as soon as the line goes back high you will begin to acquire data again--I would suggest using a counter to separate the groupings of samples from the continuous buffer.  If you want to acquire multiple windows of data in short succession though, then I would go with this instead to avoid having to restart the task (and potentially miss samples while the task is being restarted).

 

 

Best Regards,

John Passiak
0 Kudos
Message 10 of 14
(5,215 Views)