Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

I have a Problem in Serial NI-VISA

Solved!
Go to solution

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.

 

0 Kudos
Message 1 of 3
(3,683 Views)
Solution
Accepted by topic author Eng.Arafa

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.


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 2 of 3
(3,678 Views)

Thank you so mutch

0 Kudos
Message 3 of 3
(3,664 Views)