LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Master/Slave clock for DAQ

Hi everyone:

I am trying to syncronize my counters and analog output.
What I am doing now is to use one counter as the reference for my AO (so that they will be syncronized).
See the attached picture 1.

But I also have another counter to be syncronized with the original counter.
What I am doing in picture 1 is I let each counter use their own clock (rather than the second counter refers to first counter's clock.) 
It works, but I am not sure if these two counters are using the same clock on the hardware, or they have their own clock. (If so, it might cause un-syncronization for my application.)

In another trial, I use let the 2nd counter refer to 1st counter's clock, as shown in attached picture 2.
But it is not working. (the 2nd counter doesnt produce any signal then)
Is it because counter cannot refer to another counter? (while AO is able to refer to counter.)

Can anyone help me out.

Many thanks, Jhensi

Download All
0 Kudos
Message 1 of 11
(4,959 Views)

Dear Jhensi,


Thank you for your post.  In order to synchronise up tasks in DAQmx we require two things; a clock and a trigger to be shared across tasks as you are trying to do.  The trick is to setup the master task to hold the clock and start trigger and setup the slaves to run off these.  If you see the attached code, this is an example I use to show how to synchronise up an Analogue Input with Analogue Output.

 

By taking a look at your pictures attached I would be worried that you are starting the master task before you start the slave tasks.  Therefore I would push the Counter 1's DAQmx Start Task into the next frame of the sequence structure, and bring the Analogue Output and Counter 2's triggers and start tasks into the previous frame of the sequence structure.

 

I hope this helps,

Robert Ward
Applications Engineer, NI
0 Kudos
Message 2 of 11
(4,929 Views)

Hi
Thank you for reply.

Actually, I was thinking to start the master first, adn the slave channel has the trigger, so it will syncronize with the master channel anyway.

And I changed as what you said : move the trigger and start for AO and counter 2 previously.
It still works only for the AO, but not the counter 2.

To make things simpler, I only remain counters, please see the attached file
(for some reason, it doesnt allow me to upload .vi, so I can only provide jpg.).
It doesnt work no matter the order of start of these two counters.

I am not sure if it is because the counters simply cannot refer to each other? AO referring to the counter is working under this structure.

Any idea?

Many thanks, js777

0 Kudos
Message 3 of 11
(4,925 Views)

Dear JS,

 

I am not sure if you can't synchronise up two counter tasks to each other, but this community example synchronises up two counters using a dummy AI Channel ( https://decibel.ni.com/content/docs/DOC-11755 ).  Maybe you could replace the AI channel with your AO?

 

Kind Regards,

Robert Ward
Applications Engineer, NI
0 Kudos
Message 4 of 11
(4,913 Views)

Hi:

I am a bit confused about this example.
There is no clock setting for the counters.(so it is by default use the implicit clock?)

In my very first example, I set up the 1st counter (and use its implicit clock), and then let the 2nd counter ref the clock of 1st counter...and it doesnt work.
In my another example, I let each counter use their own implicit clock, and use the trigger to syncronize two counters.
(I dont see any difference between doing so and the example you provide.).

What I am not sure is: if each counter is already use the same implicit clock on board?
I have used counter and AO, and let them use their own implicit clock, the result is their clocking rate are different (the error is something like few ms per second.)
So when I say syncronize, I need to make sure two things : (1)the same clock (2) triggered at the same time.

My current problem is (1), rahter than (2).
Many thanks, js777.

0 Kudos
Message 5 of 11
(4,901 Views)

Dear Js777

 

The following information comes from the NI-DAQmx Help.

The implicit sample timing type is used for acquiring period or frequency samples (or generating pulse trains) using counters. This timing type is called implicit because the signal being measured is itself the timing signal or the timing is implicit in the rate of the generated pulse train.

The implicit instance of the DAQmx Timing VI sets only the duration of the task without specifying timing. No sample timing (time between samples) is set. Typically, you should use this instance when sample timing is not required for the task, such as for tasks utilizing counters. If you use any other instance, such as the sample clock instance, it uses the dt component of waveform to determine how often to produce samples. dt is the time between samples, in seconds. Refer to LabVIEW Help on DAQmx Timing VI for more information.

 

Kind Regards,

Robert Ward
Applications Engineer, NI
0 Kudos
Message 6 of 11
(4,881 Views)

Hi Robert:

Thank you for your replay again. But seems it still doesnt answer my question.
The information you provided doesnt conflict to my assumption: "implicit" is actually the default clock.

But here is one thing looks like a conflict.
You mention the implicit doesnt define the timing, so its clock shouldn't be able to be refered.

BUT, In my very first example, my AO can indeed refer to my counter's clock and syncronize well.
That is why I think the implicit clock should be able to be referred.

In this case, how to explain why the AO -> 1st counter (implciit) can work, but 2nd counter -> 1st counter (implicit) doesnt work.

Many thanks
js777

0 Kudos
Message 7 of 11
(4,869 Views)

Robert, 

 

This may help me in a problem I'm having with my implicit and sample clocks, but I can't open your code.  We have a relatively older version: Labview 2009, Version 9.0f3.  Can you post a screen shot of your code? 

 

Lauren 

0 Kudos
Message 8 of 11
(4,701 Views)

 

Lauren,

 

More info please?  Can you post your code?  Try and describe both what you want and what the problem(s) you're experiencing as clearly and completely as possible.  

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
0 Kudos
Message 9 of 11
(4,693 Views)

I have recently posted my problem on another message board (just hoping to see Robert's code), but I can post it here again:

 

I have one implicit clock and two sample clocks.  The top section of the code creates a line of square pulses at a “rate of trigger” (implicit clock), the middle section reads APD pulses from an input channel at a “rate of voltage” (sample clock) and the bottom section creates triangular waves at a “rate of voltage” (from “pattern”, also sample clock).  To get all of these processes to terminate correctly and at the same time, I connect “Terminal name with device prefix” – which is associated with the implicit clock, to the “source” of all the sample clocks.  (see pictures “Allsourceconneted_1” and 2)

 

Even though the bottom sample clock has its own frequency (rate of voltage), it still produces triangular waves at a rate of “rate of trigger”, due to, I am assuming, the connection to the implicit clock.  If I terminate the connection between “Terminal name with device prefix” and “source” for the bottom sample clock (see picture “disconnectbottom”), then it will produce the correct “rate of voltage”. However, the problem is that this bottom section will continue indefinitely and will never terminate the code, even after the “number of samples” exceeds “data” (see the while loop). 

 

How can I get everything to terminate at the same time, but still have different rates between my implicit clock and my two sample clocks?

0 Kudos
Message 10 of 11
(4,686 Views)