From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Implement Complementary Filter from Text File

Hello,

 

I am a mechanical engineer student and I have just been introduced to LabView.

 

I am using an IMU (3-axis accelermoeter and 3-axis gyro) to eventually get position data.  

 

A program has already been written to calibrate, find gain and offset of the IMU for the myrio.  The accelerometer has also been converted to g's and gyro to deg/sec. Once the data is collected it is saved to a tab delimited text file.  Columns of: Time(s), Gyro_X, Gyro_Y, Gyro_Z, Acc_X, Acc_Y, and Acc_Z.  This is where my problem begins.

 

I need help in implementing the complementary filter in LabView to combine the gyro and accelerometer data across all three axis'.  I completely understand how the filter works just do not understand how LabView works yet.  I have been referencing the "mycomplementary filter" example here:  https://decibel.ni.com/content/docs/DOC-22933 but it runs in real-time so my setup is a little different.

 

I have looked into the kalman filter but believe a complementray filter will work just fine.  Eventually I will be converting this filtered data to quaternions but that is for a later discussion.

 

Any help would be great!

 

Thanks!

 

0 Kudos
Message 1 of 4
(3,104 Views)

cseymour05,

 

Thank you for posting to the NI forums. What is your set up? What do you mean it runs in real time? You will take your data from the DAQmx Read.vi into the configure gyro.vi and configure accelerometer.vi, then you will take those outputs into the complimentary filter.vi and the output from there to the expression node as it is shown in this example.

 

Community: myComplementary Filter
https://decibel.ni.com/content/docs/DOC-22933

 

Warm Regards,

William Fernandez
Applications Engineering
National Instruments

0 Kudos
Message 2 of 4
(3,050 Views)

Sorry William, I probably didnt explain that very well.  

 

My project consists of two different programs.  The first program runs through the myrio that calibrates, collects and converts the IMU data and outputs it to a tab delimited text file.  The file contains: time, Gyro_X, Gyro_Y, Gyro_Z, Accel_X, Accel_Y, and Accel_Z data.  This program has been completed.

 

The second program will use this text file from the above program and process the data.  That is why I am having trouble with the complementary filter example.  The example runs the filter in parallel with the IMU moving around.  I already have a full set of data and I want to run it through the filter.  

 

I currently have two problems:

 

1.  The inputs into the complimentary filter.vi for the accelerometer and the gyro are DBL 64 Bit Numbers.  From my text file I have arrays of numbers so I want to be able to input an array into the filter and also output an array.

 

2.  When using arrays in the complimentary filter.vi it messes up the previousangle node/calculation.  Since I am new to LabView I have no idea where to start.  I am unsure how to use the previous angle in an expression using an array of data.

 

Thanks,

Christian Seymour

0 Kudos
Message 3 of 4
(3,043 Views)

Cseymour05,

 

You will have to double click on the complimentary filter and modify the code to have it accept an array instead of a scalar as well as to have it output an array. You will also have to mofify the code inside the formula node.

 

This formula node and shift registers tutorial might be a good start. 

 

Tutorial: MathScript and Formula Nodes
http://www.ni.com/white-paper/7572/en/

 

Passing Data Between Loop Iterations in NI LabVIEW
http://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm

 

Warm Regards,

William Fernandez
Applications Engineering
National Instruments

0 Kudos
Message 4 of 4
(3,021 Views)