LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggered Digital output with DAQ 6221

Solved!
Go to solution

Good morning,

I am working with a USB 6221 DAQ and my goal is that of generating a digital output when a trigger from an external photodiode arrives at the DAQ. The problem is that, due to the high frequencies of the signal output by the photodiode, I need not to have any software or windows delay, so that I need just the DAQ to handle the trigger and output a predetermined digital waveform any time it receives it from the photodiode.

It has been two weeks now that I am trying with no results, can anyone help me?

Thank you in advance

0 Kudos
Message 1 of 14
(4,528 Views)
Solution
Accepted by topic author scozia123

Try starting with something like this...

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 14
(4,507 Views)

Thank you, it works as expected, but now I have a further question, is it possible to trigger the counter both on a rising and a falling endge? i.e. I would like to output a trigger which has double frequency wrt the one used as PF.

Kind regards

0 Kudos
Message 3 of 14
(4,476 Views)

Are you sure the photodiode signal you're using as a trigger has the right characteristics for this?  To get a frequency doubling effect, you'd need to rely on the raw trigger signal to repeat with a constant rate and a 50% duty cycle.

 

That said, you can't directly configure a DAQmx task to trigger off *either* edge, you have to identify 1 specific edge polarity.

 

Two options:

1. fairly simple external circuit that would turn any digital edge into a brief digital pulse

2. an indirect and fairly complicated DAQmx configuration involving a dummy change-detection based DI task, and a counter task that triggers off an internal "change detect" signal.  I don't have time at the moment to describe it in full detail.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 14
(4,472 Views)

That's the point, the photodiode outuputs a signal which suffer from a jitter, so that it is not the best solution to put a software delay in the software DO generation, but it would be better to trigger the clock also on the falling edge and not only on the rising.

I have not well understood your second solution, I didn't know one could do such a thing using a counter, but I will work on it.

Thank you again for your time and kindness.

Kind regards

 

0 Kudos
Message 5 of 14
(4,462 Views)

This is an outline of my 2nd solution.  Not complete, not tested, but meant to give you a decent headstart in the right direction.  It's a "snippet", so you can save the png file and then drag it into an empty block diagram and it'll turn into code.

 

 

-Kevin P

 

retriggered change detect event.png

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 6 of 14
(4,458 Views)

good morning,

your answer was really useful and I am almost done with my software.

Now I have a last problem to face, which is that of delaying the digital output of the DAQ.

In order to do that, I tried to use DAQ.mx trigger delay, which is supported by the USB 6221 I am using, but it keeps giving me error:-200452, that is

Property Node DAQmx Trigger (arg 1) in Flow OPT (GS3+PI)_Gianmaria_chopper_2f.vi <append>
<B>Property: </B>Start.Delay
In the attachment you can find a snippet of my code, what am I doing wrong?

Kind regards and thank you in advance

0 Kudos
Message 7 of 14
(4,429 Views)

I haven't seen (nor tried to use) those trigger properties on a counter output task before.  Typically what's used is the "initial delay" pulse parameter which can be wired at the bottom of "DAQmx Create Channel.vi". 

 

Unfortunately, the behavior is different for the 1st trigger than for all others.  This article gives some explanation and guidance about a workaround.  Essentially, you'll need to split your single retriggerable finite pulse train task into a pair of counter tasks.  A little further complication, but it should be able to work.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 14
(4,425 Views)

Good morning Kevin_Price,

I tried again as it is showed in the two snippets attached to this post, but still it is not working, resulting in an error:-50103.

I have one task for signal generation (trigger task), one for chopper signal detection (Dummy task1) and the two counters: the first oscillating at frequency that doubles the one of the chopper, the second that oscillates at the same frequency as the first, but it is translated by a phase factor (and therefore a time interval that variates in time since f_chopper is not constant), inserted by the user.

I have no idea why it does not do want I want, any help would be much appreciated.

Thank you in advance

Kind regards

Download All
0 Kudos
Message 9 of 14
(4,319 Views)

Don't have time to fully re-digest the entire thread.  A few things popped out in a quick comparison of your first config pic to that shown in the article I linked in msg #8.

 

  1.  Your ctr0 retriggerable pulse task.  It appears configured for the default of "Finite Samples".  On your M-series device, this requires *both* counters working as a pair, leading to the resource error you get.  You need to make this a retriggerable *single* pulse and you do that by entirely removing the call to DAQmx Timing.
  2. More about your ctr0 task.  It appears you're configuring high time and low time to be equal and not configuring initial delay at all.  You'll probably need to be more selective about the values you configure for these properties to get the behavior you want.
  3. Your ctr1 task.  The pause trigger source should be "/Dev1/Ctr0InternalOutput" instead of the (extremely brief) change detect signal. 

That's all the time I've got now.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 10 of 14
(4,313 Views)