I have interfaced my Arduino Uno with LabVIEW using LINX. The first time I run the VI it takes some delay for the Arduino to respond (around 7 sec, Tx and Rx LED blinking time). After that the delay is tolerable with control. The VI I am trying to build has a requirement that values should update as soon as the VI runs. How can I control the initial delay ?
Honestly I don't think you can... I have used LINX a couple times and noticed the same thing. I am only guessing here but I think LabVIEW has to program the Arduinio every time you launch a LINX app. That's why it takes longer to respond on first run.
The people on the LabVIEW Makerhub LINX forum might have better answers...
But if this delay is causing issues you might want to forget LINX and program the Arduino with it's native language.
Then communicate with the Arduino using VISA just like you would any other device on a serial port.
Here's some tips...
An Arduino should install a virtual serial port when it is first plugged into your computer
You use that serial port and NI-VISA to communicate with the Arduino just like any other device on a serial port
You have full control over the serial protocol, query and response format since you will be writing the Arduno code
Get your Arduino code to work with the Arduino Serial Monitor, then work on the LabVIEW to talk to it
Send data using the Arduino PrintLn function as it appends a LF to the end of the data. You can use that LF as a Termination Character in your VISA Reads
Which version of LINX are you using - the latest from VIPM? I've also noticed this very slow start, and thankfully it can be vastly improved.
If you dig a few layers down into the LINX Open Serial.vi you'll find Initialize Device.vi (full path is vi.lib\MakerHub\LINX\Private\Device\Initialize Device.vi). This VI has a hardcoded 5000ms (!) wait when initializing devices. So that already accounts for 5 of the 7 second delay you're seeing.
The remaining delay is eaten up in the baud rate switching logic. The LINX code on the Arduino initializes the baud rate to 9600. The LINX LabVIEW code assumes 9600 baud when first connecting, but then switches to the maximum 115200 baud rate once a connection has been established. This switching takes at least 1000ms (a hardcoded delay in the LINX code running on the Arduino).
So there are two steps to drastically improving the startup delay. The first is changing that massive 5 second delay to something much smaller. I've tested down to 250ms, and that seems to work just fine (using an Arduino Uno @ 16MHz). This will get the delay down under 2 seconds.
The second improvement is initializing the Arduino with the maximum baud rate, rather than initializing at 9600 and then switching to 115200. To do this, use a text editor to open LinxSerialListener\LinxSerialListener.cpp located in your Arduino\libraries folder (either where Arduino is installed, or in Documents\Arduino\libraries). Find the line (line 48) LinxDev->UartOpen(ListenerChan, 9600, &acutalBaud); and replace the 9600 with 115200. Save this file, then open the Arduino_Uno_Serial example with the Arduino IDE and verify + upload it.
Back in LabVIEW, open up Initialize Device.vi and add the 115200 baud rate input to the first open serial connection VI. Delete or disable the section of code which does the baud rate switch.
With the above changes the delay can be reduced from 7 seconds to around 600ms.
A newer version of LINX over at the github repository has some improved device synchronization logic (not just a 5 second wait). I haven't tried it out, but it is probably more robust than the current delay being used. It doesn't help with the baud rate switching delay, but might be worth checking out.
Yes I had checked removing the hard wired 5s delay and 1ms delay for reboot synchronize and it comes down to around 2sec. I will check for the baud rate as well .
With default Arduino firmware, when serial port is opened, the Arduino firmware waits to see if new firmware will be uploaded. If no new firmware is updated, the Arduino then starts running whichever program is currently in flash.
LINX may be doing the same thing.