06-04-2019 06:08 PM
Hi everyone,
I'm having issues with getting quick, smooth data from a serial device. Data currently comes in large chunks (0-4000 bytes), interspersed by many empty reads, which results in visibly delayed acquisition of data. (Chunks come in at ~4 Hz.) I know that streaming smooth, timely data (at a very high frequency) is possible, because we have a MATLAB Simulink program that is able to achieve this with the same device (using FIFO Read Binary).
I'm currently streaming data from a device that sends packet data without termination characters. Each packet starts with [45, 62] and is then followed by seven bytes of data. The attached VI uses a consumer-producer loop. The producer handles serial communication while the consumer is a state machine that identifies headers and then processes them into usable form. I suspect the issue is with the producer loop, but I included the entire subVI for examination. It's currently written to be part of a larger program (stops are linked to a ref and all data goes into a queue).
Things I've tried include:
Any advice or help would appreciated. I suspect there's something I'm misunderstanding about serial ports, and could use guidance from y'all.
Thanks a bunch!
Solved! Go to Solution.
06-05-2019 07:03 AM
I had same issue when i started with custom VISA communication.
I think your problem is that you use Bytes at port function, rather than using that just read a large chunk, for example 1000 bytes.
06-05-2019 11:36 AM
Hi AeroSoul,
Thanks for your suggestion. Having tried that with timeouts of 0 and 10000, the behavior seems to be roughly the same, with data coming in about once every two seconds. With timeout of 0, most reads are empty; with timeout of 10000, the loop iterates ~4 times, waits about 0.5 seconds, and then reads 4 times again. It's almost as if the device itself sends data in clumps of ~4000 bytes. I only know this not to be true because I've seen it working on Simulink. (Note: the Simulink interface is on a different PC.)
I'd be open to investigating the device output with another machine/device, but am not sure how.
06-12-2019 06:48 PM
Came across the solution with some online digging. Turns out it has nothing to do with LabVIEW at all. What I needed to do was to go into the COM port device driver advanced settings in Windows Device Manager and switch latency from 16 ms (default) to 1 ms. All issues have gone away.
06-13-2019 04:50 AM