08-27-2008 10:27 AM
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
08-27-2008 10:38 AM - edited 08-27-2008 10:39 AM
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
08-27-2008 10:42 AM
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.
08-27-2008 10:54 AM
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
08-27-2008 10:58 AM
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
08-27-2008 11:05 AM
08-27-2008 11:18 AM
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
08-27-2008 11:28 AM
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.
08-27-2008 11:29 AM - edited 08-27-2008 11:30 AM
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. 🙂
08-27-2008 11:31 AM
Hi Tim,
if you want three independent counters, then you need three shift registers.
Don´t forget to initialize the shift register.
Mike