LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to Combine a Gyro Sensor With NI DAQ. Stuck at integration.

I have a Gyro Sensor (IMU WitMotion) and i want to connect it to labview to make a graph and save its data. I've succeeded in making a seperate VI specifically for this, with the data acquisition frequency being around 24Hz. However, I would like to connect this VI with a data acquisition VI for an NI-DAQ (NI-4432). I've already made a VI for data acquisition from NI-4432, with the final objective being displaying the acceleration on a graph. I have problems in the integration between the WitMotion VI and the NI 4432 VI. 

For context, I made the WitMotion VI into a SUB VI, that i can put into the NI 4432 VI (So the NI 4432 VI is the main VI). My logic was to put the WitMotion Sub VI into the huge while loop used in the NI 4432 VI, that way the data acquired from both the gyro sensor and NI 4432 can be synchronised and I can save all the data within one while loop. 

When I did this, however, the NI-DAQ part of the program continued to display the acceleration, while the WitMotion part of the program worked very slowly. The display of the results from the Gyro Sensor was extremely slow responding T-T. That is, the value obtained from the Gyro Sensor would be stuck at one value for a very long time before it changed again. (One could say the frequency was below 1, which is terrible). 

 

To "fix" this, I moved the Wit Motion SUB VI into a seperate while loop from the while loop used for the continuous data acquisition from the NI 4432. The program worked. However, to ensure that the data were synchronised, I used the queue from the synchronization palette, and i also tried to use Local Variable, but the first problem occurred again. 

I am trying to find a solution in which I can make the data obtained from both acquisition programs to be synchronised in time. If there is a possible way to get the program to work within one main while loop that would be great, or if there is a way for me to use the synchronization palettes. I will leave PDFS to the coding for the WIT MOTION SUB VI and the combined VI below.

Any help would be greatly appreciated. Thanks in Advance.

0 Kudos
Message 1 of 9
(1,696 Views)

Hi swiftly, and welcome to the forum.  I suspect most of the comments from the experts on here will be along the lines of "post your actual code - we can't debug a picture".

 

Having said that, a few comments about your DAQmx setup:

Don't create and clear your DAQmx task in every iteration of the loop.  Do the setup before the loop starts and the clearing after it ends so you're only doing the DAQmx Read in the loop.  On the Sample Clock VI, set the sample mode to Continuous Samples so it runs continuously.  In this mode (rather confusingly), the samples per channel input defines the buffer size - this is often best left to the DAQmx driver to manage so don't wire this input.  The DAQmx Read then waits for the requested number of samples to become available (in your case, 500 samples at 1 kHz).

 

If there was nothing else in the main loop, the DAQmx Read would determine the loop speed.  However, you have the VISA Read as well.  If this takes longer than DAQmx Read to acquire its data, the DAQmx buffer will eventually overflow.  If it takes less time, it will have to wait until the DAQmx Read has completed for the loop iteration to end and I suspect this may be the source of your problem.

 

Andy

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

The data are from different sources, one is serial the other is a daq and you are aquiring 500 points at 1000 Hz, wich takes 0.5 seconds every time it reads. 

As Andy pointed out, you don't need to setup the daq every time you run the while loop. You can keep the setup and sample clock out side of the loop.

ROtakeCanada_0-1685107814677.png

What is your goal ? to have them data synchronized, on the same table ? for this to happen every iteration, they need to have the same number of points to be stored together. 

 

However, you you just want them to be saved , you can create 2 loops one for each device, one for DAQ other for the VISA and control them using a Producer/Consumer (it's a bit advanced but will do the work). And each loop will save their data (in separate files). If they need to be synchronized, then is another story.

 

ROtakeCanada_1-1685108192617.png

 

 

0 Kudos
Message 3 of 9
(1,644 Views)

Thanks PsyenceFact, actually the speed between the two acquisition was the problem. So, instead of acquiring 500 samples per while loop, I changed it to be 1 sample per while loop so the NI DAQ could be as fast as the IMU Gyro. This actually worked. Unfortunately, I now have a waveform chart that keeps dissapearing (The display for the NI DAQ). That is, the beginning timestamp jumps to a random time stamp and then the graph dissapears. Also, the display graph keeps resetting.

0 Kudos
Message 4 of 9
(1,602 Views)

LVNinja_0-1685366268064.png

try extracting the data from the Wafeform cluster and you can then bundle daq data with the infomation coming from the gyro to plot all together with Waveform Chart if that's what you want. 

LVNinja_1-1685366666953.png

 

 

 

0 Kudos
Message 5 of 9
(1,584 Views)

If you have two devices that operate at inherently different speeds, my recommendation would be to "take advantage of LabVIEW as a Data Flow language" and create a multi-loop routine.

  • Loop #1 -- a DAQmx acquisition loop taking 500 samples/loop and streaming to DAQ Consumer Loop.
  • Loop #2 -- an IMU Gyro loop taking single samples at 24 (or faster?) samples/loop and streaming to Gyro Consumer Loop.
  • Loop #3 -- streams DAQ samples to disk and streams copy to Plot Data Loop.
  • Loop #4 -- streams Gyro samples to disk and streams copy to Plot Data Loop.
  • Loop #5 -- Plots 500 samples from DAQ + however many samples came in from Gyro.

I didn't notice the DAQ sampling speed.  If we say "1 kHz", then 500 samples = 0.5 seconds, so you'd get 500 DAQ samples and 12 Gyro samples.  You'd want to make a 2-channel data stream, so you need to "stretch" your 12 samples to become 500 (exercise for the reader), then simply update the plot every 0.5 sec.

 

LabVIEW supports such parallel loops.  I'd recommend using Stream Channel Wires to connect Loop 1 to Loop 3, Loop 2 to Loop 4, and Loops 3 and 4 to Loop 5.  Be sure that the Loops don't have any "synchronous" connections between them (i.e. no Error Lines going from Loop Out to another Loop In).  You can use properties of the Stream Writers/Readers to stop the Loops (you tell Loops 1 and 2 to stop, they "pass the message" on through their Stream Writers to Loops 3 and 4, and one of them "passes the message" to Loop 5).

 

Bob Schor

0 Kudos
Message 6 of 9
(1,578 Views)

Thanks Bob. I will try your suggestion, just need to study streaming channel wires first a bit, and try with your configuration. Will update soon.

0 Kudos
Message 7 of 9
(1,562 Views)

OH, is it possible to save both the DAQ and GYRO data into 1 TDMS file with one time stamp reference, with this multi loop method? 

0 Kudos
Message 8 of 9
(1,560 Views)

yes, you can setup another loop that receives the data from other loops (from Gyro and Daq) then consolidates them into one data file. 

For example : 

1 Loop for UI

2 Loop for DAq

3 Loop for Gyro

4 loop for Data storage

 

The tricky part is to coordinate all the loops, but you can use queue message handler to be the UI Loop as  conductor and the others as follower.

 

0 Kudos
Message 9 of 9
(1,530 Views)