LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error 5001 with MPU6050 and Servo write LINX

I write a simple program to red a MPU 6050 using and Arduino Mega 2560 and the LINX library, I also include in the same the blocks to control two servo motors, but when I execute it it runs well for a while but after some time it fails and throws the error:

Error 5001 occurred at :

Read.vi >>
I2C Read.vi >>
I2C Read.vi >>
Send Command.vi

 

Possible reason(s):

A timeout occurred while waiting for the Arduino Mega 2560 to respond

 

And I couldn't find a solution for this, I already changed the pins and still fails 

Here is the VI

 

VIVI

 

Front panelFront panelI also tried to change the baud rate but still getting the same message, the only way I didn't get the message was deleting the open servo block, but without it I couldn't write the signals to them. 

If a execute it in separated programs, I don't get the error only when I place all the blocks together.

0 Kudos
Message 1 of 13
(5,576 Views)

Error 5001 is typically a "User-generated Error" -- when I am writing a VI and discover an error condition (like "This Device's Attribute, which is supposed to be writeable, is Read-Only"), I've used Code 5001 to signal it.  This suggests that the Error comes from one of the "foreign" VIs in your example, whose details we can't see.  If you can open them, you can see which one throws this error, find out what causes it, and figure out how to avoid these conditions.

 

If you need more help, attach the other VIs.  

 

Bob Schor

0 Kudos
Message 2 of 13
(5,539 Views)

Hi jafetrd!

Maybe your issue is related with your arduino configuration. I leave you the following information:

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019SDeSAM

 

I hope it works for you!

Staff Technical Support Engineer
National Instruments
0 Kudos
Message 3 of 13
(5,529 Views)

I verify the pins and they are correct I'm using 6 and 7 in the Mega

0 Kudos
Message 4 of 13
(5,517 Views)

I also read it was about timing, and I use a wait function to sample slower but after some time i get the same error here I attach the VI, and also change the Baud rate for something faster I tried 9600, 14400,19200, still got the error and change the configuration in the port as shown in the image 

 

 

Download All
0 Kudos
Message 5 of 13
(5,514 Views)

@jafetrd wrote:

I also read it was about timing, and I use a wait function to sample slower but after some time i get the same error here I attach the VI, and also change the Baud rate for something faster I tried 9600, 14400,19200, still got the error and change the configuration in the port as shown in the image 


The VI you attached shows a Baud rate of 115200 ...

 

When you get the 5001 Error, does it say what VI or function throws the Error?  Can you attach that VI so we can inspect it and see precisely what is causing the error?

 

Bob Schor

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

No it doesn't say which block caused the error, it only prints the error I previously mentioned, and here is the VI 

0 Kudos
Message 7 of 13
(5,504 Views)

I also made this simpler VI only reading the MPU sensor without writing any signal to the servo motors, and I didn't get any error, so I'm believe the error is inside the servo blocks but I can't find it, and I really need to write to the servos, here I attach the simplified VI 

0 Kudos
Message 8 of 13
(5,494 Views)

OK, not only did I open your VI, but I broke down and downloaded/installed the LINX library.  And might have found your answer.

 

The very first function in your code, you wired 14400 into the Baud Rate Override input.  Diving into the Diligent code, I found the following:  "When specified, allows the user to override the default baud rate used for serial communication. By default LINX establishes communication using a baud rate of 9600 and then negotiates for the remote LINX device's maxiumum supported baud rate and re-establishes communication at that maximum rate. If a Baud Rate Override input is provided it will be maximum baud rate used. This is useful when using UART abstractions that are not able to change baud rates on the fly (Xbee for example)."

 

If I choose to believe this comment, you are locking your Arduino interface into using a pretty slow Baud Rate, and, more important, not letting it determine for itself an optimal Baud Rate.

 

Try deleting this constant and see if that helps.  Let us know ...

 

Bob Schor

0 Kudos
Message 9 of 13
(5,481 Views)

I delete the baud rate constant but still getting the same error 

0 Kudos
Message 10 of 13
(5,479 Views)