LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For "Select" module, how can I return nothing if s is false?

Hi everyone, I met a small question in VISA communicationSmiley Sad

 

Please have a look on my code, it is very easy to understand. I have 3 channels data to read, since it's serial port communiaction, I need to separate them and put them in three array. So I add header(Z,I,Q) for each channel. When the laptop received the data, "Select" module will judge the header. If the header is correct, then the data go through and be further processed. However, if the header is not correct( s is false ), how can I return nothing to the array? 

 

I try to put a Feedback node, but it will return the last correct data, which means the data will be repeated for three time(since I have three channels)!

 

Hope you can understand my problemSmiley Happy Thank you very much!

0 Kudos
Message 1 of 18
(3,832 Views)

In this case, I think you are better off using a Case Structure on the single string character that tells you the channel.  The case just tells you which element you are updating.


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 2 of 18
(3,824 Views)

I don't think you need to collect data forever in a shift register. The only place you are collecting, is in the history buffer of the charts.

 

Just place all the "further processing" code inside a case structure and do nothing in the other case, i.e. if the data is not valid.

0 Kudos
Message 3 of 18
(3,811 Views)

@altenbach wrote:

I don't think you need to collect data forever in a shift register. The only place you are collecting, is in the history buffer of the charts.

 

Just place all the "further processing" code inside a case structure and do nothing in the other case, i.e. if the data is not valid.


I agree.  I'm just keeping the latest values in my code.  So you just update the channel data that was recieved.


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 4 of 18
(3,798 Views)

Thank you for your reply! I'm not very understand the code in your figure. Could you please explain a little bit?

I put the "further processing" part in the case structure, however, if the header is not correct, it will return "0" to the array.

0 Kudos
Message 5 of 18
(3,743 Views)

Thank you! I put my "further processing" part in the case structure, however, if the header is not correct(case is false), it will return "0" to the array. I want it return nothing.

Could you please have a look on my modified code?Smiley Happy

0 Kudos
Message 6 of 18
(3,740 Views)
Then you need to format into a string and return an empty string, for example. Sorry, cannot look at your code at the moment.
0 Kudos
Message 7 of 18
(3,735 Views)

In my code, I used a Feedback Node to keep the latest values, stored in a cluster.  So I just need to get the header and use that for the case structure selector.  So you just update the the value you recieved based on the header.  If you don't recognize the header (the default case), then you just pass your latest values straight through.

 

I used the Search/Split String function to seperate the header from the data.


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 18
(3,723 Views)

If I want to convert the string to an empty string, I should use "Replace substring" or "Search and replace string" or "Format into String" or "Scan from string"?

I was confused by these similar functions.Smiley Sad

0 Kudos
Message 9 of 18
(3,710 Views)

@yatang wrote:

If I want to convert the string to an empty string, I should use "Replace substring" or "Search and replace string" or "Format into String" or "Scan from string"?

I was confused by these similar functions.Smiley Sad


Use "select" with an empty string constant wired to one input. Seems we are going full circle again. 😄

 

If you do the conversion inside the case structure, you can set the string output tunnel to "use defaul if unwired" and leave it unwired in the error case.

0 Kudos
Message 10 of 18
(3,695 Views)