LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding decrease the latency between each encoder sampling

Hello all, 

 

I tried to use Labview to read an angular encoder. I modified one of the example codes and get around 90ms between each encoder reading. I am wondering what are some ways for me to decrease that to 1ms. So I can reach 1khz of sampling on that angular encoder. 

 

Thank you in advance. I have the code and excel file enclosed. 

Download All
0 Kudos
Message 1 of 4
(1,014 Views)

Three key things:

 

1. Use a 1 kHz sample clock.  On many devices, you'll need to generate this clock with pulse train output from a different counter.

2. Don't try to do things 1 sample at a time.  A general recommendation would be 0.1 sec worth of samples per read which here would be 100 samples.   As a relative beginner, you might get to a useful result quicker by bumping that up to 1000 samples per read (one full second worth).

 

3. Beware file writes inside your data acq loop!  I don't trust express vi's to be efficient and  would instead use low-level file writes where you open the file one time only before the loop, then write to the file repeatedly with a file reference (not a file path).

    Low level file writes should keep up without any problem at 100 samples per loop iteration.  Your express vi file write would likely keep up for quite a while at 1000 samples per loop iteration, if you need to save learning about file operations for a later time.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
Message 2 of 4
(995 Views)

Hello, Kevin_Price 

 

Thank you for the reply. I have tried a few things and here are my concerns. 

 

1. I was not sure how to use a separate counter to output signal to my counter for encoder. I chose to use the Daq assistant VI and tried to find its highest sampling rate. But I have been having difficulties using the logging functionality and read the output TDMS file. I tired to open the TDMS file with excel plug-in, but it gave me gibberish instead of data. 

2. Yes, Thank you for the file opening suggestions. I realize opening and closing excel file might be the bottleneck. I tried to use the Open and Close file VI, but I don't see a way of storing the data from DAQ assistant since it is dynamic data. Neither write text file nor write binary file worked for me. Could you give me some guidance on this? 

 

Thank you for your time. 

0 Kudos
Message 3 of 4
(910 Views)

You can learn a lot by exploring and tinkering, starting from "Help->Find Examples...".   If you plan to tinker and modify things, be sure you FIRST save a copy of the example vi to a location of your own choosing.  Then only tinker and modify the copy, NOT the original.

 

You can run 2 separate counter examples at the same time by specifying a unique counter on your device for each example.  Let one be a continuous pulse train output where you can choose a PFI terminal to output the signal.  Let the other be a continuous position measurement that lets you specify the same PFI terminal as the sample clock.

 

Do that much first, and we can get back to file writing issues later if you still have questions.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
Message 4 of 4
(863 Views)