LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from Serial, and separate into arrays, help.

Hello Smiley Happy

 

I'm using an accelerometer+gyr with Arduino uno, the issue is, I obtain the data through VISA, so far, without problem.

The problem is, Arduino sends 6 different data, from the accelerometer, and my propose is, it separates the different data to work with it. (6 different values from the axes). The arduino code is the following:

 

...

Serial.print(value1);
Serial.print(",");
Serial.print(value2);
Serial.print(",");

...

 

Therefore I obtain in the serial port something like this: number,number,number,number,number, number

 

I attach the program in LabVIEW that I did, with "Match Pattern" I separate the string that I get with the Serial Visa, but now I want to insert the different numbers into a Array. Any idea?

 

Thanks!!

 

 

 

Download All
0 Kudos
Message 1 of 8
(4,461 Views)

Search for a pattern, separate your substrings and convert your elements to numbers. Build an array. I think this is the easiest way.


Tips: try to clean-up the diagram, your code has several backward-wires, what goes against the g flow principle. Avoid coercion dots, like the one in the "VISA Close" block.

 

Mondoni
0 Kudos
Message 2 of 8
(4,450 Views)

Use Spreadsheet String to Array.  Set the delimiter to a comman and make the array type a 1D array of numbers.  Done!


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
Message 3 of 8
(4,448 Views)

Follow crossrulz steps. Guaranteed success.

Mondoni
0 Kudos
Message 4 of 8
(4,444 Views)

Sounds like a great place to use one of my favorite hidden vis.

!1.png

That AdvancedString folder has quite a few gems in it


"Should be" isn't "Is" -Jay
Message 5 of 8
(4,425 Views)

Hi again

 

Firtsly, thanks joaopam, crossrulz and Jeff Bohrer.

I attach the new diagram with Spreadsheet String to Array. So, to separate the different data obtained (X,y,z...) I've used Split 1D Array, because, I have to work with each parameter (Math operations, graph...). Do you think that this way is the best? It would be better If I use other loop for the operations with the different paramerts?

 

joaopam, you are right, thanks for the tip 🙂

 

 

 

 

0 Kudos
Message 6 of 8
(4,389 Views)

I don't see the point in your FOR loop.  Why not just act on the array coming straight out of the Spreadsheet String to Array?


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 7 of 8
(4,369 Views)

I tried to do without the Loop, however I only got the first part of the string before the first comma. Anyway I will take a look again to figure out why happen that.

 

 

0 Kudos
Message 8 of 8
(4,335 Views)