08-05-2015 01:43 AM - edited 08-05-2015 01:49 AM
I think the string is showing one value from the two inputs, how do I separate the two inputs so that it is showing two values like 10 and 11 instead of showing a changing value from 10-11?
If I use the scan from string function, it gives me this error:
Scan failed. The input string does not contain data in the expected format.
or
Error 1 occurred at Scan From String (arg 1):
LabVIEW: An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.
my code to serial print two inputs: Serial.println(Voltage, Current);
Even if I print separately: Serial.println(Voltage);
Serial.println(Current);
It still only shows one value.. maybe that is the reason why the the Scan From String function shows one value only?
I've tried serial printing two of the input one at a time and it is correct.
08-05-2015 01:50 AM - edited 08-05-2015 01:53 AM
Hi lamela,
again I have to ask: HOW does the string look like? Is it so hard to provide an exact example of your received string???
I think the string is showing one value from the two inputs
Are you sure or are you guessing? How can we tell what you might "think" when you aren't able to provide examples?
You wrote you send values from the Arduino using the command "println(value1, value2)", but now you "think" you only receive ""value1" in LabVIEW?
Get your data communications clear! (And learn to provide meaningful examples!)
Edit after your edit:
my code to serial print two inputs: Serial.println(Voltage, Current);
Even if I print separately: Serial.println(Voltage);
Serial.println(Current);
The first command is completely different then the second part! In the first you should receive two values in one line, in the 2nd one you receive one value per line: You need to adapt your string parsing to these strings!
Again: send both values in one line. Use the LF as termchar. Separate the values by some separator char like comma. Check the received string for validity. Use some error checking in your VI.
08-05-2015 01:58 AM
Ok, I'm using the one line code now and I added the termchar but it still shows one value now? What should I do?
08-05-2015 02:09 AM - edited 08-05-2015 02:09 AM
Hi lamela,
you still don't use Ctrl-U on your block diagram? Is it so hard to use the keyboard from time to time?
I'm using the one line code now and I added the termchar but it still shows one value now?
Which string do you send from the Arduino? Did you debug this and did you compare the string generated in the Arduino with the one received by LabVIEW?
What should I do?
As I wrote in my last message: add a separator char between your two values!
And I would also limit the number of digits per value. How accurate does the Arduino measure voltages? With a 12bit ADC you only need 4 digits per value…
08-05-2015 03:33 AM - edited 08-05-2015 03:36 AM
How to add a separator char between the two values? I've checked already and the string is showing both the values at once.. so basically it keeps changing from current value to voltage value. The string in the arduino serial monitor will show two of the correct values but labview shows both that is ever changing?
Do you have a solution to this? My project deadline is getting closer and closer!
08-05-2015 03:36 AM
08-05-2015 03:51 AM
So I have to add something on the code to make labview display the two values separately?
print code: Serial.println(Voltage, Current);
08-05-2015 03:58 AM
Hi lamela,
yes, you need to add a spearator to allow LabVIEW correctly parse the string!
As said before I would use a comma between the values, something like "println(value1, ",", value2)".
And as also said before I don't know the correct syntax for your Arduino sketch, you need to figure that one out on your own!
08-05-2015 09:27 PM - edited 08-05-2015 09:50 PM
I've added the separator char and it is showing two values from the string. But the Scan From String function is only showing the value of the voltage(Voltage0) but not the current(Voltage1)?
Here is the error if I don't input the error in and out:
LabVIEW: Scan failed. The input string does not contain data in the expected format.
How can I get both the readings and signals out from the Scan From String function? What can I do?
my code:
Serial.print(Voltage0);
Serial.print(", ");
Serial.println(Voltage1);
08-05-2015 09:58 PM
I got it working already! I just added a comma between the two %f for Scan From String function so it becomes %f, %f.