Jump to content

Spreadsheet string to array


bwgames

Recommended Posts

I'm reading data in from RS232 in the form

CONF, 0005, 00040 \n\r

0, 121,23,64

1, 23,54,122

2... etc

where thr 121,23,64 etc represents X,Y,Z co-ordinates.

I'd like to be able to save this to CSV and display it on a graph.

Attaching a array to the output of Spreadsheet string-> array gives me

0,0,0

then on the second line, the correct output but overwritten every time

so instead of the above, its

0,0,0

0,121,23,64 then it overwrites that row with 1,23,54,122 etc instead of putting it on the next line. As far as I can see, I'm using the correct EOL character.

In spreadsheet string->array, I have , as a delimiter and %d as format string.

Also, how would i go about showing this on a graph? I found Array -> Cluster only accepts 1D arrays :unsure:

I found http://forums.lavag.org/index.php?showtopi...string+to+array which is almost identical to what I want, but I can't see how to get from my spreadsheet string to array to 1D array to graph..?

Link to comment

Hi,

I think you're on the right track. With delimiter set to ',' and format string set to %d it should work.

Please try this little VI, I also removed the first line from the data since it seemed like header info.

To present this in a graph you should be able to just wire the 2D-array to a Wfm-graph, but transpose the array first so that X,Y,Z values are seen as different data-sets.

If you do not want the first column (0, 1, 2, ...), just remove that column.

/J

Download File:post-5958-1157550703.vi

Link to comment

Thanks - very helpful attachment, its shown me exactly what I need to do, but I've just discovered thats not quite the input I thought I was getting.

I have a T/F case statement controlled by a button. When the button is pressed, it sends some commands to the device to program it. When false, it will loop through checking the serial port and if its received anything, it goes into a true case statement, which for the moment just outputs to an array

I tried replacing the array with a string indicator, which indicated the string was being written over with each new line, as my input is like:

CONF,X,Y\n\r

then there is a delay of ~60ms so the loop triggers again,

0,X,Y,Z\n\r

delay 60ms

1,X,Y,Z\n\r

and so on, which meant that each new line of data was a whole new string in itself.

What I see myself now needing to do is append each line to an array? Using spreadsheet string to array works fine in that it converts into a correct 1D array but as I say, it doesn't append the new string.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.