Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

receive serial data with time

Solved!
Go to solution

Hi,

 

I have a question about serial data. 

When I receive the serial data from NI-9870, is it possible to get the time when the data came in?

Can timestamp helpful?

 

Please let me know.

Thank you.

 

 

0 Kudos
Message 1 of 5
(185 Views)

I just get the time immediately after the message is read.  For a RS-232 bus, this is about as accurate as you will really need.  If you need more accuracy, then your device that is sending the data should timestamp things and put that information in the message.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(129 Views)

Thanks for your reply!!

 

The code I attached is possible to receive serial data and save as a file that contains time and date?

I'm a beginner so not sure about my code....

 

Thank you 🙂

 

0 Kudos
Message 3 of 5
(113 Views)
Solution
Accepted by topic author jay121

1. You should be constantly reading from the serial port to keep the buffer cleared.  You can conditionally log the data.

2. No need for the wait since the VISA Read will limit the loop rate.

3. Use the File IO functions to write your file.  Open the file before your loop and close the file after the loop.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 5
(93 Views)

Thank you so much!!!

Have a great day 🙂

0 Kudos
Message 5 of 5
(77 Views)