10-31-2012
03:17 PM
- last edited on
11-01-2012
09:11 AM
by
MaryH
Hello.
How correctly to write the script for switch between different waveforms during generation?
For example:
We are using the niFgen Allocate Named Waveform VI for allocate three Waveforms. When you run Generator, working first Waveforms. Next, the Generator is switched and used in the following only second and third Waveforms.
Or, we configured 10 Waveforms, and in the process of generating to switch not cyclically between all, but only between 2 and 5 Waveforms.
Whether it is possible to realize?
Max O.
Engineer and software developer,
TeSLa.
Solved! Go to Solution.
11-01-2012 03:35 AM
And switch between the waveforms need by a trigger.
Max O.
Engineer and software developer,
TeSLa.
11-01-2012 11:44 AM
Hi Max,
You will want to have a different Script Trigger name for each waveform you want to trigger. You should then use the if/else/end if instruction to check for each trigger inside a repeating loop. For example:
if scriptTrigger0
generate myWfm0
else
if scriptTrigger1
generate myWfm1
//nested "else if"s for each trigger/waveform you need
end if //remember to have an "end if" for each "if" instruction
end if
Please refer to our help documentation on scripting for further information on how to write scripts for your arb in order to accomplish what you need.
Regards,
11-01-2012 03:37 PM
Thanks for the help, Chris.
So, to switch in any order between 5 waveforms need 5 triggers and the following script?
if scriptTrigger0
generate myWfm0
else
if scriptTrigger1
generate myWfm1
end if
if scriptTrigger2
generate myWfm2
end if
if scriptTrigger3
generate myWfm3
end if
if scriptTrigger4
generate myWfm4
end if
end if
Regards,
Max O.
Engineer and software developer,
TeSLa.
11-01-2012 04:13 PM
Hi Max,
Each steps needs an else, too. The end ifs should occur at the end. For example:
if scriptTrigger0
generate myWfm0
else
if scriptTrigger1
generate myWfm1
else
if scriptTrigger2
generate myWfm2
else
/etc...
end if
end if
end if
Of course, this should all be wrapped in a repeating structure to continue checking for triggers.
Regards,
11-01-2012 04:46 PM - edited 11-01-2012 04:48 PM
Hi Chris,
What right?
repeat forever
if scriptTrigger0
generate myWfm0
else
if scriptTrigger1
generate myWfm1
else
if scriptTrigger2
generate myWfm2
else
if scriptTrigger3
generate myWfm3
else
if scriptTrigger4
generate myWfm4
end if
end if
end if
end if
end if
end repeat
or
repeat forever
if scriptTrigger0
Repeat until scriptTrigger0
generate myWfm0
end Repeat
else
if scriptTrigger1
Repeat until scriptTrigger1
generate myWfm1
end Repeat
else
if scriptTrigger2
Repeat until scriptTrigger2
generate myWfm2
end Repeat
else
if scriptTrigger3
Repeat until scriptTrigger3
generate myWfm3
end Repeat
else
if scriptTrigger4
Repeat until scriptTrigger4
generate myWfm4
end Repeat
end if
end if
end if
end if
end if
end repeat
Regards,
Max O.
Engineer and software developer,
TeSLa.
11-01-2012 05:24 PM
Hi Max,
I am not sure what you mean by "right". Both scripts are valid. Each one will allow you to use a trigger to select which waveform is generated.
The first script you posted will generate waveformX with triggerX once and then wait for another trigger before generating anything again. The second script will continously generate waveformX when triggerX is received until triggerX is sent again, at which point generation will stop and the device will await another trigger to resume generation.
Regards,
11-02-2012 10:11 AM
Hi Chris,
Possible that the its scripts and came to use (though I now doubt), but with instruction the if/else/end ifmust be preceded by a generate or wait <N> instruction.
In this case, if we add generate or wait <N> instructions to this script to get Abra-Cadabra some kind.
Clarify, what is necessary:
When starting is not pressed any triggers that generate a waveform0 continuously.
Further, if we passed to the niFgen Send Software Edge Trigger VI - single the triggerX, begin to generate a waveformX continuously.
These scripts do not provide the necessary algorithms:
May be I do not fully understand the scripts work.
How to ensure continuous generation waveformX by a single sent of the triggerX?
Please, prompt.
Regards,
Max O.
Engineer and software developer,
TeSLa.
11-02-2012 10:46 AM
Hi Max,
You are correct that you need to precede the script I provided with a generation or wait.
There is no way to send scriptTriggerX to generate waveformX, and then run this continuously until another arbitrary trigger comes in to change to a new waveform. You must specify in your repeat until instruction a specific trigger that allows the script to leave the continuous generation loop. There are two good ways to implement this in my opinion; send scriptTriggerX once to start waveformX and then send scriptTriggerX again to stop waveformX, at which point you can send any new trigger to start a new waveform; or send scriptTriggerX once to start waveformX and then send a generic stopTrigger that you use to stop any running waveform in order to exit the repeat until structure.
The functionality you are asking for is quite straight-forward to implement on a function generator, as we briefly discussed in this thread. The difficulty you are having here, I believe, is a result of the use cases for which arbitrary waveform generators are designed to be used. The application requirements you have described to me thus far are a great fit for a function generator, and a very difficult implementation for an arbitrary waveform generator. I would strongly recommend considering the procurement of a function generator for this application because I believe the time it is taking to do this is likely costing more than the price of a new function generator. If you are interested, I can get you in touch with your account representative.
Regards,
11-02-2012 11:42 AM
Hi Chris,
Oh, I think I understand you.
Is obtained that the second script is quite suitable?
But, interesting second version offered by you.
Can write it?
And thanks for the suggestion!
Regards,
Max O.
Engineer and software developer,
TeSLa.