LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sampling Serial Port Data

I am sampling data coming in via the serial port. The data is updated every second Displaying the one second data is fine, however I only want to store a record every fifth minute, how do I accomplish this without storing all the one second data?

0 Kudos
Message 1 of 6
(2,497 Views)

Use the Elaspsed Time Express VI to determine when 5 minutes have passed.  Put the code where you are storing the data inside a case structure that is wired to the Time Elapsed? output of the Express VI.

0 Kudos
Message 2 of 6
(2,489 Views)

Thank you for your response. How would this solution address data in the serial port buffer: that is, how do I know I am recording data received at the five minute interval verses recording data that happens to be queued in the buffer and was received earlier than the five minute interval?

0 Kudos
Message 3 of 6
(2,471 Views)

MacKensie,

 

You would read the buffer much more often than every five minutes. Read the port every second when the data is received. Put the data in a shift register or other buffer. Keep only as much data as you will want to display or save and discard the older data.  This is called a circular buffer.

 

If you only want to save the most recent data received, just keep only one point in the shift register.  When the 5 minute time has elapsed, save the point in the shift register, which should be the most recent point.

 

Lynn

0 Kudos
Message 4 of 6
(2,467 Views)

I said put the code where you store the value inside the case structure.  I did not say put the serial port read inside the case structure.  As Lynn said, you are constantly reading, only storing the value when the 5 minutes have elapsed.

0 Kudos
Message 5 of 6
(2,464 Views)

Thank you to both of you. I appreciate the support.

0 Kudos
Message 6 of 6
(2,457 Views)