Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I generate multiple waveforms efficiently?

I posted it in another board by mistake, I post it here again.

I am using PXI-6561 to generate and acquire waveforum in my application. Channel 0 is used to generate fixed rate clock, channel 1 is to generate control command, channel 2 to 7 are to acquire data. I have 10 different groups of commands, I save them as mywfm0 to mywfm9 by waveform editor, each waveform file contains clock and command signals.

Here is my questions: how can I control the waveform generation flexibly? For example, in front panel, if I run the application, it will generate waveform mywfm0 continuously, when I click "generate waveform mywfmX (X=1..9)" button, it will generate mywfmX ONCE, then continue to generate mywfm0 repeatly.

I considered to use script and software trigger to control different waveform generation, but I can only have up to 4 different software triggers in script, which is less than what I need.

Another solution is to use a while loop and case structure, but in each case, I have to write different waveform to board, which will introduce some software delay.

Is there anyway I can download all of waveforms into memory once, label each waveform in memory, by default it will generate mywfm0 repeatly, whenever a button pushed, it will generate the corresponding waveform once, then go back to mywfm0 again.

Thank you very much. Please let me know if my description is too confusing.

Regards,

chc

0 Kudos
Message 1 of 7
(3,364 Views)

You can load all waveforms using write named waveforms into the memnory on your 6561.

As for generate a particular waveform based on click of a button, you may want to look at a different way to generate the clcok (CLK OUT?). Do you have to have the clock "off" while you generate other commands?

0 Kudos
Message 2 of 7
(3,347 Views)

Hi CT,

Thank you very much for your reply.

Actually in my application the clock has to be ON when I generate other command, the best situation is the clock is always on, I just change different command signal. If I can control clock and command individually, that would be great, but seems it is not easy to do. The hardware design has finished, which means I have to use channel0 to generate clock.

With your suggestion, I can write all of the waveforms into on board memory, the system will run mywfm0 (which just generate clock and idle command) repeatly by default, but how can I generate different waveform ONCE when I click different button, after that the system will continue to run mywfm0 repeatly?

0 Kudos
Message 3 of 7
(3,337 Views)
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 seperate waveform, we can use all four of them in combination to create a truth table. Four script triggers, each having two states (asserted, de-asserted), means that there are 16 possible combinations of trigger states for the four script triggers. 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
 
And 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
  .<etc>
  .<etc>
end loop

Now, to actually create a script to do this is a little tricky.  You can't use an AND command in the IF/Else statements. Therefore you will need to use embedded if/else statements. Also, the script triggers can not all be asserted simultaneously, therefore some type of synchronization trigger will be required. So I'll demonstrate how to first do this using only 8 different waveforms, 3 script triggers, and 1 script trigger for synchronization.
Message 4 of 7
(3,337 Views)

<sorry, had to split into two posts>

We'll use the truth table above for the the first 8 waveforms, but only use the values for triggers 0, 1, and 2. ScriptTrigger 3 will be used as a synchronization signal. When ScriptTrigger 3 is asserted, we can be gauranteed 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

Now in the LabVIEW application, you will need to assert scriptTriggers 0, 1, and 2 first, then set scriptTrigge3.   For example, if you want to generate myWfm2, then assert triggers 0 and 2 first, then assert trigger 3. Use the "niHSDIO send softare trigger.vi" to assert the triggers.

I've included a LabVIEW VI that demonstrates how to do this with 8 waveforms. In your case you need more than eight, so you will not be able to use scriptTrigger3 as the sync trigger because you'll need all four to fill out your truth table. So instead, you can 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"
    .
    .
    .

Oh, I almost forgot. You will need to have a generate statement before each If/Else statement in order to not get a HSDIO error.  I didn't show that above because it would have made the script even more difficult to read (it is already hard enough to read). So before each if statement add "generate myIdleWaveform".

Good Luck.

 

Message 5 of 7
(3,336 Views)
Hi JaredW,

Very nice idea, thank you very much for your reply. I will try it out as soon as possible and post test result.

What I did today is to write 10 named waveforms into onboard memory, then generate myIdleWaveform continuously, followed by a while loop in which I use a case structure, whenever I press button, it will generate corresponding named waveform ONCE, outside the case structure, I put another generate myIdleWaveform repeatly.

My VI runs OK, but there is a potential problem is whenever I switch named waveform, there is software/configuration delay, in the mean time, the clock signal is stopped, for later test, this might cause potential problem.

Seems your solution is more promising, thanks a lot.
0 Kudos
Message 6 of 7
(3,332 Views)
Hi JaredW,
 
Thank you very much, I tried your solution, it works very well. The only thing is I have to set the Idle waveform a little bit longer (more samples) since I am using 100MHz sampling clock.
Message 7 of 7
(3,305 Views)