LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read 2 analog inputs with VISA

Hello everyone! I want to read two analog inputs using VISA serial communication from the arduino.  I'm currently able to read one of the input but how do I read two analog inputs on labview?

0 Kudos
Message 1 of 20
(5,515 Views)

Hi lamela,

 

you need to write an Arduino sketch that sends you those two measurement values.

Then you need to adapt your VI to handle both values by correctly parsing the received string.

 

I think we already discussed the term "correctly parsing" in your other threads… 🙂

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 20
(5,510 Views)

You might want to just look into using Linx.



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
0 Kudos
Message 3 of 20
(5,442 Views)

I'm using the arduino yun and I don't think it's compatible with LINX or LIFA?

Ok, I will include another input on the arduino sketch. 

 

I will do two serial print on the arduino: 

Serial.println(Voltage, 3); 

Serial.println(Current, 3);

 

Is it to include the termchar? Do you have a sample for reference?

0 Kudos
Message 4 of 20
(5,372 Views)

Hi lamela,

 

why don't you send just one message/line with two samples?

Something like "Serial.println(Voltage, 3, Current, 3)"? (I don't know the exact syntax of Arduino sketches, but you can figure this out!)

And yes: use the termchar as is included with println!

 

Advantage: one received string in LabVIEW contains both values. No hassle with determining the correct order of the values…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 20
(5,369 Views)

What about comparing the two signals? If I have one string with the two values, how do I get the respective signal for each?

So I will enable the termchar for the LF?

0 Kudos
Message 6 of 20
(5,340 Views)

Hi lamela,

 

If I have one string with the two values, how do I get the respective signal for each?

As has been said before: by correctly parsing the string!

 

So I will enable the termchar for the LF?

I don't know what is your "LF", but I recommend to use a TermChar with each serial communication…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 20
(5,337 Views)

@lamela wrote:

What about comparing the two signals? If I have one string with the two values, how do I get the respective signal for each?

So I will enable the termchar for the LF?


If you make the string you output something like "Voltage,Current", then you can just use Scan From String with the format "%f,%f" and you will have your two values coming out.

 

I'm pretty sure the println command includes the LF (Line Feed, 0xA).  So if you use the Configure Serial Port, you can just leave the Termination Character Enable and Termination Character inputs unwired since they default to enabled and the Line Feed.  And when you do this, you do not need that Bytes At Port, you just set the number of bytes to read to something like 50 and the VISA Read will stop the read when that Line Feed is found.



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
0 Kudos
Message 8 of 20
(5,312 Views)

Ok, if I Serial.println(Voltage, Current);  and I use Scan From String with %f, %f format, the output one is showing the value but the other is showing 0?

What am I doing wrong?

 

0 Kudos
Message 9 of 20
(5,275 Views)

Hi lamela,

 

What am I doing wrong?

Big mistake: You still haven't learned you need to provide examples to allow us to answer your questions!

 

What is the string you receive in LabVIEW? Does ScanFromString give an error output?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 20
(5,241 Views)