LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case Structure and String

Solved!
Go to solution

Hello everyone.

 

I'm having some problems with my VI on Labview. I have as input a String that have in sequence: "Number of Sample/X Value/Y Value/Z Value", each of them separated by a comma. In the serial port I receive a loop of 500 samples from an accelerometer.

 

I'd like to have Labview receive the values only when the String "Number of Sample" is 0 and graph them until the 499th sample is send and discard the data when is different from 0.

 

My problem is the Case Structure, I can't manage to send data when the string is 0 and discard the data when is different from 0.

 

I've attached my VI, any help would be greatly appreciated.

0 Kudos
Message 1 of 5
(2,759 Views)

Well, you appear to have LabVIEW 2013.  Did you know about the Conditional Tunnels that were indtroduced in 2012 and improved in 2013?  a quick mod to your code is attached.

 

There are other opportinities to improve that code but, I'm assuming its only part of a larger vi (and a BD clean-up is in order)  Comments can also help make your code more readableSmiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 5
(2,740 Views)

Thank you very much for your reply, unluckily it's not working.

 

I've attached again my VI, commented as you suggested.

 

Any help is again very appreciated.

0 Kudos
Message 3 of 5
(2,703 Views)
Solution
Accepted by topic author AndreasSchnaas

Hi Andreas,

 

the problem isn't the case structure, it's more likely the inproper use of BytesAtPort.

 

You have configured the serial port to use the TermChar. Then all you need to do is to read a sufficient number of bytes from the port as VISARead will automatically stop at the TermChar. Now you can analyze your data.

 

For that case structure: You have to output a value on that tunnel. Or you have to include all code, that should only execute in the TRUE case, inside of the case structure!

 

I also suggest to use the SpreadsheetStringToArray function as your read string seems to consist of several numbers separated by commas. It will simplify your BD a lot…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(2,697 Views)

After some days of work, thanks to your suggestions I've solved my problems.

 

Thank you very much!

0 Kudos
Message 5 of 5
(2,651 Views)