08-07-2012 11:27 AM
Dear All,
Being relatively new into programming in LabView I do have a question considering data acquisition and triggering. Searching documentation and forum couldn’t answer my question so far. I am using LabView to make some simple software in giving participants feedback on a task to perform based on their muscle ElectroMyoGraphy (EMG).
For clarity:
What I’d like to do is temporarily stop data acquisition when an external TTL trigger pulse is recorded (coming from some external hardware) while performing the requested task. So the task will last for about a minute and throughout this minute the data acquisition needs to be temporarily stopped, time being related to the width of the TTL trigger block pulse, and resumed again.
The purpose of temporarily stopping data acquisition is to freeze participant feedback as an external disturbance is presented which we don’t want to show up in the feedback, and thereby influence the task performed.
Important note: I tried several methods but came across the problem that I don’t want to do continuous acquisition as the buffering seems to delay the feedback which should really be instantaneous. The program it selves works very well using the Express Data Acquisition VI with a Single Point settings (1000 Hz sampling rate), obviously not including the stopping at triggering. Continuous acquisition, however, seems to be a requisite for being able to use proper triggering.
Hope anybody can give me a go with any small example or comment!
Cheers,
Mark
Solved! Go to Solution.
08-08-2012 12:13 PM - edited 08-08-2012 12:15 PM
Hi Mark,
I've interpreted your post as follows:-
- You want to acquire analogue data until an external TTL (0V to 5V) trigger signal goes high.
- When this signal goes high, you want to pause data acquisition.
- When this signal returns to a low state, you want to resume acquisition.
- You have tried to achieve this using the DAQ Express VI.
To acheive this you will need to use the lower level DAQ VIs, so that you can pause a continuous acquistion when a trigger signal goes high.
I have written and attached some code that should illustrate how this is done.
You will need to connect your trigger source to a 'TRIG' input on your BNC-2090, and then select this as your trigger source on the block diagram.
I hope this is helpful,
08-09-2012 03:33 AM
Hi,
Thanks for your reply.
Your interpretation of the problem is right.
I did play around with lower level VIs but couldn't work out exactly which properties to use.
I did a simple test with your code and although it runs it doesn't show the expected behavior.
It seems to pause when a trigger is received but it only registers one out of many external triggers.
Additionally after some time it gives the E -200279 it tried to read samples which are no longer available.
Hence, I am using the 6024E DAQ card and although a lot is posted elsewhere on this forum about how to use
this card with triggering and DAQ I can't work out how to make it work in my case.
Cheers,
Mark
08-09-2012 04:43 AM
08-09-2012 05:32 AM
08-09-2012 11:32 AM
Hi,
The good news is that with playing with the sampling rate and the samples per channel setting I have been able to get the code well running without error messages (so far..).
However the second part of my initial question still remains. There is a significant delay between the time the actual trigger is generated and the acquisition is paused. An delay up to 10 msec would do for me but now it is much longer. What setting determine the delay? (I guess it has to do with samples per channel and sample rate as well).
Hence as I mentioned in my first post the initial code, without the pausing, worked well only with single point acquisition in the express VI whereas the continiuos acquisition gave a significant delay between action --> reaction as well.
Hope does makes sense and someone could clarify on this,
Mark
08-10-2012 10:26 AM
Hi Mark,
Just a few questions;
- Can you send me your code?
- Are all of your external trigger signals connected to trigger inputs on your NI BNC-2090?
Thanks
08-10-2012 10:55 AM
Hi Josh,
I am just using the code you attached earlier. Only played with sample rate and samples per channel.
Happy to send it but it is exactly similar to what you've send me. My full code has exactly the same problem
so it doesn't really make sense to send it will take you some time to get through it.
I do have one single trigger channel connected to the TRIG input on the BNC rack. A trigger comes in roughly each 2 seconds
but there is a significant delay between receiving the trigger and pausing the acquisition.
Thanks a lot for the effort you put into it.
Regards,
Mark
08-13-2012 08:30 AM
Hi Mark,
I will look into this further. With your hardware you shouldn't be getting a delay as long as 10 msec, so it is likely to be something in software that is causing the delay.
I will post back when I have some results.
Regards,
08-15-2012 10:05 AM
Hi Josh,
I have been working on this the last few days and solved part of the problem.
The good new is that LabView does pause immediately now on each trigger coming in on the TRIG input.
What I changed to your code is change the acquisition type of the Read VI to Analog Input --> 1 Chan, N Samples.
Additionally I had to remove the Wait until ms function.
With the following settings:
Sample Rate = 10000;
Samples per Channel = 10000;
Number of samples per channel = 1000;
It works perfectly!
The delay in the Analog Input, 1 Chan, 1 Samp likely originates from a buffer which is created as read out isn't fast enough to keep up
with the acquisition. Therefore it always lags when a trigger is applied and there is a significant delay.
It raises however a view questions on what is the best way for me to acquire my data as for me it is of huge importance that the feedback is real time, so the sampling
frequency being as high as possible.
1:
The solution proposed is effectively a massive downsampling, isn't it? As I can only process single values in the rest of my code, I need to extract a single value from each array (length: 1000) acquired
decreasing my sampling frequency effectively to 10 Hz. Agree? (1 sample processed each 0.1 sec)
2:
I had to remove the Wait Until ms function from the while loop in order to avoid getting the E-200279 (Samples no longer available) error. This is in all cases
were I try to use single Sample Acquisition. What is the purpose of this function? My feeling is that it only messes up the HW timing coming from the Sample Clock and consequently fills
the buffer when it waits, leading to the observed error.
3:
Final and most important question: What would be the most efficient way for me to acquire data taking into account the comments made before?
I'd like to acquire single samples with the highest possible sample frequency (preferably around 2000 Hz).
Hence, this all has been tested in the plain code (as you send it earlier) and my full code. Behavior is similar.
Regards,
Mark