DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Remove drift from gyro signal

 

Hi

My attachment tries to show you what I mean. I log signals from a gyro, but due to it's nature the signal drifts over time (blue graph in the attachment). What I would like to do in the post process analysis is to "normalize" the signal by  removing the drift as shown in the red graph in the attachment. Is there a function in DIAdem that could be useful for this task, or am I better off trying to do some scripting? One can assume that the drift is linear over time.

0 Kudos
Message 1 of 7
(7,190 Views)

hibux,

Assuming your assumption is correct that the drift is linear over time, here is what might solve the problem : You run a linear regression for your signal. As a result you will get new channel. If you then subtract the new channel from your signal, the result should be your signal minus the drift.

 

If you want to, you could provide one or more example signals and post them so that we can create an example script for your.

 

Andreas

0 Kudos
Message 2 of 7
(7,169 Views)
Hi

I tried the linear regression, but couldn't get it to do what I wanted. I'll give it another try though as I'm new to DIAdem, been using FAMOS up intil now.

I've attached a file with the data (hopefully in a useful DIAdem format).
0 Kudos
Message 3 of 7
(7,141 Views)
Hi,

The Zip archive you have submitted contains only the file gyro_signal.tdm. What we also need to get your data is the file gyro_signal.tdx from the same directory.

(TDM datasets are split in the descriptive TDM file being an XML format and in the bulk data contained in the binary TDX file.)

Please submit your TDX file (gyro_signal.tdx) as well,
Ralf
0 Kudos
Message 4 of 7
(7,129 Views)
Thanks for the help, of course I couldn't get it right the first time 🙂

I've now attached the .tdx file also, hope this helps.
0 Kudos
Message 5 of 7
(7,119 Views)

Hello Hibux,

 

please see the script below. It describes the solution step by step. You can also execute all of the steps interactively. The one thing to keep an eye on is that you have to set the number of output point for the linear regression to the number of point of theinput signal.

 

Andreas

 

 

Option Explicit  'Forces the explicit declaration of all the variables in a script.
Dim   oChannel,sgTempChannel,sgDataFilename
' set the following to the name of teh dtafile on your harddisk
sgDataFilename = "C:\Dokumente und Einstellungen\GrHauba\Desktop\Customer_gyro\gyro signal.TDM"
Call Data.Root.Clear()
' Load dataset
Call DataFileLoad(sgDataFilename ,"TDM","Load") '... DataFilename,FileImportFilter,ImportAction
' Process channel "D1_GyroPos" in the first group
Set oChannel  = data.Root.ChannelGroups(1).Channels("D1_GyroPos")
sgTempChannel = "RegressionY"

' Calculate linear regression.
' Set number of output points to the length of the input channel
Call ChnRegrXYCalc("",oChannel,"","/"&sgTempChannel,"linear","Partition complete area",oChannel.Size,1) '... XW,Y,E,E,RegrType,XChnStyle,XNo,XDiv
' Subtract, createing a new channel
' Call ChnSub(oChannel,"/"&sgTempChannel,"/D1_GyroPos_NoDrift") '... Y,Y1,E
' Subtract, overwriting original channel
Call ChnSub(oChannel,"/"&sgTempChannel,oChannel.GetReference(eRefTypeIndexName))
data.Root.ActiveChannelGroup.Channels.Remove(sgTempChannel)

0 Kudos
Message 6 of 7
(7,106 Views)
Sorry for the late reply, but a big thanks to you. Your script seems to do exactly what I was looking for. I'll run it on some other datasets for comparison and let you know if I get the same result as I did with FAMOS.
0 Kudos
Message 7 of 7
(7,053 Views)