01-11-2024 06:10 AM
I am trying to separate the Voltage and current value coming from serial port using VISA. But only first value is reading. What would be the error?
This is my Arduino code
void setup() {
Serial.begin(115200);
}
void loop() {
float voltage = analogRead(A0);
float current = analogRead(A1);
Serial.print(voltage);
Serial.print(",");
Serial.println(current);
delay(100);
}
01-11-2024 06:21 AM
Hi Gappiya,
why do you convert a string of two values into a 2D array of data?
Why do you try to index row 0 and 1?
Why do you use such a format string for this specific conversion function?
Suggestion:
Replace SpreadsheetStringToArray by ScanFromString and use the same format string to get two outputs from your two values (per message)…
01-11-2024 07:15 AM
The Spreadsheet String To Array function defaults to using the tab as the delimiter while your sketch is using a comma. But that does not matter here since you would be better off here just simply using Scan From String to parse the string into the two values.
01-11-2024 07:22 AM
@Gappiya wrote:
I am trying to separate the Voltage and current value coming from serial port using VISA. But only first value is reading. What would be the error?
This is my Arduino code
void setup() { Serial.begin(115200); } void loop() { float voltage = analogRead(A0); float current = analogRead(A1); Serial.print(voltage); Serial.print(","); Serial.println(current); delay(100); }
For such a simple task, LINX or Hobbyist toolkit will simplify the code a lot.
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019TmpSAE&l=en-US
01-11-2024 07:39 AM
Knight Of NI thanks for solution i have added ScanFromString and this errors came up.