LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ Trigger

Hi everyone,

 

I've created a program (attached) where I generate an analog waveform with LabVIEW and send it out using a DAQ card. Now, I would like to simultaneously generate a trigger (square pulse) that starts at the same time and has the same frequency as the waveform.

 

Do you have any advice on how to do this? (I can use both analog and digital outputs)

 

Thanks,
Mauro

0 Kudos
Message 1 of 8
(539 Views)

Good morning, Mauro.

 

Thank you for attaching your VIs.  Many Forum users (myself, included) are not running the latest version of LabVIEW, and cannot open LabVIEW 2024 files.  Can you please save your top-level VI using "Save for Previous Version" and specify LabVIEW 2019 or 2021?  Also, can you please specify the DAQ card you are using, so we can see what "trigger" capabilities it might have.

 

Bob Schor

0 Kudos
Message 2 of 8
(528 Views)

Hi Bob thanks for your reply,


I am using a DAQ NI USB6341. Attached please find the program converted to .21 version (I hope it works)

 

Mauro

0 Kudos
Message 3 of 8
(522 Views)

Now that I can see your code, and I can see what kind of device you are using, I can suggest several things to try.

 

It appears (to me) that you have written something that outputs a selected waveform based on an un-named cluster called "Cluster" (the name is hidden, almost always a Bad Beginner Practice).  Instead of writing the "most general case", I recommend writing a smaller, neater (keep the wires has horizontal and straight as possible, always use the Error Line to connect sequential VIs, make sure you can "see the flow of data" (don't hide wires, "branch around" where needed).

 

Simplify the code to make a Sinusoid.

 

Just below that, write code to make a Square Wave.  Use the same Frequency for both.  The Sinusoid goes to an Analog Out.  The Square Wave can also go to an Analog Out, or to a Digital Out.

 

It may sound silly, but writing "neat" LabVIEW code is a skill that pays off in code that "does what you want", rather than code that "does what you said" (but since you can't read/understand it, you don't realize you told it to do the "wrong thing" ...).

 

Bob Schor

0 Kudos
Message 4 of 8
(489 Views)

Thanks for the advice, I was able to generate an analog trigger (square pulse) by simply creating a second waveform to another analoguic channel. The problem now is that by using two analog channels I am forced to decrease the sampling rate and this leads me to a worse signal.

 

So now I would like to implement the trigger digitally and my main problem that I have no idea how to generate a digital pulse and specify its period and duty cycle...

 

Mauro

0 Kudos
Message 5 of 8
(455 Views)

I've never used the Digital Pattern Generator VI in the Waveform Palette, but it has a "Toggle" Pattern Generator that will let you generate a digital pattern of 0, 1, 0, 1, 0, 1 ... for a specified number of samples at a specified Sample Rate (which you would set to two times the frequency of your sinusoid, which should be much lower than the sampling frequency of that sinusoid.

 

Then you "only" have the issue of getting the 6341 to generate an Analog waveform with one sampling rate and a digital waveform with another (don't know if this is possible!).  Alternatively, you might be able to run the Analog (one-channel) and Digital (also one-channel) outputs with the same clock, in which case your digital Waveform have to be at the same sampling frequency as your analog one (i.e. 000000111111000000111111).

 

Hope that gets you started, or that someone reading "knows more than I" (that's a pretty low bar!) and feels like sharing.

 

Bob Schor

0 Kudos
Message 6 of 8
(443 Views)

Thanks for the reply, I managed to generate the digital signal now all I have to do is synchronize them being that they start random and not with the same clock...slowly I am getting to the solution!

 

Mauro

0 Kudos
Message 7 of 8
(435 Views)

@Bob_Schor wrote:

Now that I can see your code, and I can see what kind of device you are using, I can suggest several things to try.

 

It appears (to me) that you have written something that outputs a selected waveform based on an un-named cluster called "Cluster" (the name is hidden, almost always a Bad Beginner Practice).  Instead of writing the "most general case", I recommend writing a smaller, neater (keep the wires has horizontal and straight as possible, always use the Error Line to connect sequential VIs, make sure you can "see the flow of data" (don't hide wires, "branch around" where needed).

 

Simplify the code to make a Sinusoid.

 

Just below that, write code to make a Square Wave.  Use the same Frequency for both.  The Sinusoid goes to an Analog Out.  The Square Wave can also go to an Analog Out, or to a Digital Out.

 

It may sound silly, but writing "neat" LabVIEW code is a skill that pays off in code that "does what you want", rather than code that "does what you said" (but since you can't read/understand it, you don't realize you told it to do the "wrong thing" ...).

 

Bob Schor


I always compare sloppy LV code to writing text based code with random indents.  The compiler doesn't care, but if a developer was stomping about the office yelling for the idiot who wrote that code, I'd point them in the direction of the offending dev and just ask the angry person to give me time to leave before doing anything reportable.

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 8
(414 Views)