LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting reps

Hi

 

I'm still very green in LabVIEW and are working on a project where i could use a hint or two.

I am making a VI with a slide that controls 2 points on a xy graph. The slide can go from 0-100 and i want a counting system which can detect and count one set. A set is defined as when the slide goes from below 25 to above 60 and back below 20 again. Futhermore i want it to store the max and minimum value of each set.

 

Fx

If the slide goes from 0 to 81 and back to 5 it should count 1 set. If the slide then goes from 5 to 71 and then back to 2, another set should be added and the indicator that counts sets should now say two sets done. If the slide doesnt get above 60 in a set, it shouldnt be counted.

 

I've attached a VI which have a slide and a graph that shows the two points plotted, to give a better understanding of my problem.

 

I hope someone got a hint for a solution to this, thanks!

 

0 Kudos
Message 1 of 9
(4,470 Views)

Hi there, can you save in LV 2014 or lower?

Message 2 of 9
(4,463 Views)
  • Your loop need a small wait.
  • You simply need a shift register that maintains state (e.g. a boolean that switches whenever the value goes below 25 or above 80) etc..
  • You need a second shift register to keep the count and increment it whenever the values dictate.
  • You probably don't need these formula nodes. It is pointless to have values with 30+ decimal digits. DBL (as well as EXT) is insufficient to represent that. If you need that kind of precision precision (why????), you need to create your own math tools and datatypes from scratch. That won't be easy.
  • To keep the min and max of each set, use yet another shift regsiter where yoyu keep a 2D array, appending a row for each set.

This is all pretty basic. See how far you get....

Message 3 of 9
(4,459 Views)
Thank you a lot altenbach!
The extreme amount of digits is simple because of copy/paste, and you are right! I dont need anything near that precision.
The reason i chose to use formula nodes is simple because i couldnt find another way to take the power of a number. is there a more easy way to makeup a simple equation like the one i made?

@gregoryj thanks for the reply! i will just try out what altenbach wrote and if anymore help is needed i will upload an earlier version!
0 Kudos
Message 4 of 9
(4,426 Views)
Message 5 of 9
(4,414 Views)

Thanks gregoryj! I have been searching far and wide for that! 😄

0 Kudos
Message 6 of 9
(4,369 Views)

I have troubles finding a boolean that only switches when above and below certain values. Is there an easy solution or do i have to make a system for that function? 🙂

0 Kudos
Message 7 of 9
(4,350 Views)

OpenG comes with a boolean trigger function, I'm not sure how useful that would be though. If you values change in a somewhat continuous way, (i.e. in steps of 5, not 80) then you can probably easily catch it with a case a structure. The next case would be held in a shift register of the while loop.

 

Case 1: If x<25 --> Case 2, else Case 1.

Case 2: If x>60 --> Case 3, else Case 2.

Case 3: If x<20 --> Case 4, else Case 3.

Case 4: Increment set counter then back to Case 1.

0 Kudos
Message 8 of 9
(4,324 Views)

It could look something like this. I haven't filled in all of the cases for you or put in any logic for picking the next state. Also, if you use those enum constants, it's always a good idea to make them type definitions. That way if you add or remove states, the constants will be updated everywhere. Right click >> Make Type Def. Right click >> Open Type Def. then save it near your VIs, or in an appropriately named subfolder.

 

state machine.png

0 Kudos
Message 9 of 9
(4,319 Views)