06-06-2017 01:01 PM
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!!
06-06-2017 01:50 PM
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.
06-06-2017 02:18 PM
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.
06-06-2017 02:45 PM
@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.
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.)
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?
Another silly select and BONUS what is the result of Boolean = T?
06-06-2017 04:04 PM
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:
They are good if used right
06-06-2017 06:31 PM
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 🙂
06-06-2017 08:34 PM - edited 06-06-2017 08:43 PM
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?
06-06-2017 09:00 PM
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.