From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Losing Arduino Resource after Initializing (Error 5003)

Solved!
Go to solution

I am writing a program to control several different peristaltic pumps. I want each pump to turn on and stay on for as long as I tell it to and then turn off and sit for as long as I tell it to. I am using an Arduino Mega 2560 and Labview 2014. I've been learning Labview for this project over the last 4-5 months, so am relatively new to the program.

The interface is Tab Control with three tabs: Set Up, Program and Manual. Through the Set Up, I select the Robot and the VISA Resource and then select Initialize which send the info to a sub VI called "Initialize Robots". The sub VI assigns the right input/output and sets up a servo that I use to control the drain. The Error Out goes to a while loop that allows me to turn on and turn off the power to the entire system (via a solid state relay).

Through the Program Tab, I select which pump to use and how long to turn it on and off form as well as how many times to repeat different subsections. The Time Left in Step and Time Remaining have yet to be programed, but the Number of Layers, Drain Time, and Drying Time are all valid inputs.

Through the Manual Tab, I can control the individual pumps and be able to test that I have the right drying time and drain time input (sometimes, it takes some trial and error to make sure the drain time is adequate for different size containers).

Problem:

  • I can initialize the Arduino without any problems. The "Robot Initialization Error" shows no errors. However, after I click on the Manual Tab, I lose connection to the Arduino and get a code 5003 error at all of my error indicators. The error only shows up when I click into Manual Tab. This wasn't a problem previously. When I added the sub VI for the Servo Control, I started getting the error, but I can't see how that is related to the Arduino Resource. I've read on other forums that you shouldn't split the Arduino Resource, but I'm not sure why it was working before and isn't working now. Should I not use local variables for the Arduino Resouce? I don't think there are any race conditions because I'm only reading the Arduino Resource local variable.

I appreciate any help on the specific problem or any suggetions on best practices I can incorporate (especially with respect to multiple parallel while loops).

Thanks!

0 Kudos
Message 1 of 5
(4,547 Views)
Solution
Accepted by topic author henryburdell

There are two major things wrong here.

  1. You are closing the Arduino resource in "Servo Control_V2.vi" (this is causing your error).  You need to close the connection to Arduino only when you stop your VI (or stop requiring the Arduino) which does not appear to be happening in your code.
  2. Using a local variable for the Arduino resource is functionally the same as splitting splitting/branching it.  This should never be done.  It causes a potentially serious race condition (The race condition occurs with the serial communication, not the Arduino resource wire).

Also, I'd highly recommend that you switch to LINX.  LIFA has been unsupported for well over a year now and was replaced by LINX some time ago.  It is the same basic design but it's designed much better (you won't ever need to set digital pin modes).  One thing that makes it a bit faster is that you can set multiple digital pins in a single command.  This is also true of many other functions including the digital and analog reads.  So, for example, in your "Manual" case, all the digital read VI's would reduce to a single LINX command and all the digital write VI's would reduce to a single LINX command.

http://www.labviewmakerhub.com/linx

0 Kudos
Message 2 of 5
(3,955 Views)

I appreciate the quick response! I'll make sure to avoid local variables for the Arduino resource.

As far as LIFA, I know it's been unsupported for a little while, but I had trouble installing LINX on my computer until about 2 weeks ago (which I think came from the fact I had two versions of Labview installed on my computer and the install was looking in the wrong folder). I'll have to brush up on the new commands for sure.

Thanks!

0 Kudos
Message 3 of 5
(3,955 Views)

You can install LINX for multiple version of LabVIEW.  I currently have it installed for both 2011 and 2015 on the same computer.  If you install it via VIPM, there's usually few, if any, issues.  Make sure that you select the correct version of LabVIEW in VIPM before installing.

0 Kudos
Message 4 of 5
(3,955 Views)

hello

help me

i want to run Flow meter with lab and ardiuno but i can not if you did please send to me

thanks

0 Kudos
Message 5 of 5
(3,955 Views)