LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

count iterations in case structures

I have a case structure with 5 different cases and the case structure is inside a while loop which stops once any of the cases gets executed. This while loop is inside the major while loop which basically encompasses the entire module and stops when the STOP button on the front panel is clicked.

 

I need a way to count the number of times case no 2 is executed. Once this counter reaches 5, it should be reset to 0. Also, I don't know how to read this counter value in the major while loop because, I need to compare it to a timer. I want to have a timer in the major while loop which starts running as soon as the major while loop gets executed for the first time. What I need to accomplish here is, if either the timer reaches 15 mins or the counter reaches 5 (whichever happens first), I need to force my program to do some other action.

 

I'm just totally confused as to where to start. I did come across an example for a very similar problem in the knowledge base, but it is written in 8.0 version and am using 6.1. Any pointers in this regard would be greatly appreciated!!

 

Sukanya

0 Kudos
Message 1 of 7
(8,820 Views)
You can use a shift register to hold the counter or counters you need. You will need a shift register on both the inner and outer loops. Another alternative would be to use an action action to hold the status information.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 7
(8,816 Views)
Could you elaborate on that a little more? I'm not sure I follow what you are saying. I have not used shift registers in the past hence am pretty clueless!
0 Kudos
Message 3 of 7
(8,792 Views)

Well, the first place to look is in the LabVIEW Help. There are also shipping examples. For LabVIEW 6, select Help -> Examples. This opens the Help file. One example that uses shift registers is in the Array Examples (the one called Separate Array Values). You can find others.

 

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.

0 Kudos
Message 4 of 7
(8,785 Views)

use a shift register and put an increment in the true case and wire it to the shift register.

 

 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 5 of 7
(8,777 Views)

hi guys,

 

im using a state machine condition and i need to count the times my program executes a certain event so i can use the same count to index an array and change values. the problem is that if i use a shift register it holds the last value only for the next iteration and the event i want to count doesnt occur in a sequencial order. any idea how i can make that kind of counter.

0 Kudos
Message 6 of 7
(7,682 Views)

@asnaev wrote:

hi guys,

 

im using a state machine condition and i need to count the times my program executes a certain event so i can use the same count to index an array and change values. the problem is that if i use a shift register it holds the last value only for the next iteration and the event i want to count doesnt occur in a sequencial order. any idea how i can make that kind of counter.


You need to wire the value through in the other cases.  So then you are just passing the current value to the next.  If using LabVIEW 8.6 or newer, there is a feature called Linked Tunnels.  You just right-click on the tunnel and you will see an option to link it to another tunnel.  There should also be an option to link and wire all of the unwired cases for you.


GCentral
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
Message 7 of 7
(7,678 Views)