LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set sampling rate when record data through ethernet

Hello,

 

I am trying to read and record data from an electric drive. The data come directly from the drive to my computer through Ethernet cable. What would be a good way to make sure I am recording this data at 10hz sampling rate? I know that I can have the read and write function in a  while loop with a wait of 100ms. However it is not reliable because the loop could take longer than 100ms to be completed.

 

Also, I am reading current signal (4-20mA) from an angle sensor using NI 9203 in the cDAQ-9174. I want to read this data at 10hz and pair them with the data from the drive. What would be a good way to make sure the data is synchronized.

 

I have attached my code below.

 

Thank you

0 Kudos
Message 1 of 4
(2,863 Views)

Hi kikiki1988,

 

I recommend you to use DAQ VI’s instead of using DAQ Assistant, since every loop iteration the DAQ Assistant will set the channel and timing parameters and it will require more loop time.  Take a look to this example:

http://forums.ni.com/t5/LabVIEW/Set-sampling-rate-when-record-data-through-ethernet/m-p/2374220

 

Also, I recommend you not to use the Write To Measurement File inside of the loop, you can use shift registers and after you acquisition has ended you write all your data to the file. This express VI opens the file, writes to the file and closes the file on every iteration and it will consume loop time as well.

 

There is no way to assure you are acquiring at 10Hz with Ethernet because it depends of the current transfers speed, however, you can use a Wait Until Next ms Multiple VI to make sure that you have had acquire  with your module and with Ethernet.

 

Carmen C.

 

 

Message 2 of 4
(2,820 Views)

Thank you Carmen. But can you please check the example hyperlink in your post again.

 

Also, If I put "write to measurement file" outside the loop and run this program for hours, where does Labview store the data if the loop is not completed yet. Does it go to computer RAM?

0 Kudos
Message 3 of 4
(2,811 Views)

Look at the Producer/Consumer Design Patterns. They show how to use two (or more) loops to separate the timing of critical tasks from things like file saves which may be slower and could have arbitrary delays.

 

It looks like your ethernet communication is on a private network, so you may be able to get fairly consistent behavior. You probably want to move some of the invoke nodes like Set...Link outside the loop.  I doubt you need to do that every time.  Just have the Reads and Writes you need inside the loop.  Does your device use TCP?  The standard TCP Read and Write might be faster than the Invoke nodes.

 

Lynn

0 Kudos
Message 4 of 4
(2,803 Views)