LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real time plot (read thru serial).

I have a 3 axis accelerometer that sends data thru Serial. In the VI attached I can plot  in real time one axis when I send data in the format:

3

6

8

5

4

3

 

The problem is that I want to plot all 3 axis (in 3 differents graphs) and I don't know how to do that. The accelerometer sends the data of the 3 axis in the format:

 

X=4 Y=3 Z=7

X=3 Y=1 Z=6

X=2 Y=8 Z=3

 

X=8 Y=1 Z=10

 

What modifications to the attached VI should I make to plot all 3 axis in real time?

Thanks

0 Kudos
Message 1 of 22
(3,404 Views)

You need to replace the Decimal String to Number with a Scan From String so that you can get all 3 values. You'll need to bundle the 3 values together and wire the cluster to the chart. Converting to dynamic data is silly. Since you are specifying that the string is terminated with a line feed, you can wire an arbitrary number to the bytes to read - as long as it is greater than the expected string. And make the bytes to read a U32. The bytes read should be a U32 as well. Do you know you can create a control/indicator with a right click on the terminal of the function?

 

 

0 Kudos
Message 2 of 22
(3,399 Views)

Your present code only places a single dot on the graph as it is a scalar value which is written to the waveform chart.

 

Before offering any suggestion, I would need to know if you wish to plot the values as you are reading them or after you read them.

You present code wants to plot the values as you read them, if they were in an array, of course.

 

Do you know how many values you plan to read or is this gathering data over an extended period of time with an undefined number of samples?

 

 

EDIT:  Hi Dennis,  I am not sure that the accelerometers actually write X=4 Y=3 Z=7, but I could be wrong. 

He also needs to build an array since he is only passing a single value at a time to the chart.  🙂

0 Kudos
Message 3 of 22
(3,397 Views)

I'm just going by what the op said (X=4 Y=3 Z=7). If that's the format, then the op needs to clarify

0 Kudos
Message 4 of 22
(3,391 Views)

Thanks Ray.R and Dennis_Knutson for the fast answer.

 

Actually I can choose the format that the accelerometer sends the data. Can be:

X=4 Y=3 Z=7                                  

X=3 Y=1 Z=6                            

X=2 Y=8 Z=3

 

or 

 

4   3   7

3   1   6

2   8   3

 

I want to plot the values as I'm reading them (real time).

I'm getting data over an extended period of time with an undefined number of samples.

 

 

0 Kudos
Message 5 of 22
(3,386 Views)
As long as you have the termination character after the z value and there are spaces between the others, my suggestion will work. Just set the number of bytes to read to something like 20. If you don't get the entire string, then its not sending the way you said.
0 Kudos
Message 6 of 22
(3,369 Views)
Dennis, could you please insert the necessary modifications in my VI. Im new in labview. Thanks very much.
0 Kudos
Message 7 of 22
(3,361 Views)
I already did most of the work. its a snippet so you can drag it to the block diagram.
0 Kudos
Message 8 of 22
(3,356 Views)

vitor,

 

you have not answered my question:

 


@Ray.R wrote:

Your present code only places a single dot on the graph as it is a scalar value which is written to the waveform chart.

 

Before offering any suggestion, I would need to know if you wish to plot the values as you are reading them or after you read them.

You present code wants to plot the values as you read them, if they were in an array, of course.

 

Do you know how many values you plan to read or is this gathering data over an extended period of time with an undefined number of samples?





0 Kudos
Message 9 of 22
(3,339 Views)

Ray.R

 

I answered you question in the previous post. I want to plot the values as I'm reading them.

0 Kudos
Message 10 of 22
(3,333 Views)