LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read Multiple analogue data using VISA in Arduino

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 LabVIEW fileThis is my LabVIEW file

 

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);
  
}
0 Kudos
Message 1 of 11
(1,460 Views)

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)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 11
(1,457 Views)

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.


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 3 of 11
(1,425 Views)

@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 LabVIEW fileThis is my LabVIEW file

 

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

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
Message 4 of 11
(1,419 Views)

Knight Of NI thanks for solution i have added ScanFromString and this errors came up. 

image.pngimage.png

0 Kudos
Message 5 of 11
(1,415 Views)