11-05-2018 12:10 PM
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
Solved! Go to Solution.
11-05-2018 01:16 PM
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".
11-05-2018 01:41 PM
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.
11-06-2018 11:25 AM
Fewoiz, this is how my string display reads
11-06-2018 11:26 AM
Crossrulz,
I will try that method and let you know how it goes.
Thanks
11-07-2018 02:57 PM
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
11-07-2018 03:56 PM
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)
11-07-2018 04:17 PM
I'm confused. I thought the same thing as RavensFan until I read this.
11-07-2018 04:44 PM
Interesting.
Then how do you print a literal backslash and "t"?
Why would this behave differently than other text based languages?
11-07-2018 05:02 PM
I'm starting to wonder if it is how their (Arduino IDE) serial monitor interprets the code. I need to study this example.