Jump to content
rasmusvt

Improving sampling rate for single acquisition in while loop

Recommended Posts

Hi everyone!

 

I am currently designing a lab setup, where I need to take measurements from two devices simultaneously. I am dependent on polling one of the devices (a 1-axis stepper) for its position, while the other is a simple readout from a DAQ-board.

 

My problem comes in the form of a low sampling rate. I have included a control that (is supposed to) enable users to set the sampling rate. I then pass the reciporcal of this as the argument for a time delay within a while loop that takes one measurement (polls the stepper and reads a single value from the DAQ board and writes to a spreadsheet file). However, the sampling rate is quite limited, and over the course of 15 seconds, it takes about 600 samples when setting the sampling rate to 1000 S/s. This doesn't seem to change when setting the sampling rate to other values.

 

Does anyone recognize an obvious limitation to my way of implementing this? Am I using the timer wrong? Is there an obviously better way of implementing this?

 

Thank you!

 

Share this post


Link to post
Share on other sites

rasmusvt,

Your sample rate is being limited by your poll, read, and write code.  Your loop will only run as fast as the slowest process, so your sampling rate control will only come into play if it is slower than the time it takes to poll your stepper, read your DAQ, and write to file.  My guess is that polling your stepper is what is taking the most time, especially if you are polling over a simple serial connection.  You might be able to speed that up some if you can increase your baud rate, but I'm just guessing here, and getting to 1000 S/s is probably not in the cards. 

Share this post


Link to post
Share on other sites

I agree with Steve.

 

If it's not vital that you get 1kHz for ALL data, then you can try acquiring each measurement in a separate loop. So you would have two parallel loops, one for polling the stepper, and the other for polling the DAQ.

 

If you find that the DAQ loop is able to keep up at 1kHz, then you could try creating a master loop that will continuously write DAQ data, as well as writing the "last polled" value from the stepper.

 

I'm not sure what your end-goal is, however. If you have trouble getting the DAQ loop to poll at 1kHz, then you'll probably want to play around with the different DAQ read options - one of them should give you the performance you need.

Share this post


Link to post
Share on other sites

rasmusvt,

 

Have you timed how long it takes for a single acquisition?  Is that time consistent?  If not you may be running into Windows delays?  Try increasing the priority of your VIs.  Also remove debugging from them.  That may help speed up your acquisition time.

 

Are you getting your DAQ and stepper data in parallel or series?  If series, you should change your acquisition steps to run in parallel.  Putting these processes in separate loops wouldn't allow you to have the time synchronization that I believe you are looking for.

 

Did you create a DAQ task in MAX or are you using discrete setup steps in your loop?  Make sure you look carefully at what is in the loop and pull out stuff that doesn't need to be done every time the loop iterates.  I find creating DAQ tasks in MAX to be a very easy way to get them done.  All that is need is the start task VI and then all you do use the read data VI.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Similar Content

    • By ASalcedo
      Hello to all.
      I would like to know how I can close my program ordely.
      I mean... I have 4 whiles in my program so when user clicks a "stop" botton close ordely: while 1 and when it is finished then close while 2 then close while 3....
      How can I do that just with a stop botton?
      Thanks a lot.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.