LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I control the timing to trigger tasks for multiple channels

Hi all,

  I am wondering how labview control the timing to trigger task for mutlipler channels. Let say I have two analog output channels (ao3 and ao5) and one digital channel (do1). I am going to write to those 3 channels based on the following timing diagram

 

timing.png

 

Now I have three tasks setup for each channel. I  write the pulse sequence to the analog output buffer for ao3 and ao5 and start the tasks at about the same time. After the tasks (for ao3 and ao5) started, I wait (sleep) 8ms so to set the do1 with HIGH voltage and wait another 7ms and set do1 with LOW voltage. But this way cannot precisly control the timing, it is getting worse when the pulse interval becomes shorter. I wonder if there is better way to control the timing.

0 Kudos
Message 1 of 9
(3,649 Views)

Hello,

 

Here is an article that discusses synchronization and timing in LabVIEW: http://www.ni.com/white-paper/11369/en/

There also might be more specific articles depending on what device you are using. For example, here is an article talking specifically about M-series synchronization: http://www.ni.com/white-paper/3615/en/

 

I hope this helps!

Stephanie S.
Application Engineer
National Instruments
0 Kudos
Message 2 of 9
(3,603 Views)

What hardware are you using?  

 

Many NI DAQ cards support writing a buffer of output data and clocking it out deterministically with a hardware-timed sample clock.  You should be doing this and sharing clocks and/or triggers between your tasks for synchronization.

 

 

Best Regards,

John Passiak
0 Kudos
Message 3 of 9
(3,598 Views)

@John_P1 wrote:

What hardware are you using?  

 

Many NI DAQ cards support writing a buffer of output data and clocking it out deterministically with a hardware-timed sample clock.  You should be doing this and sharing clocks and/or triggers between your tasks for synchronization.

 

 

Best Regards,


I have PCI6713. Yes, I find an example about writing samples to a buffer and control that with hardware clock. However, what confusing me is for one analog signal (continuous), but I don't know how to write ONLY ONE digital spike at specific time which is synchronous with the clock used by the analog signal. What I am asking is, if I have two analog signal of the same number of sample, I can easily have them controlled by the same clock so they will be synchronous. But what happen if the number of samples or two signals are different (in my case, I have 2048 samples for analog signal, but I only have one digital sample (VCC) being written.

0 Kudos
Message 4 of 9
(3,589 Views)

The 6713 only has software-timed digtial outputs, so that leaves you with two options:

 

1.  Use an additional analog output channel to output your "digital" signal.  You would combine all of your analog output channels into a single task, with the same number of samples for each channel.  As an example, the "digital" channel could be something like {5, 0, 0, 0, 0 ... } if you just wanted a short pulse at the beginning of your output, or {0, 0, 0, ..., 0, 5} if you wanted it at the end.

 

2.  Use a counter output to generate the single digital pulse (this only works if you need to generate a single digital pulse though, or if you needed to generate a sequence of uniform pulses).  You can trigger the counter output from the analog output start trigger and use a programmable initial delay, so synchronization may be achieved in hardware.

 

 

Best Regards,

John Passiak
0 Kudos
Message 5 of 9
(3,576 Views)

@John_P1 wrote:

The 6713 only has software-timed digtial outputs, so that leaves you with two options:

 

1.  Use an additional analog output channel to output your "digital" signal.  You would combine all of your analog output channels into a single task, with the same number of samples for each channel.  As an example, the "digital" channel could be something like {5, 0, 0, 0, 0 ... } if you just wanted a short pulse at the beginning of your output, or {0, 0, 0, ..., 0, 5} if you wanted it at the end.

 

2.  Use a counter output to generate the single digital pulse (this only works if you need to generate a single digital pulse though, or if you needed to generate a sequence of uniform pulses).  You can trigger the counter output from the analog output start trigger and use a programmable initial delay, so synchronization may be achieved in hardware.

 

 

Best Regards,


Thanks for your reply. I think the second option might help. I didn't use counter before, so does counter produce TTL signal also? As my understanding from your suggestions, it seems that I could use the counter and proper sampling rate and analog channel to trigger the counter to produce the digital signal. If that's what you mean, do I have to physically connect the analog channel to somewhere so to cast as a trigger source?

0 Kudos
Message 6 of 9
(3,572 Views)

Yeah, the counter output is available on one of the PFI lines which produces a TTL output.  You can trigger the counter output off of the analog output start trigger which may be routed internally.  The counter output channel takes an initial delay parameter so you can have hardware-timed precision on when the counter issues its digital output pulse relative to the start of the AO task.  Make sure to start the counter task first in software so that it is armed before the analog output start trigger is issued.

 

 

Best Regards,

John Passiak
0 Kudos
Message 7 of 9
(3,568 Views)

@John_P1 wrote:

Yeah, the counter output is available on one of the PFI lines which produces a TTL output.  You can trigger the counter output off of the analog output start trigger which may be routed internally.  The counter output channel takes an initial delay parameter so you can have hardware-timed precision on when the counter issues its digital output pulse relative to the start of the AO task.  Make sure to start the counter task first in software so that it is armed before the analog output start trigger is issued.

 

 

Best Regards,


Hi John, I am trying to incorporate your idea into my code but I still don't understand how to use initial delay. But follow the example http://www.ni.com/white-paper/4329/en/, I wonder if I could could trigger (from analog output)  and single digital line output to do the same thing. I have my code like

 

Untitled_1d.png

there I use channel 3 as the analog output and use it as a trigger also. I have it connected to trigger module which is binding to the digital output channel. The digital line output output only 1 boolean sample but the task will only start when the "reference analog edge" reach the given level. Do you think this code work? I am monitoring the pulse train in the scope, it looks good. But this code doesn't work, the trigger doesn't work.

0 Kudos
Message 8 of 9
(3,534 Views)

Like I mentioned before, the 6713 only has software-timed digtial outputs, you can't configure any trigger on a digital output task.

 

The 6713 also doesn't support analog triggering.

 

Even if it did, an analog output channel isn't a valid source for an analog trigger on any DAQ device that I'm aware of.

 

 

Following suggestion #2 that I gave here, your counter output task would look something like this (replace Dev1 with whatever your device name is):

 

SimpleCounter.png

 

 

 

Best Regards,

John Passiak
0 Kudos
Message 9 of 9
(3,505 Views)