LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems when using Arduino + Xbee + Labview

Hello, I am using an Xbee module mounted on a  Xbee shield connected to my computer, and an Arduino UNO (with another xbee module) connected to a servo-motor. I want to control the angle of the motor remotely using Labview. I have set baud rates to the standar value of 9600 when configuring the xbee modules, in the LabviewInterface.h and in the Labview program. If I run the program, there is communication between both xbee modules but there is a huge and non-deterministic delay (more than 3 or 4 seconds) between the moment I send an order and the moment of its execution by the remote Arduino. Moreover, I have explored the errors and intermittenly I found the next message:

LabVIEW Interface for Arduino.lvlib:Servo Write Angle.viLabVIEW Interface for Arduino.lvlib:Configure Servo.viLabVIEW Interface for Arduino.lvlib:Set Number of Servos.viLabVIEW Interface for Arduino.lvlib:Init.vi.  A timeout occurred while trying to read form the Arduino.

I have no experience with Arduino, Xbee and LIFA, so I would appreciate any help.

Thank you.

0 Kudos
Message 1 of 17
(13,396 Views)

The first thing I would try is to take wireless out of the equation and connect directly to the Arduino and see if you continue to see issues. That way we know if its the wireless connection or something else causing the errors and delay.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 2 of 17
(4,842 Views)

Hard to say without seeing your code, but maybe check that the open VISA is only done once. There is one of the two options Xbee or Arduino in the open comm VI (can't remember which now), that has a built-in 4-5 sec delay. But this should only happen when you open the connection. If you leave it open, and do subsequent read or write on that same connection there should not be any delay. To check if the issue is related to the LIFA or the Xbee, may be try to do something simple simple like writing to one of the DO of the Arduino and see if the delay you see is gone.

Laurent

0 Kudos
Message 3 of 17
(4,842 Views)

I have already checked the wireless communication between both xbee modules with standar code implemented by the Arduino software and it works correctly. I also checked the LIFA with a simple example of controlling a servo (without wireless communication) and it worked properly.  My problem appears only when I try to use LIFA with Xbee to communicate with the Arduino UNO wirelessly.

I attach the VI I am using in order to clarify how the program is implemented:

Prueba1d.png

Thank you very much.

0 Kudos
Message 4 of 17
(4,842 Views)

I could solve the original problem but I found a new one. The original problem was related to the communication parameters of both Xbees. I corrected then and now the delay has disappeared (I don't know why this occured with Labview but not with the Arduino software). Now the problem is that Labview hardly ever detects remote Arduino (but sometime it does), and I am wondering if the input "Bytes per packet" with the default value "15" conditions some communication characteristics of Xbee modules. In this case, it could be the problem and I could fix it correcting this (or these) parameter(s) when configuring Xbees with X-CTU. If not, I cannot find out which is the mistake.

Thank you.

0 Kudos
Message 5 of 17
(4,842 Views)

Which Xbee are you using : Xbee S1, pro? what type of antenna, and how far apart are they?  Is the Xbee you use to talk to remote Arduino connected to your PC via a usb adpater?

I would suggest, as a precautionary measure, to set the Xbee channel differently than the Wifi channels of your router if you have one, so that the freq bands are clearly not overlapping...

By not detecting, you mean you are getting Error 5003 whent the ARduino OPen vi?

L.

0 Kudos
Message 6 of 17
(4,842 Views)

I am using Xbee S2 with a flat blue antenna, and they are together (20 centimeters of distance). As you said, the Xbee I use to talk to remote Arduino is connected to my PC via the Arduino Shield and a USB cable.

I find that my problem only appears when I use LIFA because I have created a VI to perform the communication with standar VISA serial blocks and it works perfectly. It only fails with LIFA, maybe there is something I have to change in LVIFA_base (or LABVIEWInterface) or I have to adjust communication parameters according to the LIFA communication protocol.

I find the Error 5002: Init.vi.  Unable to establish connection with Arduino.  Please ensure that you have selected the correct COM port and that you have flashed the Arduino with the correct firmware.

Even I am noticing that  after this error, if I want to recompile the LVIFA_base in the Arduino sometimes it fails and says:

Problem updating to board. See http://www.arduino... for suggestion:

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64

avrdude: stk500_cmd(): programmer is out of sync

Thank you.

Mariano

0 Kudos
Message 7 of 17
(4,842 Views)

I could fix it, I made a mistake when I first used LVIFA_base because it asked me to change some functions which were obsolete and I corrected one of them wrong.

Thank you for all your help.

0 Kudos
Message 8 of 17
(4,842 Views)

Hi, I'm trying to find the best way to do wireless communication with my project between 2 Arduino Mega2560s and LVIFA. To use the Xbees, what changes did you make to the LVIFA base? What does your code look like on the other Arduino?

Also does this xbee work with an Arduino Mega 2560? If not, what modifications would I need to make to get it to work with the Mega?

0 Kudos
Message 9 of 17
(4,842 Views)

Hi, first of all, I want to say that I am just starting to use Arduino, so I'm not sure if I can help you. Anyway, I'll try to answer your questions.

LVIFA base uses LabviewInterface.c and LabviewInterface.h. Inside them, it uses some functions (I think they were "serial.write" and "serial.print") in a "obsolete way", because the new software of Arduino has changed slightly these functions (you have more information about recent changes here http://code.google.com/p/arduino/wiki/Arduino1). In my case, the compiler showed me the error and told me how to fix it.

I have an Arduino UNO, and I have never worked with Arduino Mega, so I can't help you with this issue (but I think it must work).

I can't understand what you want to mean with "What does your code look like on the other Arduino?", if you explain it better I'll try to help you in the next message.

0 Kudos
Message 10 of 17
(4,842 Views)