LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get data point every millisecond

Hello,

 

I have a very simple task to perform but I am missing something. I need to perform an analog read (Arduino connected through the serial port) every millisecond (actually I would like to have the opportunity to change the sampling rate as needed, but as an example, let's stick with data points sampled every millisecond, 1 kHz).

 

Find attached a LabVIEW 2015 file with the basics to achieve what I need (I just created an example with random numbers to make it easier to share in the forum; no need for serial devices), but instead of having one data point every millisecond, I am having several points every millisecond. In addition, I am not getting 5000 data points (I expected that because of the 5 seconds period I used into the example). To make the producer loop run ligther, I used queue to transfer data to consumer loop.

 

How should I proceed to achieve what I need?

 

Thanks.

 

Dan07.

0 Kudos
Message 1 of 3
(1,066 Views)

LabVIEW isn't a real-time operating system.  As such, Windows (or MacOS/Linux, if you're using them) can and will decide to pause it from time to time to do system tasks.  So timing things to the millisecond is not something you can do in Windows.

 

The timed loop is only truly able to do its timing as desired when it's run under a real-time OS.  LabVIEW has this option but it's only for things like CompactRIO and the like, not a standard PC, and it's not free or cheap either:

https://www.ni.com/en-us/shop/data-acquisition-and-control/add-ons-for-data-acquisition-and-control/...

 

Your best bet using a standard PC is to offload the timing portion of whatever you're doing to the device you're polling, and not count on LabVIEW itself for anything better than 1-second accuracy or so.  I'm not sure if you can set up an Arduino to do that.

0 Kudos
Message 2 of 3
(1,053 Views)

Luckily for you, your Arduino is spitting out data every 1ms.  So that will determine your data rate, not your Windows system.  Just use a loop to read the data as it comes across the serial port and a queue to send the data to another loop for processing.


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 3 of 3
(1,044 Views)