LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

ERROR 5002 with UNO board on Init

Hello,

I'm new here on the forum and I just started using Arduino to control a stepper motor for a senior design project but I've been having some difficulty. When I try to run the Init vi I get an Error 5002. I've been reading the other posts and it seems the problem was the Mega and has been resolved but I couldn't find a solution. I have tried updating my software and changing the baud rate to 115200 and increasing the wait time to 10000 msec but nothing solves it. Does anyone have any ideas? Btw I am using Arduino 1.0 on Windows XP and LabView 2010.

Thank you!

0 Kudos
Message 1 of 26
(32,593 Views)

Okay I have an update on my problem. So I've been trying to track where the issue is and I find that in the init subvi I get a ERROR 5003 in the Send Receive vi. The problem is it times out before receiving a response from the arduino reading back the FF00 0000 0000 0000 0000 0000 0000 FF. I have tried increasing the timeout time but that doesn't work.

**UPDATE** When I run the Send Receive subvi separately at first it didn't work and gave me ERROR 5003. I was frustrated and pressed reset on the arduino uno and it suddenly worked. But when I tried to run Init again the ERROR came back....even when I clicked reset...could this have something to do with the buffer not clearing? I've been tracking the movement of the VI with multiple LEDs and when I'm running Init and looking into the Send Receive subvi I can see that its timing out before sync is sent back from the arduino.

**UPDATE** So I'm just going crazy but I tried something else. As I was running Init I pressed reset right when it ran the Send Receive SubVi and it worked. I didn't receive any error. I'm not sure what this means as it doesn't help me run the stepper motor example I want to run. But I can't help but think it means something.

Any ideas on why this is? I'd appreciate some help on this issue.

0 Kudos
Message 2 of 26
(13,872 Views)

Thanks for bringing this up.  Arduino changed (I mean really changed) the function of serial.flush.  It used to clear the serial buffer (which is what we want to do in that instance).  Now is waits for transmissions of outgoing data to complete (we don't care about this in this case).

We will look into a fix and post asap.

-Sam K

0 Kudos
Message 3 of 26
(13,872 Views)

Hi Sammy_K

Thanks for your response. Is there anything I can do to solve this issue? I have been temporarily using a Mega2560 arduino that I borrowed from another student and that one seems to work fine. Is this only an issue on the UNO?

0 Kudos
Message 4 of 26
(13,872 Views)

Hey Meryouma,

This should be an issue with both boards -if the Mega is working you may try dropping the baud rate on the UNO. Over USB the UNO and Mega both work almost all the time (from my experience) its more of an issue if you are using wireless (since the changes to serial flush make the interface less tolerant to lost packets/flipped bits).

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 5 of 26
(13,872 Views)

Hallo Meryouma,

I had a similar problem (Error 5002) and I solved it by placing a case stucture in the init.vi of the LIFA!

No need to decrease the baud rate, 115200 works fine!

Now I can safely stop execution of the program using "Abort Execution" and I know that the next time it will start normally!

Good Luck!

yannis

LabVIEW Interface for Arduino.lvlib_Init_BD.png

0 Kudos
Message 6 of 26
(13,872 Views)

Hi Guys

I'm working on a school project that i have to develop with labview (completely new to me as i'm use to C++)
I experience the same problem as Meryou when i try to read?write pins from an AS5040.

I have a whole project to develop and i'm currently busy on the sensing part of it.

i tried everything from the solution suggested with the Mega 2056 it still does not work with my Uno.

i'm still editing my code but can't even read the data so i stopped from there.

Find it attached.

If any solution since last time? please assist.

PS: i'm using the 2009 version of labview and have been able to test the servo example of arduino for example

Regards

0 Kudos
Message 7 of 26
(13,872 Views)

To solve your 5002 issue, you need to move the Close.vi outside of the while loop.  Also, a time delay of 1e-5 is not possible with LIFA because the time to transmit a single byte is already larger than that and there are several bytes sent in each packet.

If simply moving the Close.vi outside of the while loop solves your problem and everything works then that is great (this is what I would try first).  If it fixes your 5002 error problem but does not work then you should start your own discussion with many more details of how you have that chip programmed (that is an extrememly versatile chip with respect to it's output modes) and what you are trying to do with the information.

The more details that you can give, the better.

0 Kudos
Message 8 of 26
(13,872 Views)

Hi Nathan

Thanks a lot for assisting... after putting the Stop.vi outside the loop it works better. the vis works sometimes perfectly with both RX&TX flashing some other times the errors still appears but only when i stop the vi. i think this happens when the communication with arduino is not possible... i still don't know why the instability but i just reset the board and reconnect the usb cable whenever it shows it works perfectly for some while before going crazy again.

My project is about antenna azimuth control

i've chosen to create a controller for a continuous servo motor that will be attached to an antenna.

i want to use the AS5040 to control the servo therefore i use it as a sensor to get the rotation angle at which the servo is rotating ; if ever the desired angle (input angle) matches tht of the signale sent by the ship...it has to stop transcient time have to be considered also....so basically tht's how i thought of it.

For now i want to read the data from the DO pin 9 of the AS5040 that i've connected to pin 4 of arduino.

CSN= pin 8 (arduino)

CLK= pin 7 (arduino)

In order to do that the CSN has to go high and low and the read out will be initiated.

Each subsequent rising clk edge shifts out one bit of data (i have run this 16 or 10 times to get the rotation angle as the info is available in a 16 bit info).

Attached is the modified version of yesterday i can read now the data but still need to convert the 16 bits info in degrees using Labview language.

Also find attached the AS5040 datasheet if interested.

Hope this is enough info to help you guys assist better (Sorry for the long text).

if any better ideas regarding my project!?...welcome!!!!

Regards

Download All
0 Kudos
Message 9 of 26
(13,871 Views)

This would be best implemented in the firmware since it is a timing sensitive operation.  The first thing that I would do is look to see if anybody has gotten this to work on the Arduino (without LIFA) and then use that code to modify LIFA.

Please create your own thread/discussion so that you have an appropriately named discussion.  After you have created your own thread/discussion (and have posted your information there) and you are unable to find some existing code, let me know and I will see if I will be able to help you out.

0 Kudos
Message 10 of 26
(13,871 Views)