Signal Generators

cancel
Showing results for 
Search instead for 
Did you mean: 

Smoothly transition from streamed waveform to scripted waveform in a script with triggers

Hello,

 

I'm working on an application in which I need to, within a script written onto a NI 5451 arbitrary waveform generator, smoothly transition from a streamed waveform to a pre-written scripted waveform. For example,

 

script myScript
repeat until trigger
generate waveform1
end repeat
generate waveform2
generate www10000 (<-- streamed waveform which smoothly transitions to -->)
generate waveform 4
end script

 

(strictly speaking there will be some repeats and triggers in here, but details)

waveforms 1, 2 and 4 I know ahead of time, but the streamed waveform will not be, and hence it must be streamed.

 

I've made good progress off of examples & discussions on this site, for example 

https://forums.ni.com/t5/Signal-Generators/Waveform-streaming-and-waveform-scripting-Mutually-exclus...

and 

https://forums.ni.com/t5/Example-Programs/Fgen-Arb-Waveform-Streaming-with-Script-Mode/ta-p/3502366

 

but both of these examples end with the scripted waveform. Effectively I want to tell my generator that my waveform will be XXX samples long, and after those samples I want it to continue to the next waveform, which will be written to the generator before the script starts. I'd love to just use the "stream n" script command, but according to http://zone.ni.com/reference/en-XX/help/370777G-01/niscripted/streamn/ using "stream n" is incompattible with "repeat until ScriptTrigger" lines, the "break" statement seems similarly limited. Is there any way to achieve this smooth transition effect?

 

Some application details...

I'm using the AWG output as part of a feedback system. The streamed waveform is the feedback. I learn what the feedback waveform needs to be only after the script starts, so I can't pre-program it. It's actually not a size thing, the waveform won't be that long, I just can't pre-program it for this reason. I need the output of the AWG to be continuous, so I can't stop the AWG, program the waveform I want to stream, and restart a new script either. I'm running my 5451 at a high sample rate of 350 MS/s, so it's not practical for me to stream everything after the streamed waveform either. In tests I've been able to go from scripted waveforms to the streamed waveform smoothly, but the 5451 output just stops & throws errors after the data I've written to it for the streaming waveform finishes.

 

Thanks for any help!

0 Kudos
Message 1 of 2
(3,147 Views)

I fixed my problem. It turns out that I was mis-understanding exactly what is special about streaming waveforms.

 

The solution is to allocate memory for a normal waveform, don't write anything to it, start the script generation, and then write the normal waveform data after I know what data to write.  I didn't think this was possible previously, I thought normal scripted waveforms had to be pre-allocated.

 

I had previously thought that there were two things that were special about streamed waveforms: (a) that they could in principle be very long, and (b) that they could be written in real-time, while a script was running. I didn't care about (a), and I only wanted (b) for my application, but it turns out that (b) is true for all waveforms.

 

I suspect the documentation for these things could be amended to clarify some of this... but anyways, problem solved.

0 Kudos
Message 2 of 2
(3,117 Views)