Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated  Rate this Document

Multiple Script Triggers with HSDIO

Primary Software: Driver Software>>NI-HSDIO
Primary Software Version: 1.4
Primary Software Fixed Version: N/A
Secondary Software: N/A
Hardware: Digital I/O (DIO)>>High-Speed

Problem:
I am trying to generate multiple waveforms on my HSDIO device with the use of scripting and software triggers. However, I am limited to 4 triggers, and I need to generate more than 4 waveforms. What can I do?

Solution:
You can still use a script with software triggers to switch between your different waveforms. Instead of using each script trigger as a latch for a separate waveform, we can use all four triggers in combination to create a truth table. Four script triggers, each having two states (asserted, de-asserted), there are 16 possible combinations of trigger states. Here is an example truth table.
 
               ScriptTrigger0  ScriptTrigger1  ScriptTrigger2  ScriptTrigger 3
myWfm0          T                     T                    T                    T
myWfm1          F                     T                    T                    T
myWfm2          T                     F                    T                    T
myWfm3          F                     F                    T                    T
myWfm4          T                     T                    F                    T
myWfm5          F                     T                    F                    T
myWfm6          T                     F                    F                    T
myWfm7          F                     F                    F                    T
.
.
.
myWfm15         F                    F                    F                    F
 
In psuedo code terms, you would create a script as follows:
 
Loop forever
  generate myIdleWaveform
  if ScriptTrigger0 AND ScriptTrigger1 AND ScriptTrigger2 AND ScriptTrigger3
     generate myWfm0
  if ScriptTrigger1 AND ScriptTrigger2 AND ScriptTrigger3
     generate myWfm2
  .
  .
end loop

Since the AND command cannot be used in If/Else statements, the actual script becomes slightly more complicated. You will need to use embedded If/Else statements. Since the script triggers can not all be asserted simultaneously, a synchronization signal will be required. The following is a demonstration of how to first do this using 8 waveforms, 3 script triggers, and 1 script trigger for synchronization.

The truth table will be similiar to the one above for the first 8 waveforms. Keep in mind, we are only using the values for triggers 0, 1, and 2. ScriptTrigger 3 will be used as a synchronization signal. When ScriptTrigger 3 is asserted, we can gaurantee that scriptTriggers 0, 1, and 2 have all been set (none are in a changing or unknown state).

script myScript
  repeat forever
    generate myIdleWaveform   \\ this is the waveform you want to always have running
    if scriptTrigger3         \\  if True, then we can read all of the triggers
      if scriptTrigger2
        if scriptTrigger1
          if scriptTrigger0
            generate myWfm0   \\ T, T, T case
          else
            generate myWfm1   \\ F, T, T case
          end if
        else
          if scriptTrigger0
            generate myWfm2   \\ T, F, T case
          else
            generate myWfm3   \\ F, F, T case
        end if
      else
        if scriptTrigger1
          if scriptTrigger0
            generate myWfm4   \\ T, T, F case
          else
            generate myWfm5   \\ F, T, F case
          end if
        else
          if scriptTrigger0
            generate myWfm6   \\ T, F, F case
          else
            generate myWfm7   \\ F, F, F case
        end if
      end if
    end if //end of start trigger event
  end repeat
end script

Note: You will need to have a generate statement before each If/Else statement in order to not get a HSDIO error. This wasn’t shown above because it would have made the script even more difficult to read. So before each if statement add "generate myIdleWaveform".

Now in the LabVIEW application, you will need to assert scriptTriggers 0, 1, and (or) 2 first, then set scriptTrigger3.   For example, if you want to generate myWfm2, then assert triggers 0 and 2 first, then trigger 3. Use the "niHSDIO send software trigger.vi" to assert the triggers.
Attached is a LabVIEW VI that demonstrates how to implement this with 8 waveforms. If more than eight waveforms are necessary, you will not be able to use scriptTrigger3 as the synchronization trigger (all four triggers are needed to generated more than 8 startes). If this is the case, you can still use a startTrigger event in place of scriptTrigger3.

script myScript
  repeat forever
    generate myIdleWaveform
    if startTrigger   \\ this is asserted using the "send software edge trigger.vi"
    .
    .
    .


Related Links: HSDIO Seamless Waveform Switching Using Multiple Triggers Example

Attachments:





Report Date: 07/31/2006
Last Updated: 08/30/2006
Document ID: 3ZUBL2JQ

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit