LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Removing Global Variables

Hello Everyone!

 

I made a couple of attempts to detect steps(simple step counter) using Linear Acceleration(you could give an array of values as input into StepAlgorithm and StepValidityAlgorithm VIs). Attaching the relevant VIs as follows

 

The first attempt consists of the VIs Step Algorithm and Check Step Pattern and all the Global Variables. I intend to compare each element of the incoming array to Max/Min values stored in CycleMax/CycleMin. This Maxima/Minima, when exceeding the thresholds, drives the half cycle flags, which in turn raises the completed cycle flag. I do understand that the algorithm might be inefficient at places(or as a whole, but suggestions welcome too!) but it does definitely show correct results, the correct number of steps, that is.

 

However, I have been repeatedly told to avoid Global/Local variables and hence came up with the next attempt comprising of the StepCounter and StepValidityAlgorithm VIs. This one however, does not work despite it recording the Max/Min values and Half Cycle Flags. I believe it stems from the fact that I use a Control element in a Cluster(is that even correct?). Is this second attempt fundamentally wrong/slightly wrong? Any guidance is appreciated!

 

I hope I have included sufficient data!

 

P.S.: The missing VIs in the Step Counter VI, such as the Linear acceleration and Filter VIs work fine (cross checked) and hence the acceleration input to the StepValidityAlgorithm is fine as well(again, an acceleration value for each run of that VI, so you could independently run just the StepValidityAlgorithm wired to an array (sinusoidal, exceeding the threshold values)

 

Thanks!!

0 Kudos
Message 1 of 8
(3,801 Views)

I think you could benefit greatly from using the training resources on the main page of this forum.

 

I would HIGHLY recommend going through Learn LabVIEW Basics before attempting this again.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 8
(3,763 Views)

Hi

I did go through the Tutorials once again, just in case I had missed out on something. Could you tell what specific part are you referring to? I am not able to find the needed information there.

0 Kudos
Message 3 of 8
(3,746 Views)

@harshaldawar wrote:

Hi

I did go through the Tutorials once again, just in case I had missed out on something. Could you tell what specific part are you referring to? I am not able to find the needed information there.


Well, since you asked.

Capture1.PNG

You use a select here why?  Just wire a F to the Feedback Node Initialization terminal.  (But since thats the default data for a boolean you don't need to even do that.)

Capture2.PNG

Now just exactly what are those Selects doing?  Just checking to make sure the if the input is T/F the output is REALLY T/F?

Capture.png

Another silly select and BONUS what is the result of Boolean = T?


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 8
(3,731 Views)

I agree with what has been said.  As a side note, since you mentioned that everyone tells you to avoid globals, check out this thread:

I Like Global Variables

They are good if used right

Message 5 of 8
(3,709 Views)

Hello again,

Thanks for pointing out the redundancies. However, as you all would already OBVIOUSLY know, removing all those redundancies DID NOT solve the problem. I did find a way around to the actual problem.  

 

However, thanks Shane for at least answering a part of the main problem 🙂 

Message 6 of 8
(3,693 Views)

 Then,. After simplifying​ the code.  Post the vi with problems with example data of good and bad results.

 

 I thought you asked how to remove globals.. you now have other issues?

 

Getting rid of the Rube Goldberg constructs helps to read the code that is actually meaningful.  Less noise.  Can you restate?

 

Globals are not evil.  But, did you know you can place More than one control on the same global vi?


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 8
(3,683 Views)

Shane-C wrote:

They are good if used right


Shameless plug: Are Global Variables Truly Evil?

 

I will try to look at your code in the morning.  But do post your cleaned up code to make it a little easier on us.


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
0 Kudos
Message 8 of 8
(3,675 Views)