LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set Value To Indicator Only Once

Solved!
Go to solution

Hello,

 

I am relatively new to LabVIEW, so I am wondering if you could give me hints as how to accomplish one task.

 

I am trying to store the timestamp at which a signal caused a "Trigger and Gate" block to trigger. I've attached my current attempt at doing this. The idea is basically to wait for the triggered signal to come out and store the "t0" component of it inside an indicator. The problem is that after I store the t0, the while loop iteration completes. For the next iteration, new data comes. Since the trigger is already triggered the previous iteration (there is no stop trigger), this new data's own t0 will be then written to the indicator. But that is not what I want. Is it possible to only write the data to an indicator if it does not contain a value already? 

 

My plan in the end is to take the blocks starting from the trigger and on (see the picture I attached) and create a subVI from it. The data source will be outside of the SubVI, so I can connect different sources to it during testing. This means (as far as I can tell), that the subVI does not know that it is embedded inside a loop, so I won't be able to use features of a loop (ie: shift registers) to solve my problem.

 

Do you have any suggestions as to what I should try?

 

Thank you!

 

PS: The computer that the final code will run on has LabVIEW 8.6

Download All
0 Kudos
Message 1 of 8
(4,579 Views)

Sorry, I forgot to save my VI before I attached it. This post contains the correct VI.

0 Kudos
Message 2 of 8
(4,577 Views)

You need to enclose your update of the indicator withing a case structure. You want to control the action of the case structure on 2 conditions: has the triffer occurred, and whether you've already updated the indicator. The latter can be handled with a shift register. See attached VI for the basic idea.

0 Kudos
Message 3 of 8
(4,559 Views)
Solution
Accepted by topic author kkrizka

 


@kkrizka wrote:

Is it possible to only write the data to an indicator if it does not contain a value already? 


 

Place the indicator insde the true case of a case structure and wire the "first call?" primitive to the selector terminal.

 

Message 4 of 8
(4,554 Views)

I didn't get the impression from reading the post that it would happen on the first call or the first iteration, but perhaps I misread the post?

0 Kudos
Message 5 of 8
(4,549 Views)

I did not get a very clear impression either, just a wild guess.... 😄

0 Kudos
Message 6 of 8
(4,540 Views)

Thank you very much. That did exactly what I wanted it to do! I've attached the working VI.

 

The trigger would not occur in the first iteration of the loop. So I just put the "First Call?" primitive into a case structure that was evaluated when the "Data Available" output of the "Trigger and Gate" block. That way the "First Call?" was true when the trigger fired for the first time. 

0 Kudos
Message 7 of 8
(4,527 Views)

 


@smercurio_fc wrote:

You need to enclose your update of the indicator withing a case structure. You want to control the action of the case structure on 2 conditions: has the triffer occurred, and whether you've already updated the indicator. The latter can be handled with a shift register. See attached VI for the basic idea.


I though about that too. But the problem is that the SubVI that I will build later on to put the code in will not know about the enclosing while loop.

 

0 Kudos
Message 8 of 8
(4,526 Views)