12-28-2018 09:57 AM - edited 12-28-2018 09:58 AM
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.
Solved! Go to Solution.
12-28-2018 11:11 AM
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.
12-29-2018 05:24 AM - edited 12-29-2018 05:42 AM
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.
12-29-2018 05:54 AM
12-29-2018 09:19 AM
Okey! Thank you a lot, I tried that and it works! So stupid mistake...
12-29-2018 11:14 AM
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.
12-29-2018 11:33 AM - edited 12-29-2018 11:33 AM
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?
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!
12-29-2018 12:26 PM - edited 12-29-2018 12:36 PM
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.
12-29-2018 03:51 PM
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)...
01-02-2019 03:55 AM
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