LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Representing data on XY graph (timing)

Solved!
Go to solution

Hello I'm new to LabVIEW.

 

I have a problem on timming my data. My profesor ask me to send data throught the serial port every 10 ms (from the Arduino, sending data from an analogic input and its respective sampling time), this part is solved, and I have to represent it in the xy graph every 0.5 seconds. So I have made a program wich reads the data from the serial port every 10 ms, it splits the array that I am sending (data, time) and it represents it in the graph every 10 ms. If I want to represent it every 0.5 seconds how can I do it? Also in some cases the LabVIEW shows an error in the VISA write and sends me wrong data, do you know why this happens? So if you see any error or know something that I am doing wrong tell me. Thank you all.

 

This is my LabVIEW program: When i press the button the LabVIEW send me '1' throught the serial port to Arduino and then I start sending data to the LabVIEW
Es mostra LabVIEW.PNG.And there is the graphic with errors every x time. 
image.png
Error in the VISA Write
image.png
This is the data that I am sending from arduino. As you see there is the sample time, every 10 ms and the lecture from the analogic input, left to right respectively.
image.png
 

 

0 Kudos
Message 1 of 13
(3,047 Views)

So do you only want to show a small fraction of values or do something more complicated, e.g. do a 0.5s running average?

 

To only plot a point every 0.5 seconds, simply place the graph related function and terminal inside another case structure that only turns true occasionally.

 

(Also note that "index array" can be resized for two outputs and "spreadsheet string to array" can produce 1D DBL arrays if you wire the type correctly)

 


@bernat_serra wrote:

Also in some cases the LabVIEW shows an error in the VISA write and sends me wrong data, do you know why this happens? So if you see any error or know something that I am doing wrong tell me. Thank you all.

 

 

 


You should not use "bytes at port" but use a correctly configured termination character. Currently, you can easily read partial messages or get frame-shifts that corrupt the data.

 

Message 2 of 13
(3,023 Views)

Okey thank you a lot! Talking about the error in VISA write I tried to use termination character as you said and now it works well until i reach the value of time "1000". You can see a picture of an excel that i have created with the graph to see that. I only have changed "bytes to port" to "termination character". I don't know if i have to do something else.

 

Also I created another case structure to place the graph. I only want to show a small fraction of the values, I mean the once equivalent to the time. So I don't know how to say to the case structure that every 0.5 seconds I want it to execute the graph. I tought that i could put a function that every time that it arrives a value of miliseconds multiple of 500 (that is equal to 0.5 seconds), sends a true to my case function an actives the graph. Or if any funcion that you can enter the time and it sends a true every time that will work also... but I don't know if there is any.

 

Here is a picture of the graph. Now that I changed to "termination character" there is a false data point in every iteration. 

Download All
0 Kudos
Message 3 of 13
(2,995 Views)
Solution
Accepted by topic author bernat_serra

Hi bernat,

 

get rid of the TermChar property and wire a constant of 99 instead!

 

TermChar is 10 by default, so you get problems as soon as your message is 10 bytes or longer...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 13
(2,992 Views)

Okey! Thank you a lot, I tried that and it works! So stupid mistake...

0 Kudos
Message 5 of 13
(2,986 Views)

I have also solved the issue of representing the data every 0,5 seconds puting a case structure with an input of boolean type that says me if the time is multiple of 500 ms. The problem is that in some iterations it skips one data, but in general it works okey.

Download All
0 Kudos
Message 6 of 13
(2,966 Views)

Hi Bernat,

 

The problem is that in some iterations it skips one data, but in general it works okey.

Using Q&R on float values can be tricky…

 

Why don't you just follow the requirements and update the graph each time 500ms has elapsed?

check.png

There should be NO wait function in the loop when you acquire data: the VISARead will do the timing of the loop!

You only need the wait in the "no acquire" case, so place the wait function inside that case!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 13
(2,964 Views)

Thank you for the quick response!

 

Yes you are right but I have save the data in the excel and these are the values. As you can see it is not exact... it should be 500,1000,1500,2000,2500,... I don't know why this happens.

 

 

Download All
0 Kudos
Message 8 of 13
(2,957 Views)

Hi bernat,

 

the communication takes its time, and runs in parallel to ElapsedTime. So you can't expect exact times this way.

Either use it like it is - or decouple DAQ from data saving: put logging into its own loop and have that loop run at 500ms intervals. Transfer data using local variables (or use other ways like notifiers)...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 13
(2,944 Views)

Okey thank you! And the last question, if I had to graph all the data inside this 0,5 seconds, how would you do it? I tought about saving the data and every 0.5 seconds put it on the graph but I don't know how to do it.

 

Regards,

 

Bernat Serra

0 Kudos
Message 10 of 13
(2,921 Views)