LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing string into channels input

Solved!
Go to solution

I think this is what you want. The key is to keep the delimiters then sort by the delimiter before putting data into the array

Message 11 of 22
(992 Views)

By 'shifted', you mean each VISA read call return a chunk, and each read does not necessarily contain the values of all channels? (That's why it is shifted each read?) Is it necessary to parse the string within the loop? If not, why don't you just dump all the read values into a file first. Then you can parse the string later outside of the loop. 

TailOfGon
Certified LabVIEW Architect 2013
0 Kudos
Message 12 of 22
(970 Views)

Hey

 

It is correct that each Read from the VISA does not necessarily contain the values of all the channels. Based on the bit read and size of the input the number only certain values "fit" in a particular read. I'm currently adjusting my input device so that I have a consistent length for each input in order to always have an input from each channel. 

 

Reason I do not dump into a file and sort later is because I need the program to read the input, parse, perform some signal acquisition and then display the result in real time. However, I did not consider having the parsing outside of the loop since I wanted a continuous input.

 

I'm currently testing both idea presented to me as seen in the block diagram. However, the output I am getting is either null or not grouped properly. 

 

Really Appreciate this. 

0 Kudos
Message 13 of 22
(957 Views)

Does the data being sent include a termination character?  Your serial port configuration is set up where the termination character is enabled.  If so, you should be reading a very large number of bytes rather than whatever number you have entered into your "Byte Count" control.  The entire string would then be read by the VISA read.  The string will be complete that all of your channels will be present in the data for parsing.

0 Kudos
Message 14 of 22
(946 Views)

Hey

 

 I have 6 inputs setup with a terminal character and 4 numeric values, so my VISA read is doing 30 bytes. I had to make a change to my device such that each channel would provide a consistent 5 byte input. However, I am getting the problem that depending when I start the VI, the read buffer does not start with a terminal character. For example:

 

2A1024B0134C0932D0321E0095F053

 

At the moment will parse to 

 

A1024 B0134 C0932 D0321 E0095 F053

 

Where is should be 

 

A1024 B0134 C0932 D0321 E0095 F0532

0 Kudos
Message 15 of 22
(939 Views)

You can use this regular expression:

 

([A-F])(\d{4})

 

This will only parse the string of 5 characters that match the alphabet followed by 4 digits.

 

F053 will not match this regular expression. 2A1024 will match, but the first "2" will be ignored. A1024B will match, but the last "B" will be returned at "after match" out, which you can prepend to the next string you want to test against.

TailOfGon
Certified LabVIEW Architect 2013
Message 16 of 22
(931 Views)

If you are using termination characters, you should always get complete messages, except for the first message received after starting the VI.  That first message may be incomplete.  You may also want to set the Byte Count input to a value signifcantly larger than expected size of the message.  It will terminate when the termination character is received and not wait for Byte Count characters. 

 

The strings you posted make it look as though you are not really using a termination character or a termination character occasionally occurs in your data.  If you are still having problems, save some data showing the probelm as default and then post your VI with the data.

 

Lynn

Message 17 of 22
(927 Views)

Hey

 

I've been working on this and I have made some progress. 

 

for(imstuck), I have attempted to implement the solution you provided, however the search and replace set-up I have does not work. It is only works if I put in only one character but won't work with a advance regular expression. I have provided a image of my current set-up.

 

I have also tried using Match regular expression to start sorting, however I end up with an array with every other column filled and with the Terminal character ( the letters) still in the value. 

 

Also, Lynn I do not know how to post my VI with the data. Would I simply store some string values into a file and attach both my VI and data file? 

0 Kudos
Message 18 of 22
(903 Views)

Did you right click the VI and select "Regular expression"?

0 Kudos
Message 19 of 22
(871 Views)

You could certainly store the data in a file.  But the easy way is to run the VI until the data which illustrates the problem is shown on the indicators. Stop the VI. From the Edit menu select Make Current Values Default. Save the VI. Post the modified VI.  All the data in indicators and controls at the time you did Make Current Values Default will be saved as part of the VI.

 

Lynn

 

 

0 Kudos
Message 20 of 22
(858 Views)