LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Coding with a simple If else statement using text file values

Solved!
Go to solution

@GerdW wrote:

Hi Lexen,

 

I have to check the C and G values if they are larger than 0.65.... if one of the values are larger than 0.65, I have to increment a count and the boolean button would light up indicating there is one. The entire process continues throughout the data.

Trying to translate your text "word by word" into LabVIEW:

check.png

Read the file, index the columns, compare with your threshold value, "light" a boolean indicator, increment a "count"…


Thanks for the gracious help again dark knight, however I couldn't create the DBL as shown as for my labview my dbl created was just a constant....

The boolean, count and the one below I also could derive out the location of the components... 

0 Kudos
Message 11 of 21
(1,174 Views)

Hi,

 

even when I was faster the problem is maybe not solved: LexenZ wasn't very specific in it's definitions!

 

What's the exact condition? Three possible interpretations:

- check for at least one value bigger than threshold? (This one I chose.)

- check for exactly one value bigger than threshold?

- check for values bigger than threshold and count them?

The biggest problem in programming is defining the algorithm in an exact way…

 

however I couldn't create the DBL as shown as for my labview my dbl created was just a constant....

What are you talking about? Mind to share a snippet (or VI, I prefer LV2014)?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 21
(1,174 Views)

@GerdW wrote:

 

 

however I couldn't create the DBL as shown as for my labview my dbl created was just a constant....

What are you talking about? Mind to share a snippet (or VI, I prefer LV2014)?


Apologies for the difficult to understand me, basically I am trying to replicate your VI, as you are using 2014 edition while I am using the 2015 edition, I could not source for the DBL and Boolean constants out as shown..

0 Kudos
Message 13 of 21
(1,168 Views)

Hi LexenZ,

 

I could not source for the DBL and Boolean constants out as shown..

There are no constants in my image! There are only indicators

 

Basic LabVIEW knowledge, learned by taking the free beginner courses:

Right-click an input/output of a function -> Create -> Constant/Control/Indicator…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 14 of 21
(1,164 Views)

I have managed to set it up as shown.

However, I presume is because of my lousy explaination, my main objective is to see 3 columns of data(from the text file shown).

Any value greater than 0.65 should be checked(There should be a count to increment it like you did, but I have to see how many values are greater than 0.65 in that particular column). Furthermore, once a value greater than 0.65 is found, the boolean acts like a LED to blink if there is a value greater than 0.65 being found.

0 Kudos
Message 15 of 21
(1,159 Views)

Hi LexenZ,

 

my main objective is to see 3 columns of data(from the text file shown).

You already see those 3 columns in the C, G, and D array indicators!

Edit: you have implemented to index rows instead of columns. You should follow my suggestions more carefully!

 

Any value greater than 0.65 should be checked

This also already is done by the comparison functions!

 

(There should be a count to increment it like you did, but I have to see how many values are greater than 0.65 in that particular column).

All you need to do is: use BooleanTo0/1 function on the boolean arrays (after the comparison). Then convert the result of this function to I32, then use SumArray on this I32 array: wow, you got your number of values greater than threshold!

 

Furthermore, once a value greater than 0.65 is found, the boolean acts like a LED to blink if there is a value greater than 0.65 being found.

Should the LED be "lighted" or should it "blink"?

I have shown you how the "light" it. When you want it to blink you need to use a "Blinking?" property node of the boolean indicator…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 16 of 21
(1,156 Views)

This one may not be the right way to do.. but may give you a simple overview.

And it all depends on your way of explanation and the reader's way of perception.At first i thought you want something like this and i was doing it in this way

 

Solu.png

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 17 of 21
(1,151 Views)

@GerdW wrote:

Hi LexenZ,

 

-You already see those 3 columns in the C, G, and D array indicators!

Edit: you have implemented to index rows instead of columns. You should follow my suggestions more carefully!

-This also already is done by the comparison functions!

 

So sorry! I managed to solve this issue by placing the correct constant, now the columns are shown.

 

All you need to do is: use BooleanTo0/1 function on the boolean arrays (after the comparison). Then convert the result of this function to I32, then use SumArray on this I32 array: wow, you got your number of values greater than threshold!

 

Apologies I still do not understand this part. As shown my the latest snippet I uploaded, I am unsure why is there only 1 count, when there should be more than 1 values are that greater than 0.65.

 

Should the LED be "lighted" or should it "blink"?

I have shown you how the "light" it. When you want it to blink you need to use a "Blinking?" property node of the boolean indicator…

 

It should be lighted whenever there is a value greater than 0.65. Perhaps I should not mention blink. However even so it only lighted once, perhaps I should use a while loop or something to check the every values?

 


 

0 Kudos
Message 18 of 21
(1,145 Views)

@Nghtcrwlr wrote:

This one may not be the right way to do.. but may give you a simple overview.

And it all depends on your way of explanation and the reader's way of perception.At first i thought you want something like this and i was doing it in this way

 

Solu.png


YESS Nightcrawler!!! That is exactly what I wanted! Except for the boolean section I would only require 2 LEDs instead of mutiple LEDS. (1 for C and 1 for G) How should I show it out say for example, once I open the text file and view the data, each of the number is scanned and checked if its greater than 0.65, if it is, the LED would light up once per every value of 0.65)

0 Kudos
Message 19 of 21
(1,140 Views)

Hi LexenZ,

 

All you need to do is: use BooleanTo0/1 function on the boolean arrays (after the comparison). Then convert the result of this function to I32, then use SumArray on this I32 array: wow, you got your number of values greater than threshold!

 Apologies I still do not understand this part. As shown my the latest snippet I uploaded, I am unsure why is there only 1 count, when there should be more than 1 values are that greater than 0.65.

This is what I'm talking about:

check.png

 

It should be lighted whenever there is a value greater than 0.65. Perhaps I should not mention blink. However even so it only lighted once,

And so my solution works!

Whenever there is a value greater than threshold the LED is lighted! Wh should it light up more than once?

Again: you need to define your tasks very carefully!

 

Edit: the image in your last post is OVERLY complicated! Learn to use autoindexing - or use polymorphism as I did…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 20 of 21
(1,139 Views)