03-11-2015 06:10 PM
Hi everyone, I met a small question in VISA communication
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 problem Thank you very much!
03-11-2015 06:22 PM - edited 03-11-2015 06:22 PM
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.
03-11-2015 06:44 PM - edited 03-11-2015 06:46 PM
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.
03-11-2015 07:47 PM
@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.
03-12-2015 11:32 AM
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.
03-12-2015 11:35 AM
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?
03-12-2015 11:42 AM
03-12-2015 12:03 PM
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.
03-12-2015 12:53 PM
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.
03-12-2015 01:25 PM
@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.
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.