LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino serial communication

Solved!
Go to solution

I connected ZMPT101B voltage sensor to Arduino and got 0 - 5VAC reading. I have written a simply code to display Vrms value. This is the code. 

 

 

#include <ZMPT101B.h>
#define SENSITIVITY 735.0f

// ZMPT101B sensor output connected to analog pin A0
// and the voltage source frequency is 50 Hz.
ZMPT101B voltageSensor(A0, 50.0);

void setup() {
  Serial.begin(115200);
  voltageSensor.setSensitivity(SENSITIVITY);
}



void loop() {
  float voltage = voltageSensor.getRmsVoltage();
  Serial.println(voltage);

  delay(1000);
}

 

 

I want to read this voltage number using LabView. How can i do this. This is the sample Vi file that i create to read the analogue reading. But i want to  read this voltage number. Serial.Println (voltage); 

image.png

 

0 Kudos
Message 1 of 6
(957 Views)
Solution
Accepted by Gappiya

Hi Gappiya,

 

why do you use LINX functions when all you need is the VISARead to actually read the data written in your Arduino sketch to the serial port of the Arduino?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(929 Views)

In general there are three ways of using LabVIEW with an Arduino

 

  1. Program the Arduino in the native Arduino language.
    1. LabVIEW can communicate with an Arduino using VISA just like any other instrument on a serial port.
    2. IMHO: This is the best way as you have full control over the communications protocol and access to all of the of Arduino libraries and LabVIEW toolkits that are already out there.
    3. I highly recommend watching this video on serial communications: VIWeek 2020/Proper way to communicate over serial
  2. Use LINX Now called the LabVIEW Hobbyist Toolkit (LIFA has long since been deprecated)
    1. Full LabVIEW integration
    2. Limited amount of Arduino libraries and peripherals directly supported
    3. The Arduino runs a special sketch and basically becomes a USB DAQ device that always needs to be connected to a computer.
  3. TSXperts Arduino compiler for LabVIEW
    1. Actually turns LabVIEW into compiled Arduino code. (A real feat on its own)
    2. Limited subset of LabVIEW vi's and primitives
    3. Very limited support for Arduino libraries 
    4. Development has stopped, so those annoying bugs are here to stay

 

 

========================
=== Engineer Ambiguously ===
========================
Message 3 of 6
(867 Views)

@RTSLVU wrote:
  1. Use LINX Now called the LabVIEW Hobbyist Toolkit (LIFA has long since been deprecated)
    1. Full LabVIEW integration
    2. Limited amount of Arduino libraries and peripherals directly supported
    3. The Arduino basically becomes a USB DAQ device that always needs to be connected to a computer.

An additional comment on LINX with the Arduino.  The LINX library uses a set sketch for the Arduino.  The LabVIEW driver then uses the commands pre-defined in the sketch to make it do what is needed.  If you write your own sketch, the LINX libraries will not work.  At that point, just do the simple VISA Read to get the data coming from your Arduino.


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 4 of 6
(859 Views)

Thank you. I am building a power analyzer. So, I needed to analyze the graph using LabVIEW. That's why i took analogue reading for further analyses. But thank you for your idea. I will do in that way. 

0 Kudos
Message 5 of 6
(828 Views)

@crossrulz wrote:

@RTSLVU wrote:
  1. Use LINX Now called the LabVIEW Hobbyist Toolkit (LIFA has long since been deprecated)
    1. Full LabVIEW integration
    2. Limited amount of Arduino libraries and peripherals directly supported
    3. The Arduino basically becomes a USB DAQ device that always needs to be connected to a computer.

An additional comment on LINX with the Arduino.  The LINX library uses a set sketch for the Arduino.  The LabVIEW driver then uses the commands pre-defined in the sketch to make it do what is needed.  If you write your own sketch, the LINX libraries will not work.  At that point, just do the simple VISA Read to get the data coming from your Arduino.


That's a good point I have updated my generic Arduino and LabVIEW response to better clarify that it

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 6
(792 Views)