05-08-2012 02:48 PM
Hi,
I am new to Arduino and Labview and I have an Arduino Mega and Uno that are communicating with each other using I2C. The Uno is sending data to the Mega. The communication worked when I use serial monitor to read from Mega, however when I upload the LIFA firmware to the Mega and try and use Labview to read the data that the UNO is sending it gives me 5003 timeout error. I have tried to increase the time out but it still doesn’t work. Does anybody know what I am doing wrong? I have also attached the Uno sketch and the Labview VI I am using. I would be grateful if anyone can help.
05-09-2012 01:18 AM
You have to use the same baud rate in LabVIEW and what is in the LIFA firmware. If you are using the latest version then you need to use 9600 and not 115200 for the Arduino Mega 2560.
05-09-2012 02:14 PM
Nathan,
Thanks for your help, I changed the baud rate to 9600 but I am still getting the 5003 error which is due to a timeout while trying to read from Arduino.
05-09-2012 06:57 PM
I added a 7 in : Wire.begin(7); // join i2c bus (address optional for master) in my code and I also changed the 4 to 7 in my VI for the I2C read block. It looks like I am reading something but now I am only reading 255!!!
05-14-2012 03:16 AM
I have the same setup and the labview get only the last byte
any suggestions?
Thanks
my skech:
#include <Wire.h>
#include <SHT1x.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5,6,7);
// Specify data and clock connections and instantiate SHT1x object
#define dataPin 10
#define clockPin 11
SHT1x sht1x(dataPin, clockPin);
int x=0;
float temp_c;
float temp_f;
float humidity;
int t;
int h;
void setup()
{
lcd.begin(20,4);
lcd.print("starting program");
delay(1000);
lcd.clear();
Wire.begin(2); // join i2c bus with address #2
Wire.onRequest(requestEvent); // register event
}
void loop()
{
// Read values from the sensor
temp_c = sht1x.readTemperatureC();
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();
t=temp_c;
h=humidity;
lcd.setCursor(0, 1);
lcd.print("Temp:");
lcd.print(temp_c);
lcd.setCursor(0, 2);
lcd.print("Humidity:");
lcd.print(humidity);
delay(100);
}
// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent()
{
Wire.write(t); //
Wire.write(h); //
// as expected by master
}
12-17-2012 04:04 AM
Hi All,
I am currently trying to do the same kind of thing ... But I got a problem ..
You can find the VI I use in screenshot below..
The problem is that I always have this error code : 5003 : LabVIEW Interface for Arduino.lvlib:I2C Read.viLabVIEW Interface for Arduino.lvlib:I2C Init.viLabVIEW Interface for Arduino.lvlib:Init.vi. A timeout occurred while trying to read form the Arduino.
What can my problem be ? I have already tried to change the baud rate to 9600 both in the arduino soft and in tha VI, but no change, still got this error code ..
The problem can't be coming from the wiring since I've tried to transmit datas between the two arduinos with the Arduino soft and it is alright (viewing with the serial monitor such as cutluss did).
Any advice ?
Thank for your help,
BRs,
Oscar
12-17-2012 09:44 PM
Do you ever use the "abort execution" button in LabVIEW? (the little red stop sign).
P.S. soft???
P.P.S. Avoid using the abort execution button as much as possible when using LIFA. Using the abort execution button between the init and close VIs may prevent the COM port from being release properly and you will get a timeout error after this happens. When this happens, you may need to completely close LabVIEW (including the splash screen) and then re-opening your VI. (this is based on my experience and learning this the hard way ).
12-17-2012 09:46 PM
YES
09-13-2013 03:53 PM
Old thread but just to add. Try chaning one of the board that can be faulty. As I got similar problem with ADXL345, when uploaded sketch it was reading all 3 axis but not correct on "serial monitor" arduino software, but when I uploaded LIFA firm trying to comminucate in labview via I2C, I was getting same error as you do.
Replacing the ADXL345 solved all the problem !
12-12-2014 03:13 PM
This program stops working when I put to read higher values of 1. When the reading value is zero (0) it works without error