LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Output data at specific rate

Hello, 

 
I have been testing out the Zaber VI (A motor company) and trying to code the program to reach best performance (high sampling rate). However, I am facing some issues. I would like to get some feedback from you. I have included my current VI. 


I was able to use the timed loop to pull motor and encoder data with provided Zaber VI and DAQ Asistant for the encoder. I worked all well for customized period up until 14ms. 15ms to 1000ms, it worked great. It gave me the correct amount of samples. But when I changed the period to 14ms, I suddenly lose half of the samples. 

For a 10s measurement, with 14ms of period. I am expected around 700 data points. But I can only get around 400. I have no idea where the issue is. Could someone take a look at my VI and help me with this? 

 

Thank you all in advance! 

0 Kudos
Message 1 of 5
(273 Views)

It is difficult to figure out what you are doing.  You did include your VI (thank you for that), but failed to include all of the VIs (i.e. the entire Project, best done by compressing the Project file by right-clicking it, selecting "Send to:", then "Compressed (zipped) folder", and attaching the resulting .zip file).

 

It would help to describe the I/O system.  I see reference to COM3.  I cannot open your DAQ Assistant to learn how you have configured DAQmx to acquire data.  What is your DAQ device, what are the parameters of data acquisition (including timing, number of samples, etc.).

 

I have a few suggestions that go directly to improving the speed of data acquisition.

  • Do Not Use the Dreaded DAQ Assistant (DDA).  Learn now to use DAQmx to use NI hardware (I just realized you didn't mention, or I didn't see, what hardware you are using!) to acquire data, particularly as much DAQ hardware has built-in timing that allow it to acquire data in "buffers", i.e. to acquire 1000 samples at a time at a data rate of, say, 1 kHz.
  • So the previous point breaks down into two subpoints:
    • Tell us about the DAQ device.
    • Find "Learn 10 Functions in NI-DAQmx and Solve 80 Percent of your Data Acquisitions Applications".  Ignore the first section that mentions the DDA, and see how (for many devices) 3-5 functions (configuration, timing, read-in-a-loop-multiple-timed-samples) do most of the work for you.
  • I'm puzzled by the Timed Loop.  I'm distressed by using Timing Functions in conjunction with the Timed Loop (it can only slow things down!).  When you find the timing take twice-as-long, it suggests you are catching "every other clock tick", again, another reason for not using a Timed Loop (unless your DAQ device does not have DMA capability, but I couldn't figure out the nature of the DAQ device).
  • Having Data I/O inside the same Loop as the DAQ acquisition means the loop needs time for both acquisition and saving-to-disk.  Use a Producer/Consumer Data pattern to have two concurrent, parallel loops, so instead of the basic loop time being "Time to Acquire" + "Time to Save to Disk", it becomes Maximum ("Time to Acquire", "Time to Save to Disk").

We look forward to more information.

 

Bob Schor

0 Kudos
Message 2 of 5
(248 Views)

I generally think the Timed Structure should not be used in a Windows environment.  It rarely solves problems and often causes more.  Change that to a normal While loop.  The DAQ and instrument communication will limit the loop rate.

 

You also have the issue of an ever-growing array that will slow down your loop.  I recommend using DAQmx Configure Logging to make DAQmx save the data to a TDMS file for you.  This is even more efficient than a Producer/Consumer setup as it bypasses many software layers.  Granted, you need to use the actual DAQmx API instead of the DAQ Assistant to do this.


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 5
(214 Views)

Hello, Bob_Schor and crossrulz 

 

Thank you for the detailed explanation. Let me explain my VI a bit. I will inlcude details this time. 

 

1. The VI I uploaded was the only VI I had. The DAQ Assistant is configured to read the angular position of a quadrature encoder with 2000 cycles per revolution. (Figure 1). I also enabled TDMS logging with this feature (log and read). 

2. The Motor (Zaber Motor) is connected to the computer with DAQ through COM3 (USB connection). I am trying to synchronize the motion of the encoder with the motion of the motor. (encoder 1 rev, motor 0.5 rev) 
3. My DAQ device is PCIE 6353. I am trying to achieve more than1khz sampling of encoder position and motor position. (The more the better). 
4. You mentioned with DAQ Assitant the time delay will be large, but I can get 133 samples within 1ms, but the time stamps are all the same. (Figure 2). 
5. I used time loop to "lock" the loop frequency. I tried to do it with wait(ms), but it was not working well. 
6. Would having a buffer help with data logging? Since I will be storing data in a loop with shift register, and I need that data for finding the difference between the motor and the encoder. 

Yes, I will go through the tutorial and test both the consumer/producer and DAQmx way of tdms logging. 


Hope to hear more suggestions! 

 

Download All
0 Kudos
Message 4 of 5
(190 Views)

Hello yfei2000,

 

Edit: I spoke with my colleagues and understand that you are already in touch with them and that the below would not be applicable based on your connection. 

 

-----

Can you say if you are using the X-USBDC USB to RS232 cable supplied by Zaber? If so, there's a way to optimize the response timing by adjusting the latency through device manager. See here for a quick GIF showing the process.  

 

latency_windows.gif

 

Can you say what Zaber controller model you are using?

 

Best regards,

 

Mike McDonald

Zaber Technologies

Applications Engineering

 

0 Kudos
Message 5 of 5
(186 Views)