cancel
Showing results for 
Search instead for 
Did you mean: 

Split from String and Graph

SOLVED
Sman29
Member
Solved!

Split from String and Graph

Hello,

 

I am working in LabVIEW 13. I am receiving a string from a robot in this format: "[X,Y,Z],"   where X,Y,Z are numbers that can vary in character count. I am wanting to split these strings into 3 seperate doubles with just the numeric values (i.e. omit the brackets and commas), and then graph the error between the commanded position data vs the returned position data. I have looked at the search/replace and split string vi's, but I am kind of confused on how to use them properly...

 

Can someone help point me in the right direction to first split the strings and then graph the numbers?


Thanks,

SM

5 REPLIES 5
James.M
Active Participant
Solution

Re: Split from String and Graph

Message contains an image

Graphing, I think you can figure out by playing around a bit with the numbers. To get you started, here is how you would use Scan From String to get the 3 numbers:

Scan From String.png

 

If you are just graphing the error between actual and theoretical, that's easy. Get the difference in XYZ between the two points, then perform a Pythagorean theorem calculation on the resulting vector.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


GerdW
Knight of NI

Re: Split from String and Graph

Hi SM,

 

use ScanFromStrng with format string "[%f,%f,%f]"!

 

Edit: James was faster and also made a snippet for you…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Sman29
Member

Re: Split from String and Graph

Works excellent! Thanks guys!

 

Now that that part is done, how can I graph these 3 numbers vs the numbers I send the robot? In other words graph the error/discrepency between the 2. I have been looking at the Plot Multi-XY but I can't figure out how to get the data into it correctly, I am confused on how to go from dobule to cluster to all the other data types it needs...

 

EDIT: Also I should note, that these strings are coming from the robot 4 times a second, so it's a constant update.

 

Thanks,

SM

James.M
Active Participant

Re: Split from String and Graph

Show us what you've tried so far. If you only care about the error, and not the direction in which the error is, then just generate a single error value (DBL) using the method I described above. If you need to plot 3 axes, that will be a bit more difficult.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Sman29
Member

Re: Split from String and Graph

Message contains an attachment

Guys, thanks for all the help. I got it all figured out and it works how I need it to.

 

Attached is a snippet of my code and what my waveform looks like.

 

Thanks again!

SM