08-03-2015 04:47 AM
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?
08-03-2015 04:53 AM
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… 🙂
08-03-2015 07:26 AM
You might want to just look into using Linx.
08-04-2015 03:22 AM
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?
08-04-2015 03:29 AM - edited 08-04-2015 03:30 AM
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…
08-04-2015 04:13 AM
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?
08-04-2015 04:16 AM
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…
08-04-2015 06:38 AM
@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.
08-05-2015 12:12 AM
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?
08-05-2015 01:33 AM
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?