LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling Event Structure with Text File

Solved!
Go to solution

I am relativaly new to LabVIEW (only about 2 week experience). I am currently trying to control a stepper motor using an event structure. Similar to the example code given by LIFA, I input my parameters of how the stepper motor moves, then press a button on the front panes to start it, and it works this way. I also have other hardware that works as well in LabVIEW, such as a transnational stage; all the components work individually.

 

 

Now, I am trying to make the system more automated, and make it so all the different hardware work in the same code. So, I tried implementing an event structure using a text file as an input to try to control the events. The text file has a 1D array of numbers going down vertically (only the row numbers are changing). So, I used an index array function to take out the numbers one by one, and use a for loop (while loop in this example code) to go down the column of numbers. However, the event is not registering the change even though the indicator says the value is changing. 

 

Attached is my test code and the text file I am using to try and control the event structure. Please let me know what I am doing wrong. Thanks.

 

Download All
0 Kudos
Message 1 of 11
(4,298 Views)

To trigger an event off a programtically changing indicator/control, update it's value using the Value(Signaling) property node.

0 Kudos
Message 2 of 11
(4,286 Views)

I am attempting that in the code, but it is not registering it. I created an event that triggers on my changing value in my text file. This has a property node that uses Value (signaling) to get the new value from the text file. Then I have another event that triggers on the change of number of the property node that just displays the number.

0 Kudos
Message 3 of 11
(4,280 Views)

I can't open your vi (don't have version 13) but I'm confused by what you mean by  "an event that triggers on my changing value in my text file".  Since I'm not sure what you are doing, i'll try to be clear in what I meant

 

Read your file into an array.  Index the array when you need to, assigning the value to an indicator USING the value(signaling) property node.  This property node has to be used when ASSIGNING the value of this INDICATOR.  Your event structure must be set up to handle the "Value Changed" event for this indicator.

 

Of course, the value must be set OUTSIDE the event structure (event structure code should be limited to HANDELING EVENTS ONLY, not creating them).  If the code for an event is running, the event structure may miss another event that has occured.

 

Others who can open your file should be able to provide more specific advice.

 

0 Kudos
Message 4 of 11
(4,249 Views)

If you want something to be automated, you don't want to use an event structure.  A for loop with the actual code to step the motor is what you want.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 11
(4,241 Views)

I think this is now saved as a 2010 version of the code. If you look at the code currently, I am trying to use a control to change the value of an indicator, and want to use the indicator value to activate the events (for a simpiler case of using arrays). The event with the change in the indicator has the Value (signalling) node that takes the NewVal of the indicator. The property node is connected to an outside indicator called event source 2. Then event source 2 is another event, and in that one I output a string of the number given by the control. However, this does not work either.

0 Kudos
Message 6 of 11
(4,233 Views)

Sorry I should have been more specific in my initial statement: I want to make it more automated, thus I want to input a text file into the code and let the code run on its own. The event structures will take what I put into the text file, and go to the specified event with the different input of the text file. The problem I am having is trying to make the event structure work with the indicator value that I am using, which has the output of a specific value from the text file (will be a 1D array of numbers).

0 Kudos
Message 7 of 11
(4,222 Views)

@yeshak10 wrote:

Sorry I should have been more specific in my initial statement: I want to make it more automated, thus I want to input a text file into the code and let the code run on its own.


Again, don't use an Event Structure.  Just use a FOR loop and be done.

 

The other option I would suggest is to use Dynamic Events.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 11
(4,209 Views)

CrossRulz is right in that a for loop (or a while loop) is much better suited to this task.  Event structures should be mostly used (there are exceptions) to handle User events, like button presses or value changes on the FP.

 

The main problem with your code so far is that you simply discard the data from the file.  You index the 2D array and then do nothing with it.  You can achieve your goals here without the use of the event structure.  Each iteration of your for loop will use the next value in the array to perform the task at hand (what you were trying to achieve with the event structure based on the changing value of an indicator)

0 Kudos
Message 9 of 11
(4,195 Views)
Solution
Accepted by topic author yeshak10

Oh I understand now what you were trying to say. Im using a FOR loop now, and using a case structure to activate different events with inputs from the array. I thought case structures and event structures were the same, however you taught me that event structures are just used for the front panel stuff. Thanks everyone!

0 Kudos
Message 10 of 11
(4,185 Views)