07-03-2010 03:58 AM
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
Solved! Go to Solution.
07-03-2010 04:03 AM
Sorry, I forgot to save my VI before I attached it. This post contains the correct VI.
07-03-2010 10:34 AM
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.
07-03-2010 11:31 AM
@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.
07-03-2010 11:43 AM
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?
07-03-2010 12:03 PM
I did not get a very clear impression either, just a wild guess.... 😄
07-03-2010 02:58 PM
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.
07-03-2010 03:00 PM
@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.