Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquire analog samples on a digital trigger event from a continous analog acquisition

Hi,

 

    I currently have a system with two "synchronized" M-Series card.  Currently, I'm waiting for a digital trigger coming from PFI7 to automatically start the acquisition for a number of seconds of both cards.  This works as expected.  Of course, when doing it that way, no data is acquire until the trigger occurs and I can't show anything to the user.  What I would like to do is a continous acquisition from which I would show some current samples on the screen with a graph and, when the trigger occurs, the data would be grab for the specified number of seconds and save on the disk then resume the viewing of the data in waiting for the next trigger to occur.  Is that possible? If so, how?

 

TIA,

 

Michel

 

0 Kudos
Message 1 of 7
(4,003 Views)

Hi Michel,

 

Here is an example of how to achieve this.  In this example, you will have to bring your digital pulse into a counter.  Once the counter has counted the pulse, it will change the status to true for the comparison and then begin to log data using the case structure.  You will have to add in additional logic to have it only log a certain number of values, but this is a good starting point.  Please let me know if this works and if I have misunderstaood your post at all. Files attached as well.

 

Digital Trigger.png

 

Community Example:

http://decibel.ni.com/content/docs/DOC-10608

 

Best,

Adam
Academic Product Manager
National Intruments
Message 2 of 7
(3,981 Views)

Hi Adam,

 

    Thanks for the solution but it doesn't exactly meet  my problem.  In this solution, the past data is log when the counter gets the pulse.  What I want to do is to record the next - like a number of seconds of data - following the pulse.  And I need to be pretty precise on the occurence of the pulse in relation with the data.  This is for synchronization between an apparatus generating this pulse on the start of its own acquisition with some forceplate signals (and other signals) acquisition that we do with the M-Series card.  That way, I'm pretty sure that the data collected by this apparatus is in sync with our signals.  I just don't want to wait for the pulse to show some "current" force signals to the user but I don't want to miss the "real" data when the pulse occurs.

0 Kudos
Message 3 of 7
(3,976 Views)

Hi Exovede,

 

From my understanding, you will need to acquire a certain number of values after the pulse is received.  What you could do is set the counter input to be hardware timed, and acquire data at the rate from the AI Sample Clock and AI Sample Clock Rate.  You could then get a counter reading for every analog input reading you take.  Then you have two options: log all of the data and post-process the data, or build in logic to your VI in software to only log data when the pulse is received and a set number of points thereafter.  Would either of these methods work for you?

 

-At what rate are you sampling?

-How many points are you attempting to acquire when you log the data?

-How many pulses will you receive?

-What M-series card are you using?

 

Best,

Adam
Academic Product Manager
National Intruments
0 Kudos
Message 4 of 7
(3,963 Views)

Hi Adam,

 

    The second method would be adequate.  Here's the criteria:

 

- I have synchronized two M-Series cards (PCI-6225 and PCI-6229).  One will acquire data at 600 Hz, the other one at 1200 Hz (the frequencies may change depending on the protocol of the experiment).  This is already tested and working.

- The number of points could be variable.  Time of acquisition can vary between 5 and 300 seconds but it is set before the experiment.

- Each trial to log the data will receive one pulse but an experiment consists of many trials with pauses between each trial.  However, in those pauses, I need to show the current values of signals (checking if nothing is "broke").

 

    As I wrote earlier, everything's working.  I only want to add an extra by showing the current values of signals between the trials (or pauses)  as for now the material is only waiting for the trigger to start the acquisition and, in this waiting, I can't show nothing to the user.

 

Thanks again,

 

Michel

Message 5 of 7
(3,941 Views)

Good morning Exovede,

 

The first example that was posted only gives you the ability to build in logic for every "n" number of samples, depending on your samples to read that is configured in your DAQmx Read Analog signal.  After a counter tick is registered, you will then start to log data indefinitely.  There are many ways that you could then build in logic to stop the logging and then wait for another tick.

 

One method would be to implement a producer consumer architecture that acquires and displays all of your data in one loop, both the analog and counter input (equal sized arrays) and then queues the data to be analyzed in the consumer loop.  Now in the consumer loop, you can parse through the data in chunk sizes equal to the samples to be read from the DAQmx read.  You can then step through the counter data array, one element at a time, to identify the element where the pulse happens.  Then you can start logging the data.  This can be done by setting up a state machine or another method of logic.  After a criteria has been met (time, number of samples, etc.) you will then stop the logging and wait for another pulse.  You could also setup another consumer loop taht you pass data down to it when you get a pulse on your counter input.

 

 

Application Design Patterns: Producer/Consumer:

http://zone.ni.com/devzone/cda/tut/p/id/3023

 

DAQmx Base Continuopus Analog Input wtih Prodcuer/Consumer:

http://zone.ni.com/devzone/cda/epd/p/id/6192

 

Best,

Adam
Academic Product Manager
National Intruments
0 Kudos
Message 6 of 7
(3,903 Views)

Here's something similar in DAQmx (rather than DAQmx Base):

 

Using Producer/Consumer Architecture for DAQmx Read and Write to File

 

 

Best Regards,

 

John

John Passiak
Message 7 of 7
(3,877 Views)