LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

software controlled event

I have  a problem of generating software triggering of an event. The VI is attached with the post. It in LabView 8

 

Loop # 1 generates an array of 100 random numbers. Now what I want is that "just when the array is complete, It must  trigger the structure below. The array data must be passed to the local varible "Array" in the event structure and is displayed in the waveform graph and Intensity chart.

the event structure must stop then, until the next array values arrives. The process must be as effecient as possible.

Simialarly, Kindly let me also if there is any other effecient way of data transfer in between instead of Local variable method.

 

Will be waiting for an early reply...

 

Regards;

Download All
0 Kudos
Message 1 of 7
(2,792 Views)

Is this a simplified version of a more complex process or are you trying to learn how certain parts of LabVIEW work?

 

1. Use of hidden indicator and local variable to transfer data is usually an indication that you are trying to use text-based language structures in LV rather than the native dataflow.

2. The event structure is primarily designed to respond to front panel activity generated by the user. An advanced process called User Events could be used for the data transfer but there may be better ways.

3. Event stuctures are usualy inside a while loop.

4. Putting code inside an event structure does not make it run when you want to to run.  You need to set up the event.  The default timeout event with no timeout set will wait forever.

5. Infinite lopos are not nice.  Please do not post code with no means of stopping it.  Replace the False boolean with a Stop button on the front panel. Do not use the Abort button on the toolbar to stop the VI.  In this example it does not hurt anything but in most real programs an orderly shutdown process which closes files, releases references, and places external hardware into a known safe state is required.

6. The for loop in the event case can be replaced with a single-element Build Array primitive.

7. The event structure can be eliminated and all the code placed in the while loop.

 

Lynn

 

one loop.png

0 Kudos
Message 2 of 7
(2,782 Views)

A very simple and efficient solution is to graph your array on "Array Value Changed" events. This works because the value of your Array variable doesn't actually "change" until it has been entirely updated with the new random values.

 

Right-click the "Timeout" case of your event structure, then select "Add Event Case". In the "Event Sources" list of the "Edit Events" window, select Controls>>Array, then select "Value Change" from the "Events" list at right. Click okay to add the event, then drag your graph-updating code to the new event.

 

Did I just do your homework for you? Because I expect extra Kudos for that...

 

solution

 

------

Matt Kirk

Inventor of ImageJVI

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

Mkirk,

 

You shouldn't be getting any kudo's for that post.  If you gave him a homework answer, he'll get a failing grade.

 

First, the one iteration For Loop to build an array is just a Rube Goldberg.

 

But the big problems:

Do you have a while loop around your event structure?  Without it, that event structure will only run once.

 

That event case for Value Changed will never run.  The array is an indicator.  Just writing to an indicator terminal does not fire a value changed event.  Only a user changing a control, or programmatically writing to a Value (Signalling) property mode will cause a Value Changed event to fire.

0 Kudos
Message 4 of 7
(2,772 Views)

Thanks all for your kind and quick suggestions and comments.

 

@Lynn: Thanks a lot for your tips, that really helped me. Actually what I was trying to do is that there will be two processes in my program. One will only acquire the data through DAQ, while the other will process and display the data. this is because I do not want the DAQ buffer to overflow and get crashed.

 

@Matt Kirk: Thanks for ur suggestions too. Initially I was doing the same, but this does not as "Ravenfan"mentioned. Ha ha haaa. This was not my home work. It was something I am doing for my own learning of LABVIEW. but you will get your Kudo.

 

@RavenFan: Thank allot man. Ha haaa this was not part of my home work. you were right, I have to make use of user events in a while loop to work properly. Its done now. I have attached the code that is working. Please check and any suggestion for improvement is highly welcomed;

 

Regards;

Najam

0 Kudos
Message 5 of 7
(2,748 Views)

The Boolean 'Stop this VI' has to be reset to False state either before starting the while loop or after stopping the while loop.

 

Alternatively you can use notifier too to stop the other loop.

 

0 Kudos
Message 6 of 7
(2,741 Views)

Thanks: Frabto

 

You are right about the boolean Stop. after reading your post, the first thing I am doing is to open the labveiw example of notifier and trying to understand its function.

 

Thanks guys, you people are shooting me with ideas I am craving for

 

Regards;

najam

0 Kudos
Message 7 of 7
(2,737 Views)