07-21-2011 06:59 AM
I am relatively new to Labview, so please excuse my ignorance.
I recently built a USB three axis accelerometer using a virtual comm port. The device gives 1000 x,y,z samples per second. My task is to log this data along with daqmx data, being able to select any or as many channels as I wish.
My approach was to use three parallel loops. One to receive the accelerometer data, format it into an array compatable with my daqmx task (ie 100 x,y,z samples 10 times / second) and place it on a queue. The second loop just takes the array from the daqmx task and places it on a second queue. The third loop lines up the two queues to display the data and log it to a file. At the end of every set of samples I also place a time stamp in the file.
This all works quite well except for one crazy little problem. I have noted, that "every now and then", unpredictably the daqmx task will give 99 samples, then on the very next aquisition I will get 101 samples. This of courses makes a mess of the logged time stamps and places an error where the 100th sample should have been, the accelerometer works fine. If I disable the accelerometer aquisition, the daqmx task works fine.
I get the feeling, the daqmx loop is not getting enough cpu time, but I am not sure on how to correct this. Please help.
regards
Brett
07-21-2011 07:03 AM
I would say that you need to put a wait in the other loops or make them longer. If you post your code it would be easier to help. Right now we would have to guess at how you programmed your code.
07-21-2011 07:25 AM
Thanks Tim for getting back in touch so quickly. Sorry for not attaching the vi, wasn't thinking. Please don't fall over laughing when you see this, "I am the new kid on the block". Again, thanks for your help.
Regards
Brett
Ps. I am using LV9 SP1 and a PCI-6030e card.
07-21-2011 07:26 AM
Hello again Tim, it's been a long day, here is the vi.
07-21-2011 07:37 AM
OK I looked at what you have going on here. There are better way to do what you have done but I do no thave the time to help today with that part. I do believe that you have timing issues. The wait for each loop may or may not have been exicuted because of where it was in the program. I moved them to the main loop and changed the time on them.
See if what I did helped.
07-21-2011 08:09 AM
couple of issues here.
1/ I have already put the accelerometer into service with software as is. Will build another, it won't take long and I will get back to you with the results.
2/ I can't read the vi you returned. I have LV9.0.1
I certainly beleive there is an easier way of doing this, I do have a tendency to over complicate things. I have taken huge steps over the last weeks and have so much more to learn. This is the exciting part about being on a learning curve.
Brett
07-21-2011 09:07 AM
Here is a 9.0 version
07-21-2011 09:22 AM
Greetings,
I would recommend condensing your code into smaller segments using sub-VIs. There are no sub-VIs in your code. This causes your code to be over-complicated, at least from a viewing stand-point. This also makes it harder to debug and diagnose. I am not sure what is going on with your code, I'm just giving some friendly advise to make things easier for you in the future (and anyone else who looks at your code).
07-21-2011 10:14 AM - edited 07-21-2011 10:23 AM
@Kbt wrote:
..... The device gives 1000 x,y,z samples per second. My task is to log this data along with daqmx data, being able to select any or as many channels as I wish.....
Why log 1000 samples per second? Do you really want 60,000 lines for one minute of data? It's fine to acquire that data into a terminal (for graphs, etc) but if I were to log the data, I would average the data so that I'm logging it no faster than is required. By using the Mean.vi (one per channel of data), you'll get averaged data, and it will not matter if there's 99, 100, or 101 samples. Maybe you'd want to break it into 20 or 50 samples - see what works for your expected event speed.
p.s., even easier: Use Peak Detector.vi (or similar) and log just the peak data of every loop cycle.