LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA read to array/graph

Solved!
Go to solution

Hi,

 

I've been dabbling into LabVIEW for a few months and have had quite of bit of success using it (created a fully automated state machine run system with cRIO).  I'm on to my next project and I'm running into an issue that seems like it should be a simple fix but my lack of programming knowledge has me at a halt.  I'm reading data from a card that I programmed with arduino (UNO R3) and am now reading it with LabVIEW (the continuous read and write example).  I'm reading the data fine with string but I want to be able to separate the data onto an array and create individual thermometers for each (if possible).  I find some info online but I'm not sure if I'm filling out "the blanks" correctly (delimiters and what not).  I'll attach the VI along with the code from Arduino and a picture.

 

Best,

Josh

0 Kudos
Message 1 of 15
(3,142 Views)

Can you give me an example of your string?  For example is the temperature string like this "15; 16; 17; 18" or "Sensor05 is: 15; Sensor05 is: 16; Sensor05 is: 17; Sensor05 is:  18".

 

 

0 Kudos
Message 2 of 15
(3,120 Views)

I would rewrite your Ardunio code to read all of the sensor data and put it in variables.  Then use a single Serial.println() command to format and write the data.  I would separate your readings with a tab.  Then it is simple enough to use the Spreadsheet String To Array on your read line to get all of your 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
0 Kudos
Message 3 of 15
(3,112 Views)

Fewoiz, this is how my string display reads

read display.PNG

0 Kudos
Message 4 of 15
(3,085 Views)

Crossrulz, 

 

I will try that method and let you know how it goes.

 

Thanks

Message 5 of 15
(3,084 Views)

Crossrulz,

 

You'll have to forgive me, I'm also terrible with c++, I really need to take a class and learn on my free time.  I was able to change the code to read by tab but I'm not really sure where to go from there when you say to read all of the sensor data and put it in variables or how to put it into code exactly?

 

// This Arduino sketch reads DS18B20 "1-Wire" digital
// temperature sensors.
// Tutorial:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 12


// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// Assign the addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

DeviceAddress Sensor01 = { 0x28, 0xDE, 0x7B, 0x50, 0x2F, 0x14, 0x01, 0x4E };
DeviceAddress Sensor02 = { 0x28, 0x29, 0x29, 0x4B, 0x2F, 0x14, 0x01, 0x03 };
DeviceAddress Sensor03 = { 0x28, 0xED, 0x56, 0x69, 0x2F, 0x14, 0x01, 0x35 };
DeviceAddress Sensor04 = { 0x28, 0x6E, 0x4C, 0x68, 0x2F, 0x14, 0x01, 0xC8 };
DeviceAddress Sensor05 = { 0x28, 0x4B, 0xA6, 0x5E, 0x2F, 0x14, 0x01, 0xB3 };



void setup(void)
{
  // start serial port
  Serial.begin(9600);
  // Start up the library
  sensors.begin();
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(Sensor01, 10);
  sensors.setResolution(Sensor02, 10);
  sensors.setResolution(Sensor03, 10);
  sensors.setResolution(Sensor04, 10);
  sensors.setResolution(Sensor05, 10);
}

void printTemperature(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(tempC);
    Serial.print(" F: ");
    Serial.print(DallasTemperature::toFahrenheit(tempC));
  }
}

void loop(void)
{ 
  delay(2000);
  Serial.print("Getting temperatures...\n\r");
  sensors.requestTemperatures();
  
  Serial.print("Sensor01 is: ");
  printTemperature(Sensor01);
  Serial.print("\t");
  Serial.print("Sensor02 is: ");
  printTemperature(Sensor02);
  Serial.print("\t");
  Serial.print("Sensor03 is: ");
  printTemperature(Sensor03);
  Serial.print("\t");
  Serial.print("Sensor04 is: ");
  printTemperature(Sensor04);
  Serial.print("\t");
  Serial.print("Sensor05 is: ");
  printTemperature(Sensor05);
  Serial.print("\t");
}

Sorry,

Josh

0 Kudos
Message 6 of 15
(3,060 Views)

It looks like your C code is sending literal "\t" and "\r\n".  Those are not tabs, carriage returns or linefeed characters but backslashes and "t", "r", and "n".

 

You need to send the ascii character.  In basic it would be chr$(9)  chr$(13)  chr$(10)

0 Kudos
Message 7 of 15
(3,055 Views)

I'm confused. I thought the same thing as RavensFan until I read this

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 8 of 15
(3,051 Views)

Interesting.

 

Then how do you print a literal backslash and "t"?

 

Why would this behave differently than other text based languages?

0 Kudos
Message 9 of 15
(3,048 Views)

I'm starting to wonder if it is how their (Arduino IDE) serial monitor interprets the code. I need to study this example.  

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 10 of 15
(3,046 Views)