LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Mega - 5003 error

Hi

I'm building a climate control for my terrariums and already have build the hardware interface for it. I'm using a 2560 arduino as microcontroller for this setup because i needed almost all of it's pwm signals. I had the same problems as some people before me that the arduino would not init but thanks to some tips found here i resolved that problem. The problem i have is when i run a test vi wich only reads 2 analog inputs the arduino will stop responding somewhere between 5 and 30 minutes and gives a 5003 error (believe it's lost it's communication). I have no clue why this would happen. Using computers for a long time i believe it it should not communicate at all or communicate always and not stop at random times. Only thing i have modified is that i have set the pwm timer 1 and 2 to the highest possible. Baud rate is set to 115200 in arduino/labview/windows.

There are some checks still to do but will try that later:

Try another USB port

Try lowering Baud rate

Set pwm timers 1 and 2 to default

Maybe some other checks to try?.

Here some pics of the interface

http://foto.krillins.com/arduino/kast1.jpg

http://foto.krillins.com/arduino/kast2.jpg

http://foto.krillins.com/arduino/kast4.jpg

http://foto.krillins.com/arduino/kast5.jpg

0 Kudos
Message 1 of 16
(12,774 Views)

Krillin,

First things first...that thing looks sick!  Awesome clean design, organized wiring, and profesionall looking case, well done.

As for the disconnection issue the first think I would do is try it with the timers set back to the default values.  Other peripherals may be using those timers which might cause some trouble.  Other than that everything you listed is reasonable to check.  Did you make any other modifications to the firmware?  Can you post your code or a screen shot of your code?  What is your main loop rate?  Can this be slowed down?  Is there anything else running on your PC that could be causing trouble (virus scan starts up and causes LV to timeout...I admit its a bit of a long shot but always worth checking).  Does the memory or CPU usage climb as you run your app?

When I was developing the wirless portions of the toolkit I tested with an Xbee about 15 feet from my PC and it ran for 8 hours without disconnecting.  It was only doing an analog read though.

-Sam K

LIFA Developer

0 Kudos
Message 2 of 16
(3,784 Views)

Well i think i have found the problem. After testing some of the options you mentioned the arduino still behaved erradicly. So went back to the old methode of measuring the grounds. I did that before but this time i found something out. The usb connection on the arduino has a metal outer casing. This casing was just touching the metal of the 19" rack. Normally this would not be a real problem because it's just the shielding of the USB. But just for trying, i isolated the outer casing of the arduino from the 19" rack and the program has run for several hours now . I think that the data passing through the usb port (vertical flow ) is going past the 19" rack (horizontal) and i creating a electrical charge (static electricity). It seams far fetcht but i think that is the reason why it disconnects at diffreant point in time.

But thnx sammy for thinking with me. As for the build. Thank you for your remarks. This is my second setup. I already have a setup build like this one only it is based on a NI DA card and two 220V dimmer modules (0-10V input). The 220V switching of pumps, fans, heaters are done with standard relais. But it was done real fast, so no neat housing etc. This version i'm taking it a step further with dimming high power leds (sunrise/sunset/clouds/storm) and fan control. But in mind that it would be reasonable priced.

Back to the topic though. There is still one problem left. If i run the program for the first time it always gives me an 5001 error. I have to mannually open the init VI and run that first to get it started. After that it will always run. I know that there are simmilar problems on the forum, and i have tried them all, but none of them helped.

0 Kudos
Message 3 of 16
(3,784 Views)

Krillin,

It sounds like your VISA Resource is not beign disposed of properly.  Are you calling Arduino Close at the end of your program?

-Sam K

LIFA Developer

0 Kudos
Message 4 of 16
(3,784 Views)

I double checked to see if it calls the close init and it does. Also yesterday the analog input suddenly stopped, only this time there was no 5003 error and the rest of the program just continued. I checked the voltage of the analog input (to see if my sensors freaked out) but the voltage was around the 2.3 Volts so i have no clue why the input stops reading sometimes.

0 Kudos
Message 5 of 16
(3,784 Views)

Krillin,

Can you post your LV Code?

-Sam K

LIFA Developer

0 Kudos
Message 6 of 16
(3,784 Views)

Found the problem. i used ryannaz routine to get rid of the 5000 errors (found herehttps://decibel.ni.com/content/thread/9621?start=15&tstart=0). it messes up the analog readings (no idea why). Now i'm back to the timeout option of 10 seconds and is the most reliable now. still got the init problem (sometimes it will work at once, sometimes not) tried normans code (https://decibel.ni.com/content/thread/9762?start=30&tstart=0) and it's the same. sometimes it works sometimes not. I'm going to try to pinpoint it, but for now i'm happy it works.

@Sammy

Could give you the code but it is still in development and has a lot of vi's so it will take some time to decifer it .

0 Kudos
Message 7 of 16
(3,784 Views)

Did some extra testing last night.

It seams that from the 3 modifications the 10 second wait time works best. For a recap

1. Ryannaz mod sometimes work sometimes not but i have to highlight init.vi and run that first to get it going. After that it will always work until i close down labview. Problem is that the analog inputs will stop reading at a random time wich prob is found in his modified wait for bytes.vi

2. Normans simple mod gives the same result. only the analog input will work.

3. The 10 second wait time works always. Only weird thing is that the first time i run it it looks like not all variables are set correctly (lights go on or blink). the second time i run it, it will run fine (not closing labview). This could be some wrong coding in labview but i have to take some time to check that out. Problem with this mod if your developing (wich means you run it a lot) the 10sec will get annoying.

0 Kudos
Message 8 of 16
(3,784 Views)

Krillin,

  Really liked your project. I would like some more context. Did you do this for school or just a home project? I'd love to understand the story behind this.

-Ben

Ben J.
National Instruments
Applications Engineer
0 Kudos
Message 9 of 16
(3,784 Views)

It's funny that you mention my code being the problem... because while my code fixed the startup problem for me, I've had this weird I2C dropout and lost packet data problem for the longest time.  The problem is at some random time, my I2C magnetometer (electronic compass) would just drop a byte of data, causing the data to be shifted, which causes something like a 300 degree angle to turn into a 50 degree angle.  Not good for the project I'm doing with it.  It kind of makes sense that changing my code could cause this, but I'm not sure why it does cause this problem.


It might be a moot point now, with LIFA 2.0 releasing here in a week or so.  Hopefully these bugfixes promised fix the 5002 error. 

In the meantime, since I'm all done with school, I will take  a look at the modified code and see if I can figure out a fix for it.  Sorry it caused you problems.

-Ryan

P.S. Very nice project you have going!  Very professionally done!

0 Kudos
Message 10 of 16
(3,784 Views)