11-14-2014 06:44 AM
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
11-14-2014 08:47 AM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
15 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord