02-11-2021 08:58 AM
Hi, I want to receive 16 bytes coming after every 1 milliseconds interval. i am using VISA configure, comport read in while loop with time delay 1 milliseconds, convert strings to byte arrays. when i count while loop iteration via numeric indicator it shows 850 and some time 866 iterations, but bytes count are just 64 and some times 48.
Solved! Go to Solution.
02-11-2021 09:04 AM
That is a lot of numbers thrown at us, but not much information.
Receiving 16 bytes from where? What are you communicating with?
"Using VISA configure", but what baud rate did you configure?
How does "count loop iteration" relate your "byte counts"?
You should attach your VI so we can see how you are doing things.
02-11-2021 09:06 AM - edited 02-11-2021 09:06 AM
Hi Akbar,
@Akbar7110 wrote:
I want to receive 16 bytes coming after every 1 milliseconds interval. i am using VISA configure, comport
To read 16000 bytes/s from serial port it has to use a baudrate of >= 160kBaud.
What did you configure?
@Akbar7110 wrote:
read in while loop with time delay 1 milliseconds,
Why is there a delay? Which kind of delay?
@Akbar7110 wrote:
when i count while loop iteration via numeric indicator it shows 850 and some time 866 iterations, but bytes count are just 64 and some times 48.
There is a problem in your code!
As you didn't attach the code you need to debug it on your own!
02-11-2021 09:49 AM
Please see attachement files
02-11-2021 10:01 AM
First thing is to get rid of the stacked frame structure. Learn how to use data flow. The stacked frame structure should be removed from the language. Secondly, don't use "Bytes at port" to guage how bytes you read. Without knowing your devie or what the 16 bytes of data look like, you should use whatever protocol the device uses to read the data. Many serial devices terminate their data with a carriage return, line feed or some other terminatal character. Use that to complete your read. Read more than the largest record size (seems like 16 bytes might be yours) and read until the termination character is received. You are also overwriting your data every iteration so I don't know what you plan to do with it. Since your requirements are to read every millisecond, I would place the reading of data in a dedicated loop that only reads from the device. Pass the data to a different processing loop via a queue.
02-11-2021 10:03 AM - edited 02-11-2021 10:05 AM
Are you sure the device (which you still haven't mentioned) is cable of sending 16,000 bytes per second?
Please get rid of the stacked sequence structure and do block diagram cleanup. Also condense your front panel. No need to have two windows set to fill the screen and take up far more real estate than they need to.
Note. A wait timer with a 1 millisecond wait in Windows is really no guarantee that it is precisely a millisecond. And you are not really measuring how fast your bytes come in or how long that loop iteration takes. You should use the High Resolution timer that came out in one of the more recent LabVIEW versions to measure your loop iteration time.
02-11-2021 10:42 AM
Shameless plug: VIWeek 2020/Proper way to communicate over serial