ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 5002

I am getting an error 5002 when I try to run the very simple code below. I am trying to send a pwm to an Arduino pin, but it's not even initializing the board correctly. I read some forums that said to increase the timing rate in the init.vi and I increased it first to 1000 and then to 2000, no success.

The forums also said to make sure the baud rate is the same across the board. I noticed the Serial.begin(19200) in the firmware sketch and I changed the baud rate in my code to 19200, no success. The arduino shows up fine in my device manager and it also shows up fine in the labview measurement & automation thing. The only weird thing is that the arduino stopped showing up in my arduino serial port menu after a while.

Any suggestions or ideas?

Drive Debug.JPG

0 Kudos
Message 1 of 13
(9,073 Views)

What board type are you using?

If its an Uno you want to set that to 115200 if you are using a mega the default is 9600

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 2 of 13
(6,974 Views)

Also make sure you download the latest update. It fixed all my problems.

Create a COM and Board Type constant also with your baud.

0 Kudos
Message 3 of 13
(6,974 Views)

I'm using the Mega 2560. I know I have to change the baud rate in the code (which is the 19200 in the pic above). I changed it to 9600, but where else do I have to change the baud rate?

0 Kudos
Message 4 of 13
(6,974 Views)

I think I have the latest updates...I just downloaded everything in January.

How do I create a COM constant? And I thought the board type thing I have in my code is a board type constant...is it not?

0 Kudos
Message 5 of 13
(6,974 Views)

I have updated my software, I changed the baud rate to 9600 in MAX, the code, the vi, and the windows device manager, I increased the timeout...I don't know what else to do.

When we run the vi, the LED labelled L blinked twice, then the tx and rx pins started blinking rapidly, then the LED labelled L blinked twice again. I have tried to follow the advice I've seen on other threads, but nothing is working. Although I have not tried to do any hardcore editing of the init.vi itself

0 Kudos
Message 6 of 13
(6,974 Views)

initfail.JPG

This is where the problem is within the Init.vi. I have no idea what this means or how to solve it...

0 Kudos
Message 7 of 13
(6,974 Views)

There was also a february update which fixed the 5002 error for most people. If you have that one and are still seeing this issue post back.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 8 of 13
(6,974 Views)

I updated all of my software and I'm still having that issue. I set the baud rate to 19200 in the windows device manager, max, and the init.vi (because that's what the Serial.begin is using in the firmware). I increased my timeout to 5000.

Any ideas?

0 Kudos
Message 9 of 13
(6,974 Views)

The baud rate in the firmware should by default be set here:

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)

#define DEFAULTBAUDRATE 9600    // Defines The Default Serial Baud Rate (This must match the baud rate specifid in LabVIEW)

#else

#define DEFAULTBAUDRATE 115200

#endif

so if you have a Mega its 9600 or if you have anything else its 115200. Not sure where you are seeing the 19200 rate.

Kevin Fort
Principal Software Engineer
NI
0 Kudos
Message 10 of 13
(6,974 Views)