LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

parallel loops

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

0 Kudos
Message 1 of 9
(2,674 Views)

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.

Tim
GHSP
0 Kudos
Message 2 of 9
(2,669 Views)

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.

0 Kudos
Message 3 of 9
(2,660 Views)

Hello again Tim, it's been a long day, here is the vi.

0 Kudos
Message 4 of 9
(2,658 Views)

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.

Tim
GHSP
0 Kudos
Message 5 of 9
(2,649 Views)

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

0 Kudos
Message 6 of 9
(2,639 Views)

Here is a 9.0 version

Tim
GHSP
0 Kudos
Message 7 of 9
(2,627 Views)

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 codeSmiley Happy).

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 8 of 9
(2,621 Views)

@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.

Richard






0 Kudos
Message 9 of 9
(2,604 Views)