LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Help reading a INT value in LabView (Solved)

Ok so I use it, first I set the arduino in the sub Vi Init, later I re check them in the sub Vi ping))) and after that I start the main VI Ping example, and nothing happen, I am gettint a pop up with this error;

Error 5002 occurred at 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.

This error code is undefined. Undefined errors might occur for a number of reasons. For example, no one has provided a description for the code, or you might have wired a number that is not an error code to the error code input.

Additionally, undefined error codes might occur because the error relates to a third-party object, such as the operating system or ActiveX. For these third-party errors, you might be able to obtain a description of the error by searching the Web for the error code (5002) or for its hexadecimal representation (0x0000138A).

I am flashing on it the firmware that you give, and I don't know what else could be happening 😞

My final project require two ping sensors, their values are going to be processed with a PID and a fuzzy control and are going to control two DC motors, so if just reading one single ping is been this hard, I can even think what hell must be do what I am trying to do.

0 Kudos
Message 11 of 19
(1,309 Views)

The official error 5002 documentation can be found here.  (I usually just google "lifa 5002" and it get's me there quickly)

So, you might need to wire your COM port directy to the VISA resource input of the Init VI.  Just right click on the input (when you get the spool tool) and select "Create Constant".  Then, choose you comport from the drop down list in the constant.

This is one of the more common fixes that I've seen for this particular error.  You can also read through the other suggestions on the error's documentation page.

Some things seem harder than they really are when we communicate via text.  Once we get this working, you should be able to easily use it with two sensors.

0 Kudos
Message 12 of 19
(1,309 Views)

Ok so nothin happen after I do that, the plot is working but nothing happen in the ping sensor, it dosn`t even workin as the led dosn`t blink.

I appreciate all your time and effort but this is frustrating

Solution:

This error occurs when LabVIEW cannot establish a connection with the Arduino microcontroller.  Several factors can cause this error so please check the following:


  1. Make sure that the correct firmware is flashed to the Arduino.  The correct firmware can be found in <LabVIEW>\vi.lib\LabVIEW Interface for Arduino\Firmware\LIFA_Base = OK
  2. Make sure you have selected the correct COM port for the Init.vi or that the VI automatically locates the Arduino (this happens when no wire is connected to the VISA Resource input of the Initi.vi and only works for Arduinos that are connected to the PC via USB) = OK
  3. If using an Arduino connected via USB make sure that the Arduino is listed as under Ports in Windows device manager.  If it is not listed you may need to install the Arduino drivers. = OK
  4. If using a wireless connection (Xbee, BlueSMIRF) to LabVIEW try using a wired connection (USB , Serial).  Poor wireless signal strength can cause the Arduino to be unreachable by LabVIEW. = Not using anything wireless
  5. Make sure that the baud rate specified as an input to Init.VI matches the baud rate specified in the firmware by #define DEFAULTBAUDRATE X (where X is the baud rate). = OK

And still not working

0 Kudos
Message 13 of 19
(1,309 Views)

Well, I happened to get access to a PING))) sensor and I was able to test it with an Arduino Mega 2560.  The code that I wrote seems to work really well when I tested it.  So, I'm not really sure what the issue is with your Arduino and/or set up.

However, one thing that I did need to make sure that I did was to change the number of the pin that is input to the Get Ping Distance VI.  So, make sure that you change the Pin constant to the digital pin that you are using.

Message 14 of 19
(1,309 Views)

I change it every time to 7 or other, with the last VI I use the pin 8 (as  appear on the VI ) and 7, but nothing happen) I am going to test in another computer but has to be on monday, I will let you  know.

0 Kudos
Message 15 of 19
(1,309 Views)

So finally today after testing the files in another computer... THEY WORK! so if you are searching for a Ping Sensor Vi here it is! (it works)

Nathan I can't be more grateful and I really appreciate all your time and effort!

Thanks!

0 Kudos
Message 16 of 19
(1,309 Views)

Hi CTUNA. I'm no Arduino/Labview expert, but I wanted to offer you a solution I think may work in the future. I know you've said you've fixed the issue, but I was watching your video and I had the exact same error codes. It was all attributed to one thing - the Arduino Close Function was not being run. If a program is prematurely ended via the stop button, or a program is run which opens a read sequence on a port but doesn't close it (such as the one shown in your video), it will remain open until you restart your computer (at least I think so -- Nathan please correct me if I'm wrong). I believe the errors are the result of trying to reinitialize an already open port when you run it again. What threw me off however, was the fact that you were able to write to the Arduino through the Arduino software - I'm assuming that that was right when you started the computer, which will allow you to do this, but if you try to write LIFA_base to the Arduino after using labview without closing the port, the Arduino software will complain saying it's in use.

Basically, when you're debugging, make sure your Read functions are followed by an arduino close after stopping your program. This can either be done programmatically by tacking on a close to your program - or if it's a subfunction, just open the arduino close function separately by double clicking and running it outside of your program. That will allow you to access the port again and should fix your root issue with those particular 5002/5003/long -1xxxxxxxx error codes.

I don't know if it's the right solution being somewhat of a novice, but I noticed that you weren't doing that and it worked for me and I'm hoping that it will help you as well.

Message 17 of 19
(1,309 Views)

You are, for the most part correct.  If the Arduino connection is not closed with the Close VI, it will remain an open resource preventing you from reconnecting to the resource (COM port).  A full restart of the computer should not be necessary but will definitely work.  Simply running the Close VI like you said manually should fix it.  Before I discovered that fix, I only had to close out of LabVIEW completely to get it released.

The major thing that I noticed in the video was that he was trying to run my VI directly.  This will not work because the VI that I created (the one that isn't named 'example') is a subVI and assumes the Arduino is connected already.  So, when running that VI alone, it was trying to talk to the Arduino even though the Arduino hadn't "picked up the phone" yet.

Message 18 of 19
(1,309 Views)

As I told before this are my first step with labview and arduino and they are for my final degree, so every tip is vital for me, thanks to both of you.

0 Kudos
Message 19 of 19
(1,309 Views)