rasmusvt Posted July 10, 2014 Report Share Posted July 10, 2014 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! Quote Link to comment
Steve Morris Posted July 10, 2014 Report Share Posted July 10, 2014 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. Quote Link to comment
Mike Le Posted July 10, 2014 Report Share Posted July 10, 2014 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. Quote Link to comment
bigjoepops Posted July 23, 2014 Report Share Posted July 23, 2014 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. 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.