LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW and Arduino Uno

Hello,

 

I'm attempting to send acceleration data from my Arduino Uno to LabVIEW so that I can graph, calibrate, and eventually digitally filter the data. I am absolutely stumped, it seems like it should be very simple. I want to read the digital I2C ports (SCL and SDA) from the Arduino, I have attached my VI so hopefully someone can tell me what I'm doing wrong. This is what I'm doing currently, maybe I'm missing a vital step (note: I have the LIFA firmware installed on the Arduino),

 

1. Open the Arduino IDE and upload the code to get acceleration data from the LIS3DH accelerometer, here's the Arduino code for that:

#include <Wire.h> //I2C Arduino Library 


#define address 0x19 //I2C 7bit address 


void setup(){ 
  //Initialize Serial and I2C communications 
  Serial.begin(9600); 
  Wire.begin(); 
   
  //Put into the correct operating mode 
  Wire.beginTransmission(address); //open communication with 
  Wire.write(0x20);  
  Wire.write(0x27);  
  Wire.endTransmission(); 
}     


void loop(){ 
   
  int x,y,z,a,b,c; //triple axis data 


  Wire.beginTransmission(address); 
  Wire.write(0xA8); 
  Wire.endTransmission(); 
   
  
//Read data from each axis 
  Wire.requestFrom(address, 6); 
  if(6<=Wire.available()){ 
     x = (int)Wire.read();  
    x |= (int)Wire.read()<<8;  
    y = (int)Wire.read();         // Note change in operator on this and next three statements
    y |= (int)Wire.read()<<8;     
    z = (int)Wire.read(); 
    z |= (int)Wire.read()<<8;
  } 
   
  //Print out values of each axis 
  Serial.print("x: "); 
  Serial.print(x); 
  Serial.print("  y: "); 
  Serial.print(y); 
  Serial.print("  z: "); 
  Serial.println(z); 
  delay(450);
}

2. Open the LabVIEW VI and click run

 

Also the baud rate for the "Arduino Init" on the block diagram keeps changing back to 115200 even after I change it to 9600 which I don't really understand.

 

Is there something else I need to do? Do I need to put code into the Arduino IDE to send the data into LabVIEW?

 

Feel free to ask more questions if anything I said isn't clear, thank you in advance.

0 Kudos
Message 1 of 19
(6,568 Views)
0 Kudos
Message 2 of 19
(6,560 Views)

Are you trying to use the LIFA toolkit or not?  Your LabVIEW source looks like you are, but your Arduino source looks like it isn't.  If you are wanting to write your own Arduino firmware then you'll want to use the VISA functions which talk directly to your COM ports.  If you are wanting to use the LIFA or LINX toolkit you'll want to upload that firmware then use the VIs from your palette to talk to the hardware.

0 Kudos
Message 3 of 19
(6,557 Views)

I feel that I gave more information here and explained the problem better. So I figured I'd make a new post, is that not acceptable?

0 Kudos
Message 4 of 19
(6,553 Views)

Yes, I am attempting to use the LIFA toolkit, I have the LIFA firmware uploaded on the Arduino. Are there specific blocks I need to use for the LIFA toolkit, can I not just use the Arduino blocks like I currently am?

0 Kudos
Message 5 of 19
(6,549 Views)

@cuuddii wrote:

I feel that I gave more information here and explained the problem better. So I figured I'd make a new post, is that not acceptable?


The proper etiquette is to continue in your ORIGINAL thread.

That is the accepted way of acting on a message board.

 

0 Kudos
Message 6 of 19
(6,534 Views)

Well the subject changed a bit between threads, I don't think it is terrible to make a new thread but linking to the original is a good idea.  For some reason I didn't realize this was a related issue.  Also others who are subscribed to the other thread won't get notifications on this thread, but they would if you replied to that one.

 

Before trying to read I2C or SPI, can you get normal analog inputs working with LIFA?  I believe there is some examples on how to sample an AI but it looks like you are on the right track.  If you can't establish communication and read an analog then there is other issues, like possible baud issues.  The baud selected needs to match, and be the same between the LabVIEW source, and the firmware on the Arduino.  I'm unsure what the default for LIFA is but it might appear to change because it keeps going back to the default, which the firmware has.

0 Kudos
Message 7 of 19
(6,524 Views)

@Hooovahh wrote:

Well the subject changed a bit between threads,

 

 


Actually nothing has changed.

He is still trying to use LabVIEW with an Arduino with an acceleromotor.

 

 

 

0 Kudos
Message 8 of 19
(6,520 Views)

I'll see if I can get the analog inputs to work with LIFA. About the baud rate, do you think I need to change it within the LIFA firmware? I was looking at another thread and it seems other people were having similar issues with the baud rate (link below).

 

 

https://forums.ni.com/t5/LabVIEW/Arduino-MEGA-2560-with-115200-baud-rate/td-p/1963481

0 Kudos
Message 9 of 19
(6,509 Views)

The complaint in that thread is that the user tried increasing the baud rate from 9600.  If you did not change the firmware, then the default is 9600 and you should stick with that.

0 Kudos
Message 10 of 19
(6,501 Views)