09-09-2021 11:31 AM - edited 09-09-2021 11:33 AM
I'm using a PXIe-5672 controlled by the RFSG VIs in LabVIEW as an arbitrary waveform generator (AWG) and am wondering how to achieve the following:
Say I have two waveforms A and B and I want to start by generating A and then switch to generating waveform B on receipt of a trigger. This is easy if both A and B are pre-defined waveforms in the LabVIEW code. However my waveform B is not pre-defined - it will be determined by measurements taken while the AWG is generating waveform A. The waveform needed will be different for each run of my experiment. It is vital that we switch directly between the two waveforms, there can be no pause between them.
Using LabVIEW, I'm struggling to come up with a way that I can input the waveform data for B while the AWG is still producing waveform A. Does anyone know if this is possible and, if so, what is the best way to achieve it?
Thanks
Solved! Go to Solution.
09-09-2021 11:37 AM - edited 09-09-2021 11:38 AM
Nope literally not possible. You need sufficient time to make the measurement and generate the waveform, this has to be between A and B.
Even if you implement this on an FPGA, you need some clock ticks before to analyse and make a decision. Only possible if things are all Analog.
Edit: or maybe I am misunderstanding, can you provide more details with actual test specifics instead of generalizing.
09-09-2021 11:40 AM
Perhaps I should clarify: the measurement and generation of waveform data for waveform B can be done externally to the code that controls the AWG. It's just the upload of the waveform data for B to the AWG that needs to occur while A is running.
09-09-2021 12:00 PM
That may be a problem, the issue is that the AWG can do one thing at a time, since it is already busy generating a waveform, it may not be able to load the waveform B onto memory.
Can you give examples in terms of durations of A and B and when exactly B becomes available during the generation of A?
I hope that there is still a way if you can allocate a memory buffer equal to the size of B ahead and write to the buffer directly so that AWG is not disturbed from generating A.
09-09-2021 12:17 PM
It may be possible with 2 caveats.
1. You can loop you’re A and B waveforms until you call your trigger to switch. Otherwise, you have the issue of erroring out due to waveform underflow to the DACs when running out of samples while waiting for the new waveform to be measured and calculated.
2. The module supports the downloading a new waveform while in generation mode. Not all modules do.
The idea is to create a script (running in Script Mode) that uses two waveform spaces that are allocated up front with same size waveforms (not exactly required but makes future waveforms easier). The script will use a repeat forever outer loop. Each Waveform will have a repeat until trigger loop. Script starts out generating waveform A in a continuous loop. While that is happening, create your B waveform and download to the B waveform handle. Send the script trigger so that looping A waveform stops and starts looping on waveform B. The next step is the same, except now you download to waveform A, and then send the trigger to stop B from looping, and the script goes on to generate A in a loop. And so on.
If the module lets you download on the fly, there is an RFSG VI (niRFSG Set Arb Waveform Next Write Position.vi) that you can use to set the write position to the beginning of the waveform, or sample zero. Then download the new waveform to the existing A or B memory space. The waveforms need to be the same size, or you will get extra samples from a previous waveform being generated, or you get an error trying to write too many samples for that waveform.
09-09-2021 12:19 PM
I haven't tried it, but I think that you can write to a waveform by name even after generation has started. You allocate the memory first and then write to it as you need to. For reference this is how "streaming" is done: https://zone.ni.com/reference/en-XX/help/371025V-01/rfsg/streaming_waveform_data/
I think this is what Santhosh is describing. As long as you're not playing the waveform that you're writing to and you don't need to change the size of the waveforms after initiate, you should be ok.
09-09-2021 12:23 PM
Yep--Jerry beat me to it.
One more thing to add: the waveforms need to complete before they can switch. For instance, if you have a 10 msec waveform and the trigger is received just as the waveform starts, the waveform won't switch until 10 msec later.
09-10-2021 12:13 PM
Thank you all for your helpful replies - I think these are exactly the sorts of solution I need.