LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arbitrary Waveform Generator with Script Output Mode - Need to Display a Marker with a Trigger While Switching Between Waveforms

Hi, I am currently using NI PXIe-5450. Output mode is configured to script. I've created two waveforms that are downloaded to AWGs memory. I've configured a script digital edge (rising edge) trigger with an external source (into PFI0) and use the following script.

thej178_2-1576882826078.png

Using a function generator set to a pulse hooked up to PFI1, when I press trigger, my waveform changes from waveform 1 to waveform 2. Pressing again, it changes from 2 to 1. My program and setup works just as I needed it to. I now need to generate a marker every time a hardware trigger is received but I am having a hard time with the syntax. I browsed some NI Fgen Signal Generator Help like Common Scripting Use Cases and Scripting Instructions which helped but I wanted to see if anyone could help brainstorming or has any ideas/solutions. With the script below:

thej178_3-1576882858860.png

you get a marker every time the waveform is repeated while waiting for the trigger, we only need one marker when the script trigger is received. We've been able to sort of cheat by only adding this marker to the second waveform (below), this way we can distinguish with a marker exactly when we switch to the second waveform and thus when the hardware trigger was received.

thej178_4-1576882930799.png

I'd like for this script to achieve something like:

- generate waveform 1 until trigger is received

- once trigger is received, generate waveform 2 with a marker at the beginning and then continue generating waveform 2 without a marker.

- once trigger is received, generate waveform 1 with a market at the beginning and then continue generating waveform 1 without a marker and repeat

 

I've tried a few things that didn't work. I've been looking through the scripting instructions, like repeat/end repeat etc. to try things, but usually my ideas don't work due to a syntax error.

(Example: I tried generating a marker using repeat once, generate marker. This is an issue because you can't only generate a marker. A marker must be generated with a waveform).

thej178_5-1576883616030.png

Let me know if you have any ideas! Thanks.

0 Kudos
Message 1 of 4
(4,467 Views)

I might have figured it out! Of course, right after posting here ;). This seems to work!

Would like to see anyone else's ideas.

thej178_0-1576884143450.png

0 Kudos
Message 2 of 4
(4,453 Views)

Welcome to the World of Code Review.  You have just discovered the "Rubber Ducky" method, which can be summarized as follows:

  1. You have a problem with your code.  You've looked over it, and can't see why it doesn't work.
  2. You want to describe it to a colleague, one (you hope) is an "expert" who can easily see what you did wrong.
  3. No such colleague is available.  So you:
    1. Find a Student, a Spouse, an Offspring (who may be far more computer-literate than you!), or
    2. You get a Rubber Ducky and put it on the desk in front of you.
  4. You explain what you are trying to do to your "consultant".  Since they don't know anything about the issue, you (of course) must begin by giving them the high-level (what my wife calls "the 30,000 foot") view of the problem.
  5. Then you get "into the weeds" (details).  And you say "Oops, I think I see the problem, I ..." (with me, it is often "I forgot to wire something-or-other").

Bob Schor

Message 3 of 4
(4,318 Views)

Hi, yeah, I realized that's what happened. I've tried talking myself through it prior and talked to a coworker but it lead nowhere, but turns out a few minutes after posting this it clicked. Hopefully this will help someone else in the future.

0 Kudos
Message 4 of 4
(3,672 Views)