LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interfacing Arduino Uno R3 with LabVIEW

I have an 8-channel multiplexer. I want to select each channel sequentially, say Input I0 and then I1 .... to I7. I am using an Arduino Uno R3 to select input lines by the select lines (S0, S1, S2). I have done that using Arduino. Now I want to select the inputs by using LabVIEW.


Can I use (upload) the Arduino codes/ scripts to select that? I couldn't find anything on that.

 

How can I select inputs in LabVIEW?

 

Pic1: A mux block diagram

Pic2: Displaying the S0, S1, and S2 values from Arduino code

 

I really appreciate any help you can provide.

Regards

 
------
Arduino CodesMux.jpegAdruinoSimsOnline.PNG 
 
#define enPin 2
#define channelA 4
#define channelB 7
#define channelC 8

 

void setup() {
  // setup codes
Serial.begin(9600);
//Init CD4051B
 pinMode(channelA, OUTPUT);
 pinMode(channelB, OUTPUT);
 pinMode(channelC, OUTPUT);
 pinMode(enPin, OUTPUT);
 digitalWrite(channelA, LOW);
 digitalWrite(channelB, LOW);
 digitalWrite(channelC, LOW);
 digitalWrite(enPin, LOW);
}
int chnl = 0;

 

void loop() {
  if (chnl != 8)
  {
 int A = bitRead(chnl,0); //Take first bit from binary value of i channel.
 int B = bitRead(chnl,1); //Take second bit from binary value of i channel.
 int C = bitRead(chnl,2); //Take third bit from value of i channel.
 digitalWrite(channelA, A);
 digitalWrite(channelB, B);
 digitalWrite(channelC, C);
Serial.print(F("Printing "));Serial.print(C);Serial.print(B);Serial.print(A);
  chnl++;
  Serial.println(F(" "));
  delay(1000);
  }
}
0 Kudos
Message 1 of 4
(2,192 Views)

Well the simplest way would be to program the Arduino in its native language as there is no direct support for your MUX in LINX or the long since deprecated LIFA.

 

You will need to make up your own little "command set" to change the MUX by sending commands through the serial port using the serial monitor that is built in to the Arduino IDE or any other terminal program like Terra-Term

 

Once you have that working write a LabVIEW program to do the same thing with the Arduino using VISA just like any other instrument on a serial port.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 4
(2,177 Views)

Hello there,

There are multiples ways to do it.

I will explain 2 of them.

 

Way 1:

1. Make a Arduino code to read the serial integer data and take action as per the serial input. 

You will need to use Serial.read or Serial.readString input. 

2. Use VISA serial drivers of LabVIEW.

Initialize VISA, Use VISA write to send the integer data. Make UI as per your requirement. 

3. Integrate. Working - whenever you will send data from LabVIEW, Arduino will read the serial data and accordingly it will select Mux. - Done.

 

Way 2:

1. Use MakerHub's LINX or LIFA

Reference links to learn. 

https://www.labviewmakerhub.com/doku.php?id=learn:tutorials:libraries:linx:getting_started

 

https://forums.ni.com/t5/LabVIEW-Interface-for-Arduino/ct-p/7008

 

2. Upload pre-built firmware of Arduino by LIFA or LINX.

 

3. Write complete logic using The APIs provided.

 

NO Need to make any Arduino code for Way 2.

0 Kudos
Message 3 of 4
(2,175 Views)

@RTSLVU wrote:

Well the simplest way would be to program the Arduino in its native language as there is no direct support for your MUX in LINX or the long since deprecated LIFA.

 

You will need to make up your own little "command set" to change the MUX by sending commands through the serial port using the serial monitor that is built in to the Arduino IDE or any other terminal program like Terra-Term

 

Once you have that working write a LabVIEW program to do the same thing with the Arduino using VISA just like any other instrument on a serial port.


On second thought I guess you could use LINX as I am guessing you are using a few of the DIO lines to address your MUX 

 

So you could:

  1. Use the LINX Digital Output vi to select your MUX channel by setting the proper DIO pins
  2. Use LINX Analog Read vi to get the voltage
  3. Repeat until done...
========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 4
(2,165 Views)