12-20-2019 05:14 PM
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.
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:
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.
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).
Let me know if you have any ideas! Thanks.
12-20-2019 05:22 PM
I might have figured it out! Of course, right after posting here ;). This seems to work!
Would like to see anyone else's ideas.
12-21-2019 08:24 AM
Welcome to the World of Code Review. You have just discovered the "Rubber Ducky" method, which can be summarized as follows:
Bob Schor
12-23-2019 02:52 PM
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.