LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I count events falling into three categories?

Solved!
Go to solution

I think this should work.

Download All
0 Kudos
Message 11 of 17
(858 Views)

As it is right now, your application probably isn't going to function as you expect it to.  You have the Event Structure in an inner while loop.  Your Event Structure has no timeout wired, so it will use the default timeout of -1, or "Wait Forever".  The only events registered to it are the value changes of two buttons, and even then only one of those buttons actually stops its loop.

 

Therefore your inner loop is going to sit and wait until you press one of those buttons, and if it is the Test button, it will do what is in the associated diagram and then go back to waiting.  Because your inner loop is within your greater loop, the greater loop has to wait until that inner loop actually stops before it can move on to the next iteration of its diagram.  So right now you are going to get an application that does everything once - which won't be much since "everything" includes polling controls to see if they have been pressed - and then waits until you press that stop button at the bottom before it can do even one more iteration.



0 Kudos
Message 12 of 17
(849 Views)

When I put it into the main vi I would like to set the event control to a change in the data from Total Torque in the ITS_datagraphs. 

 

As far as stopping the counting program, will it halt other functions within the greater while loop on Impact Tester Main? The main while loop runs the entire duration of the test. We start the Main, then command speed, start test, then analyze data. We only use the stop function after testing completes.

 

Everything is pretty manual. The operator has to account for a lot of variables during testing and command speed accordingly. I would love to eventually use a PID to automate a 10 impact cycle but I'm concerned about it wildly overcompensating for clutch drag instances in the system.

 

Attached is how I planned to insert the counting loop into the Main vi. I expect I'm going have problems pulling my Total Torque number the way I did.

0 Kudos
Message 13 of 17
(833 Views)

I tried something like this already and for some reason when I add a terminal to the terminal pane on the subvi it does not show up on the main vi. I can only imagine this is because the sub vi is "call by reference". The subvi already outputs an indicator to the front panel of the main vi called "total torque". This is inside a case structure so I don't know how to reference it for the subvi which you created.


Yes, this is because of how it is being called in your top level VI.  If you add a control or indicator and then connect it to a terminal on the connector pane, it would show up as you expect if you used it as a subVI dropped directly on the block diagram of your top level VI.

However, this is not automatically so when calling by reference.  When calling by reference, you have to explicitly provide the connector pane information if you want to use it with the Call By Reference node.  This is the control labelled "VI Refnum" going into the top of the Open VI Reference function in your top level VI.

The easiest way that I have found to do this is to place a Static VI Reference node (Programming -> Application Control) on a block diagram, insert the VI (your ITS_Data_Graphs.vi) into the node, right-click and set it to be a Strictly Typed VI Reference.  Then you should be able to right-click on the VI Refnum control on your top level VI's front panel and select Select VI Server Class -> Strictly Typed VI and select the new connector pane.  The first part is just to get the connector pane loaded into the list of recently used / opened ones that show up in that right-click menu, and can be done on any open VI, even just creating a new VI in memory to do it with temporarily and then throwing it away when you are done.

 

 

What you probably want to do is make an Action Engine out of the draft that altenbach provided and call it after your ITS_Data_Graphs (which is your Call By Reference).  It would hold the counted number internally, and when you call it it would process the latest data from ITS_Data_Graphs, increment whichever pool the result belongs in, and then output the current values of each pool.  Note that the Event Structure would not belong in it in this case; I believe that altenbach's draft was just an example that you could run standalone to play around with.



0 Kudos
Message 14 of 17
(827 Views)

All you probably need to do is wrap my code into an action engine that keeps the countrs in an uninitializewd shift register and returns immediately. Initialzie it at program start and call it whenever a new results comes in.

 

ITS graph: Whatever you are doing in the code you have attached is way too convoluted and wasteful. Why are you parsing the same file 10x per second? The data never changes! The only input is the offset and the only output that depends on it is the torque. Everything else belongs outside the loop, bevcause it is static.

Impact tester 03: Many weird constructs (e.g. using a FOR loop and case structure as "index array" replacement).

0 Kudos
Message 15 of 17
(818 Views)

@SeanCummings31 wrote:

...

As far as stopping the counting program, will it halt other functions within the greater while loop on Impact Tester Main? The main while loop runs the entire duration of the test. We start the Main, then command speed, start test, then analyze data. We only use the stop function after testing completes.

 ...


It would not.  The way dataflow works with while loops is that a while loop cannot proceed to the next iteration of its diagram until everything on the diagram has finished.  A while loop on the diagram counts as just another thing, with it finishing being defined as it stopping.  Similar for an Event Structure - when one is inside a While Loop, the loop does not proceed until that Event Structure has executed a digram (and anything else that is in the While Loop's diagram has finished, of course!).

 

Your design requires that the outer while loop is running a bunch - the issue I was referencing in that version you attached is that it would not be running at all except for one iteration each time you pressed the inner loop's stop button.

 

 

This is just information, though, as you don't want to be using it in that design, anyways; as suggested, probably change to an Action Engine subVI called after your analysis subVI.



0 Kudos
Message 16 of 17
(813 Views)

  Sorry for the delay in creating a response to this thread. I worked with Vltan and he helped me turn Altenbach's vi into an Action Engine. I was then able to put that AE into my main VI and it works great. Just adding that counting function has saved me 20.5 hours per part tested which is amazing. I have run through several tests since as well as worked on training others to run it. When used properly it yields great results. One  issue is when someone forgets to run the Analyze subvi the count (as well as the data) is off, but that is something I will work on moving forward. As already stated in this thread there are several areas that the entire test program can be inproved and I will continue to do so.

 

  I have signed up for Diadem classes in the next couple months, and I am also signing up for Labview classes. I was told that the SSP we have for Diadem might also be used for Labview free online training so I have to look into that. Otherwise I plan to continue Labview training through the core classes. We would like to implement Labview an NI products in more of our test cells so I'm excited to learn it and help out where I can.

 

  Thanks again for all of your help creating this AE. I could not have done it without the help of the great talent on this forum! You guys are awesome!

 

 

  -Sean-

0 Kudos
Message 17 of 17
(720 Views)