LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

case structure/event counting

Thanks so much everyone for your help. I was able to get it to work. I now have a second question that I have been wrestling with on my program for some time. I am hoping to be able to count the number of times each event happens, be it >0, <0 or 0. So far, I haven't been having a lot of luck on figuring this out.

 

The way my program works is that the case structures control the opening of solenoid valves. I am running a while loop to keep the program running, but would like to be able to at least count the number of times each of the cases are true in an effort to figure out the amount of time each of the solenoids is open during a run.

 

What I really need to do is be able to run each case for a maximum of 10 minutes each, and then stop the case from running. I know this is an in depth problem, but simply counting the number of times each of the cases run would be a huge start for me.

 

Thanks again for the help on the other problem.

 

Tim

0 Kudos
Message 1 of 11
(4,122 Views)

Hi VTStudent,

you can use shift registers to store the data. Wire them through your case structure and add a 1 in the specified case.

 

Mike 

Message Edited by MikeS81 on 08-27-2008 05:39 PM
Message 2 of 11
(4,120 Views)

You already asked this question in your other thread. Please keep the discussion in one place. If you want the discussion moved here, then place a note in the other thread that the discussion moved.

 

Also:

 

To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

Message 3 of 11
(4,114 Views)

Wow, sorry about messing with the ni discussion board etiquette, I wasn't sure if my post would be seen. And, by the way, I have taken tutorials and classes and am still having a problem counting the case structures within a while loop.

 

I agree with Mike that adding a shift register and a +1 to all of the cases will prove to count my events, but also what happens is that every time the case changes and goes back to the same case, the cases start over counting again from zero. I am trying to figure out how to count the total collectively of the times the event runs during the while loop, until the while loop itself is stopped.

 

Also, I thought the discussion boards were for discussing issues associated with labview programming regardless of the level of programming experience of the programmer, tutorials and lessons give basics and big picture, not specifics like I am trying to learn here. Your post makes novice programmers like me feel intimidated and may prevent people from trying to get their problems resolved.

 

Tim

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

Hi VTStudent,

it sounds like you don´t connect the wire in all cases! Could it be? Can you post your code if this doesn´t help?

Mike 

Message 5 of 11
(4,100 Views)
I had no intention of intimidating you. The blurb I posted about the tutorials is a fairly standard one that many other people post. Many people are not aware of the free tutorials. All levels of questions are accepted here. However, many times we have people who post questions here but have not even bothered to either go through the tutorials or simply open the manual. The blurb is friendly information. If you took it as intimidation then it must be from something else, and not me. Smiley Wink
Message 6 of 11
(4,093 Views)

Ok, here is a simple version of my program that I just put together with help from the last post. My solenoid valve program goes inside of the case structures, but I didn't think it was necessary to include all of that info. I am simply trying to count the event structures, so for example, the loop may run 100 times, and hit above zero 75 times, zero 10 times and below zero 15 times, thereby giving me 75, 10 and 15 for a total of 100. Instead what I am getting is like a counting effect and the number may go from 5 to 50 depending on where the loop is in its looping process.

 

Again, thanks for the help.

 

Tim

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

You need to use 3 different shift registers since you are trying to keep track of 3 different counts. Also, you can replace all of the code that uses the comparison functions and the Build Array and the Search 1D Array with a single Sign function as I pointed out in your other thread.

 

Note that your code will always count even if the user hasn't changed the number. I'm not sure what the eventual goal is, but you should be aware of this behavior.  It's also not clear what the purpose of the random number generator is.

Message 8 of 11
(4,079 Views)

You need three different counters, one for each event. Right now you increment the same number, irrespective of case, so you might as well do this outside the case structure or even just use the iteration terminal. Also, the counter should be blue (I32). You also need to initialize the shift registers.

 

Here's a simple example (LabVIEW 8.0) that uses an array of three elements to keep count of the three cases. See if this makes sense. 🙂

Message Edited by altenbach on 08-27-2008 09:30 AM
Message 9 of 11
(4,077 Views)

Hi Tim,

if you want three independent counters, then you need three shift registers. Smiley Wink  Don´t forget to initialize the shift register.

Mike 

Message 10 of 11
(4,073 Views)