Signal Generators

cancel
Showing results for 
Search instead for 
Did you mean: 

Script to random switch between different waveforms

Solved!
Go to solution

Hi Max,

 

This script you posted looks good to me.  My second suggestion would merely replace all repeat until scriptTriggerX instructions with repeat until scriptTriggerStopWfm or something to that effect (whatever you want to name it).  This way you use the same trigger to stop any waveform being generated (except waveform0).

 

Regards,

Regards,
Chris Elliott
x36772
0 Kudos
Message 11 of 23
(4,110 Views)

Hi Chris,

 

Please tell me, the function niFgen Configure Software Edge Script Trigger VI can work with more than 4 triggers (with twenty, for example)?
And the function niFgen Write Script VI whether limitations by the number of lines in the script?

 

Regards,

Max O.
Engineer and software developer,
TeSLa.

0 Kudos
Message 12 of 23
(4,102 Views)

Hi Chris,

 

In this example, it turns out that Triger0 stops the Waveform1.
And then one runs the Waveform2, but that we should not start again send Trigger0.

Stop and start happening simultaneously?

 

repeat until scriptTriggerX.png

 

Regards,

Max O.
Engineer and software developer,
TeSLa.

0 Kudos
Message 13 of 23
(4,101 Views)

Hi Chris,

 

What is done so that еhe if/else/end if instruction must be preceded by a generate or wait <N> instruction?

Function wait 8 is the number of samples? And what is its minimum possible value?

In the following example, the wait 8 serves as a timeout or it enables after 8 samples to execute the code that follows it?

 

wait 8
 if scripttrigger0
     generate myWfmA
 else
     wait 8
     if scripttrigger1
         generate myWfmB
     else
         generate myWfmC
     end if
 end if

 

Regards,

 

Max O.

Engineer and software developer,

TeSLa.

0 Kudos
Message 14 of 23
(4,091 Views)

Hi max_i,

 

The script editor help file is useful for questions like these, have you had a chance to look through it?  It should save you time instead of waiting for a response from someone on the forums.  From the script editor help file for the "wait" function:

 

"Pause execution of a script. You can pause the script until a particular Script trigger is received or until a specified number of samples are generated."

 

 

Example: (also from help file)

  • Generate the sequence myWfmA, wait 100 samples, then generate myWfmB:
    generate myWfmA
    wait 100
    generate myWfmB

 

Best Regards,

 

David B

National Instruments

Applications Engineer

0 Kudos
Message 15 of 23
(4,083 Views)

Thanks David,

 

I looked through the script editor help file.

But I all the same still have questions.

Than what would happen in a particular example for  "wait 8" function?

 

wait 8
   if scriptTrigger0
      repeat until scriptTrigger0
         generate Waveform0
      end repeat
   else
wait 8
   if scriptTrigger1
      repeat until scriptTrigger1
         generate Waveform1
      end repeat

 

That is, after sending the scriptTrigger0 (or in other words passed software trigger) generation the Waveform0 will begin immediately after sending of a trigger (without delay) or anyway, until after 8 samples generating a new waveform will not start?

And can you answer to my previous question.
What to do if need 20 software triggers, for example?

But the function niFgen Configure Software Edge Script Trigger VI works with 4 triggers.

If exceed this number, we get an error:

 

Error -1074135008.png

 

Regards,

 

Max O.  

Engineer and software developer,  

TeSLa.

0 Kudos
Message 16 of 23
(4,078 Views)

Hi max_i,

 

This code will wait 8 samples and then check for scriptTrigger0.  If scriptTrigger0 is high, then it will generate Waveform0 until it receives scriptTrigger0 again.  If scriptTrigger0 is low, then it will wait another 8 samples, then check for scriptTrigger1.  In summary, if it is in the wait 8, it will wait 8 whether the trigger is sent at that point or not.

 

Best Regards,

 

David B

National Instruments

Applications Engineer

0 Kudos
Message 17 of 23
(4,072 Views)

Ok, thanks.

What about the second question?

About the function niFgen Configure Software Edge Script Trigger VI.


Regards,

Max O.
Engineer and software developer,
TeSLa.

0 Kudos
Message 18 of 23
(4,062 Views)

Hi Max_i,

 

Unfortunately, there are only 4 script triggers available, you cannot use more than that.

 

Thanks,

 

David B

National Instruments

Applications Engineer

 

0 Kudos
Message 19 of 23
(4,051 Views)

Hi,

 

That's a pity!
Why so few?
What to do if need a minimum of 20 triggers?
There are other ways how to implement it (In Script Mode)?

Thanks!

 

Max O.
Engineer and software developer,
TeSLa.

0 Kudos
Message 20 of 23
(4,043 Views)