Signal Generators

cancel
Showing results for 
Search instead for 
Did you mean: 

fastest way to transition from a complex script to a known constant voltage level

What is the fastest way to transition from a complex script already using markers and triggers to a known constant voltage level on the 5421 using c functions?
Is it to load a second script in advance with a single voltage level and activate it using the following 3 steps?
    -niFgen_AbortGeneration
    -Set NIFGEN_ATTR_SCRIPT_TO_GENERATE attribute to the single voltage script
    -niFgen_InitiateGeneration

How long should these 3 steps take?

 

Is there a faster way?

0 Kudos
Message 1 of 9
(7,867 Views)

tomkor,

 

I believe that the fastest approach involves embedding the DC Generation script into the script that you have at the moment.  You could allow this part of the script (DC Generation) to start at a specified script trigger and generate a pre-made DC waveform forever.  The script that exhibits this behavior is as follows:

 

  Wait until scriptTrigger0
  Generate DCwfm 

  Repeat Forever

 

Could you attach the script that you have at the moment to clarify the issue further?   

0 Kudos
Message 2 of 9
(7,853 Views)

tomkor,

 

I made a mistake in my last post concerning the repeat forever in the script. The script should look as follows:

 

wait until scriptTrigger0

repeat forever

generate waveform

end repeat

 

Hope this helps.

0 Kudos
Message 3 of 9
(7,842 Views)
At the end of a script, the generator should maintain the DC level of the last sample of the last waveform it was generating.  So you don't even need to loop forever on the DC waveform.
0 Kudos
Message 4 of 9
(7,839 Views)

 

The desired behavior is to execute the complex script, until an external software event occurs.

Wait until script trigger will not continue to execute the script, it will stop at a single value.

 

0 Kudos
Message 5 of 9
(7,825 Views)

tomkor,

 

I have listed another idea, below, that you may wish to use.  The "repeat until scripttrigger" should be able to constantly loop over your complex script until the appropriate software edge occurs. 
   
repeat until scripttrigger0
        <place your complex script here>
    end repeat

         generate DCwaveform

 

As psisterhen had suggested, "the generator should maintain the DC level of the last sample of the last waveform it was generating" is absolutely true.  You would only want to use the repeat forever with the DC waveform if you would like to control when the generation ceases.  Please let me know if you have further concerns. 

0 Kudos
Message 6 of 9
(7,815 Views)

The script can take many seconds to complete a repeat cycle. I am interested in interruping and transitioning to the DC level in the shortest time.

The repeat until won't interrupt until completion of an entire multisecond cycle.

 I expect that niFgen_AbortGeneration is an immediate termination. But I'm trying to get a feel for how long it would takefor the 3 steps:

    -niFgen_AbortGeneration
    -Set NIFGEN_ATTR_SCRIPT_TO_GENERATE attribute to the single voltage script
    -niFgen_InitiateGeneration

And    Is there a faster way to achieve this transition in less time?

 

 

0 Kudos
Message 7 of 9
(7,787 Views)

The easiest way to transition to a known DC value after a generation is aborted is to use the "Idle Behavior" and "Idle Value" attributes - these are new in NI-FGEN 2.6.  Set NIFGEN_ATTR_IDLE_BEHAVIOR to NIFGEN_VAL_JUMP_TO_VALUE and set NIFGEN_ATTR_IDLE_VALUE to whatever DC level you want, and when generation finishes or is aborted, the output will automatically go to and remain at that level.  So for your application, you could set these attributes and call AbortGeneration to have it transition instantly to the "idle value".

 

NI-FGEN 2.6 can be downloaded from http://www.ni.com (just search for "fgen 2.6" ).

 

As a side note, when AbortGeneration is called, the script will interrupt after the currently generating waveform finishes.  So, if you only have one really long waveform in your repeat cycle, it won't abort until that entire waveform is finished.  But if you have a bunch of small waveforms in your repeat cycle, it will abort immediately after whichever one it is currently on finishes.  This is faster than waiting on a script trigger, which as you correctly stated will only jump out of the repeat loop when it completes the entire cycle.

 

Drew Creel

NI Software Group Manager

Signal Generators Group

 

Drew Creel
NI Software Group Manager
RF and Signal Generators
0 Kudos
Message 8 of 9
(7,780 Views)
Sorry, disregard my last comment about AbortGeneration - it will stop generation (and generate the "idle value" ) immediately, regardless of the current location in a waveform.
Drew Creel
NI Software Group Manager
RF and Signal Generators
0 Kudos
Message 9 of 9
(7,759 Views)