06-15-2011 09:45 AM
I have a Mega 2560 Arduino board.
Has anyone successfully worked with the Mega2560 and LVIFA driver?
I get a 5002 error (Unable to establish connection with Arduino. Please ensure that you have selected the correct COM port and that you have flashed the Arduino with the correct firmware.)
It times out before it receives an answer from the Sync Packet that is being sent in the initialization procedure. The Rx LED on the board keeps flashing as the sync packet is sent multiple time. After the default 20 timeouts, it gives up and throws the 5002 error. All this time, the Tx LED is not flashing at all, as if it's never answering.
I've tried it on three systems with the same results. Two running on Win7 x64. One has LabVIEW 2009(32-bit) and LabVIEW 2010(32-bit) installed. The other runs LabVIEW 2010(64-bit). The third system is a WinXP (32-bit) with LV 2009.
I have NI VISA 5.0.3 installed with the latest LVIFA version 1.3.0.23. I also downgraded to 1.2.0.21 on LV2010 systems and got the same thing.
Arduino board works fine when I flash the "Blink" example that comes with the Arduino IDE. I get the above error when I have the LVIFA_Base.pde file uploaded.
Unfortunately, I don't have a Uno board to try and see if I'm doing something wrong.
06-15-2011 03:07 PM
Normandinf,
I have successfully used the toolkit on the 2560. Have you tried wiring a constant into the Init VI's Visa Resource input? If you are seeing the RX light flash on the MEGA that tells us that data is being recieved by the board. Are you connected via USB? Do you have anything plugged into DIO pin 0 or 1? Did you get any errors when you deploy the firmware to the Arduino? What does your LV Code look like? Have you tried one of the examples?
Please let us know and we will get you up and running asap.
-Sam
LIFA Developer
06-15-2011 03:54 PM
Thanks for these tips.
I use USB for communication. I don't get any errors with the Arduino deployment. I actually managed to write my own code to communicate with the Mega 2560, and I can read an analog input and control the LED at pin 13 via PWM, and trigger actions by sending serial commands just like your checkForCommand() code. However, using the example supplied with LVIFA, it fails with error 5002. (Read Analog Pin Example). Nothing is connected to DIO 0 and 1, which would interfere with serial comm.
It must be the simplest thing missing, perhaps a serial setting that is wrong. My COM port is set to these parameters: 115200 baud rate, 8 data bits, no parity, 1 stop bit, no flow control, no termination characters.
I copied and modified your code to insert Serial.write commands here and there, to monitor where it fails for me.
I think it simply doesn't get 15 characters. When I use the terminal window and send 15 characters (all zeros for example), I can have your program print something on the terminal window and go through the checksum test. However, when I'm in LV, it always times out. My guess is that the chain of characters is not 15 or longer, hence the Serial.flush() command is called instead. It doesn't even go to the point where the checksum is verified.
This simple diagram fails. (Init + Close)
06-15-2011 05:13 PM
normandinf,
The toolkit will not work if you add serial communication code using the same USART that you use to connect to LabVIEW. I assume that for your original connection attempt you used the standard LIFA base firmware. Is this correct?
-Sam
LIFA Developer
06-16-2011 07:31 AM
06-16-2011 09:32 AM
OK, I tried many things and the toolkit works, except for the Init VI.
To have good behavior, I need to manually initialize the VISA settings. Then, when I feed directly the data bytes to the "Send Receive" VI, I can make it work (receive the "sync" response).
But I'm not sure yet the stone must be thrown at the init VI. I don't get the same behavior if I call "VISA Configure Serial Port (Insrt).vi" in a VI (as shown below) or if I open its front panel and run it manually prior to using the LIFA driver.
There is something going on that I don't understand with the COM port settings. I am at a loss as to why the VISA Configure Serial Port VI doesn't do it's job when called as a subVI... It must be the same thing that happens in Init.vi of the LIFA driver.
What is even more puzzling is how it could happen on three machines with three versions of (Windows) OS.
What is the earliest VISA driver that you know would work? I'll try to downgrade and see if that solves it.
Temporarily, I've disabled it in the Init.vi of LIFA, and it seems to work correctly.
06-17-2011 12:42 PM
I was having the exact same problem. Every time I ran one of the examples I received the 5002 error for my Arduino Mega 2560 board, until I turned on the highlight execution in the Init.VI and then it worked every time in both the BlinkM and Servo examples. Further experimentation showed that the error originated in the Send Receive sub VI inside the Init.vi. I increased the delay in the "USB / Serial" case structure to 10000 (10sec) and the Init.VI and the examples worked every time.
06-21-2011 08:54 AM
normandinf,
Have you added any code to the LIFA Firmware?
normandinf and MAELabman,
Are you using a USB 2.0 Port? (My best guess at this point is that this is the cause of the strange behavior. The slower port may cause timeouts due to slower data transfer).
-Sam
LIFA Developer
06-22-2011 10:44 AM
06-27-2011 08:02 AM
Hello I have de same problem
How can I resolve this prbloem?