From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial write very slow to arduino?

Hello,

 

I have been trying to use an arduino to add a small OLED display for one of our Labview controlled robotic setups (without having to mess with the robot hardware directly).

The display should show the trial number and subject ID for each trial, which we then record on video (together with all the stuff the rat does). In a trial, the robot gets in place, waits for the rat to interact with it (or until timeout is reached), stores data recorded during the interaction and gets back into the start position (startign the new trial). The trials are at most 10s apart, but an interval of about 1s is more common. 

 

My problem is that the display responds too slowly.  After the robot gets in place, it takes about a second before data is displayed and the trial is already finished by that time.

I don't think the problem is in my arduino code, because the display reacts much faster when I use the arduino serial monitor. 

 

I write the data to display to a serial port using VISA inside the sequence structure that controls the robot: the stings to be displayed are sent to the arduino at the same time the robot is initialized for a new trial (first frame of the sequence) and I close the VISA session at the end of the sequence. Am I somehow keeping my arduino busy without realizing it? Any idea where the second long lag comes from? 

 

I've attached a screenshot of the OLED-related labview code (it's a very basic serial write). I've also attached my arduino code. 

 

Any help is much appreciated

 

Download All
0 Kudos
Message 1 of 2
(4,291 Views)
  • When posting code post the actual code not a screenshot.  You wouldn't take a screenshot of a text file and post it on a text language forum.  Upload the actual VI, or zip several files and upload the zip.  The exception to this rule is when uploading a VI Snippet.  This is an image with the VI embedded in it, so the source is still intact.

Source

 

I'm guessing what is going on here is you LabVIEW code doesn't get around to writing that serial data very often.  Without seeing the source I can only speculate.  But I would guess that you wrote your code very sequentially.  Do this, then this, then this, then do the first thing again.  This can cause loop rates to be very slow.  It looks like you are taking DAQ data, and depending on how that is configured it may take a while to get you data, and writing to the serial port will only happen after all the other steps have been finished.

 

I'd put some timing probes like this one, which allow you to see how much time it takes to go from one error wire to the next.  Or if you only probe a single error wire, then it is the time it takes to get back around to that error wire.

 

A better desing might be a producer consumer, where one loop simply talks serial and can be commanded asyncronously so you don't need to wait on the other operations to finish before writing to the serial port.

Message 2 of 2
(4,265 Views)