LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible to modify data on the fly?

Solved!
Go to solution

example_modify_data.png

I have two similar programs, which have been running fine:

  1. The first program (upper block) has an input of five element array. Whenever an external trigger comes in at PFI0, it outputs the five values in order, and stops and waits for next trigger.
  2. The second program (bottom block) also have a five element arrays as input. However when an external trigger comes in at on PFI0, it will start outputting the five numbers over and over.

(Note that you have to disable one of the blocks above to make the program run. I just stitch them together here.)

 

Now I wanted to add a little tweak to those two programs. On the top of diagram, I added a Dial, which I hope to allow users to add some offset to the the input array. However it does not work. It seems that once the data has been sent to the card, one could not change it. I am looking for suggestions.

0 Kudos
Message 1 of 6
(2,931 Views)

Well, you've discovered that once you've started a AO Task that has the data, just waiting for a Trigger, you are "committed".  But under some circumstances, you can "have your Cake and Eat it,too".

 

Here's the deal -- when you get the changed input Event that says "Oops, I need to adjust the output Waveform", do the following:

  1. Stop the Task!
  2. Re-define the Task, meaning re-write the Input array and restart the Task.

There is, of course, a possibility that you will change the offset just as the (asynchronous) Trigger fires, but that is a "low probability" event, and not much you can do about "bad timing".  If your Triggers come somewhat periodically, then you might just (rarely) miss a trigger.

 

Bob Schor

Message 2 of 6
(2,887 Views)
Solution
Accepted by topic author joehsiao

volt_change_on_the_fly.png

 

Those are solutions that I came up.

Thanks, Bob. 

0 Kudos
Message 3 of 6
(2,851 Views)

Are those array operations for real, or just to simulate something?

Instead of building an array of 5 constants, you can just use an array constant.  Or even use the Ramp function built into LabVIEW.

And you don't need to create an array of the 5 values from the control.  Initialize Array would have been one step better.  But you don't need an array for that.  You can add a scalar to an array.

 

Example_VI_BD

0 Kudos
Message 4 of 6
(2,841 Views)

@ 

The values in the array are actually obtained by parsing a .csv file earlier, so I couldn't use a constant array for them. (or maybe I could?)

The idea of adding a single scalar to the array is awesome!

0 Kudos
Message 5 of 6
(2,814 Views)

It doesn't matter where they come from.  The constants shown are just to give simple example of how numeric functions can handle arrays.

0 Kudos
Message 6 of 6
(2,811 Views)