From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-01-2016 12:48 PM
Hello, Guys
I wanna send two difference Variables (ٍSensor Data & time) Via Serial port from Arduino to LabVIEW (NI-VISA).
I worked on the Code but receives one variable
VI in Attachment
Regards.
Solved! Go to Solution.
04-01-2016 01:02 PM - edited 04-01-2016 01:02 PM
First of all, how are you sending the data from the Arduino? What does the data string look like from the Arduino?
You should be using the Println on the Arduino side. This appends a termination character (End Of Line, 0xA, to be more exact) to the message that we can use on the LabVIEW side.
I would go with either a comma or a tab between your two variables in the string.
Now on the LabVIEW side, we leave the default of using the termination character turned on (boolean input on the Configure Serial Port). With it enabled (which is the default), the VISA Read will stop reading from the port when one of three things happen: 1) reads the number of bytes it was told, 2) reads a termination character, or 3) have a timeout (default of 10 seconds). So what we do is tell the VISA Read to read more bytes than we ever expect in a message. This way it will stop reading when the termination character is read and we therefore know we got the full message.
I also recommend you learn to use the Scan From String function. It is very useful for parsing string data.
Here is an example. I just assumed a comma serating the variables and the time was just a floating point number.
04-01-2016 03:00 PM
Thank you so mutch