Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

6602 Arm Trigger to Sync Multiple Tasks

I am using a 6602 card to read the period of multiple TTL square waves.  I am doing this through Matlab using the DAQmx functions.  I was able to read the period on one channel perfectly fine.
 
To check the robustness of the code, I tried reading the same TTL wave through two different counters.  The counters were put into seperate tasks, therefore using two StartTask functions.  i noticed this caused the tasks to be offset by 15 or so samples.
 
I believe I should be using an arm trigger to sync the two tasks.  I cannot find an arm trigger function for a 6602 to use in Matlab,though.  Is there an arm function or should I take another route?
0 Kudos
Message 1 of 7
(5,347 Views)
Hi Mike,

I am not sure you should call it "15 samples apart". Do you mean that your first counter measures X on idex 0 and the second counter measures the same x on index 14?
Here is how buffered works and the picture below:



Furthermore, you are using DAQmx Tools correct?
If you think you need a trigger so that the two counters start at the exact same hardware time, you can always use "DAQmxDigitalTrigger" for both counters on the same terminal.
You can refer to the getting Started with DAQmx document here.
Hope this helps,


Message Edited by Yardov on 06-15-2007 05:53 PM

Gerardo O.
RF SW Engineering R&D
National Instruments
0 Kudos
Message 2 of 7
(5,326 Views)

By 15 samples later, I mean Counter 0 measures it's 15 samples before Counter 1 measures it's first.  So index 0 on counter 1 matches index 14 on counter 0.  It is basically a need for a trigger to start both counters simultaneously.  The problem occurs when I am trying to write the code to do this through Matlab.  The only DAQmx digital trigger functions availbe through Matlab are:

DAQmxCfgDigEdgeStartTrig

DAQmxCfgDigPatternStartTrig

DAQmxCfgDigEdgeAdvTrig

I'm not sure which one is best suited for what I want to do.  The one thing I can think of is to read (or route) in a slow square wave into a another channel and use an edge to trigger both counters.  Does this make anymore sense?

0 Kudos
Message 3 of 7
(5,311 Views)
Playing around with this a little more, I realized that the two counters are infact not even running displaced to one another.  So index0 on counter 1 only matches index14 on counter 0 by pure coincidence.  Counter one is actually just reading the period as soon as counter 0 finishes reading its specified number of samples.  What must be done to run the two counters simultaneously?
0 Kudos
Message 4 of 7
(5,302 Views)
Hello Mike,

Feel free to atach your code (or paste part of it) if you are not familiar with DAQmx terminology.
  • How many samples are you taking each task? Is this finite or continuous acquistion?
  • Are you calling "DAQmxCfgDigEdgeStartTrig" for both of them on the same terminal? If so, you should start your task then call the read which will not return until the trigger has been received and the number of samples specified are acquired.

Gerardo O.
RF SW Engineering R&D
National Instruments
0 Kudos
Message 5 of 7
(5,289 Views)
Thanks for the response Gerardo,
 
I am now collecting the samples continuously.  This yielded simultaneously running tasks that are just delayed from one another (which is almost what I want).  I was running finite before, but am no longer.
 
I tried using DAQmxCfgDigEdgeStartTrig but was not successful.  I've attached my Matlab code (as a .txt) with the attempted trigger is clearly labeled.  I was trying to run an internal trigger or sorts.  I am probably way off on this assumption, though.  I was thinking I could generate a pulse signal to counter2 and use that as the trigger signal.  How wrong is that?
 
-Mike
0 Kudos
Message 6 of 7
(5,285 Views)
Hi Mike,

Thank yoou for posting the code, this helps.
When you use CI measurement task (just as period, frequency, semi-period) the trigger cannot be use since the counter gate is already being used.

To solve your problem, you need to accommodate the task in order for them to measure the same:

%Start the task that measure

[err04] = calllib('myni','DAQmxStartTask',taskh1);
[err14] = calllib('myni','DAQmxStartTask',taskh2);

%Now start the measured signal

[err25] = calllib('myni','DAQmxStartTask',taskh3)
This way, you guarantee that both taskh1 and taskh2 will measure the same signal and not delayed.
Gerardo O.
RF SW Engineering R&D
National Instruments
0 Kudos
Message 7 of 7
(5,269 Views)