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: 

Elapsed time in serial communication

Hi everybody,

I created a simple VI to measure the elapsed time, which the serial communication protocol needs to transfer several characters.
But if I do theoretical calculations, also with different baud rates in the sub-VI conf s-port, the theoretical results differ a lot from the measured results.
I also observed, by increasing the number of transferred characters one by one, the elapsed time decreases or increases.
I attached the VI. Can anybody tell me, if I am doing completely wrong and maybe there is a better and more precise method to measure the transfer time of a serial communication.
Thanks a lot.
Cheers
Aquarel
0 Kudos
Message 1 of 7
(2,655 Views)
One thing you should certainly do is take the start time after you configure the serial port. Move that to an earlier fram. Also, you did not include the VI you're using for configuring the serial port. How have you modified VISA Configure Serial Port?
0 Kudos
Message 2 of 7
(2,647 Views)
sorry, I forgot to attach the VI for configuring the serial port.
I just modified the sequence and added the time stamp after configuring the serial port.
My probem is now, if I send a string of length 21 and I run the VI several times, elapsed time should always be the same?
But it isn't! Why?
0 Kudos
Message 3 of 7
(2,640 Views)
You're going to see some variation simply because the OS (Windows I assume) takes time to do other things periodically. How much actual variation are you seeing?
0 Kudos
Message 4 of 7
(2,633 Views)
Okay, I think these differences may result from the Windows OS. That is true.
I still have the problem, that there is big difference between calculated and measured values (Factor 10).
I added the property node 'Bytes at port' to see how many bytes are exactly written to the serial port, but it is always zero.
Do I have to change anything more in the VI??
Thanks.
0 Kudos
Message 5 of 7
(2,618 Views)
Bytes at Serial Port will tell you how many bytes are in the receive buffer. To know how many bytes you send, look at the return count output of VISA Write.
Message 6 of 7
(2,611 Views)
Re: the "factor of 10."

Did you consider the fact that baud rates for the serial port should be thought of as BITS per second rather than BYTES? The factor of 10 may simply be your 8 data bits + 1 start bit + 1 stop bit = 10 total bits worth of time per byte transferred.

-Kevin P.
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 7 of 7
(2,606 Views)