I am going to implement the Complementary filter into my system but i do not quite understand what is the "dt" means and how should i find out the "dt" in the Complementary filter equation. This is where I found out the complementary filter equation https://www.pieter-jan.com/node/11 and this is the equation angle = 0.98 * (agnle + gyrData * dt) + 0.02 * (accData).
These are the code i am using now and how can i determined the "dt" from the Complementary filter equation?
Code:
while n!= 10:
data = bus.read_i2c_block_data(0x68, 0x3B, 6)
xAccl = data[0] * 256 + data[1]
if xAccl > 32767 :
xAccl -= 65536
yAccl = data[2] * 256 + data[3]
if yAccl > 32767 :
yAccl -= 65536
zAccl = data[4] * 256 + data[5]
if zAccl > 32767 :
zAccl -= 65536
data = bus.read_i2c_block_data(0x68, 0x43, 6)
xGyro = data[0] * 256 + data[1]
if xGyro > 32767 :
xGyro -= 65536
yGyro = data[2] * 256 + data[3]
if yGyro > 32767 :
yGyro -= 65536
zGyro = data[4] * 256 + data[5]
if zGyro > 32767 :
zGyro -= 65536
totZdata += zAccl
totXdata += xAccl
totYdata += yAccl
totGyroXdata += xGyro
totGyroYdata += yGyro
totGyroZdata += zGyro
zAcclG = (zAccl - AcclzOff) / Accl_scale
xAcclG = (xAccl - AcclxOff) / Accl_scale
yAcclG = (yAccl - AcclyOff) / Accl_scale
xGyroDPS = (xGyro - GyroxOff) / Gyro_scale
yGyroDPS = (yGyro - GyroyOff) / Gyro_scale
zGyroDPS = (zGyro - GyrozOff) / Gyro_scale
print ("Acceleration in X-Axis : %.2f G" %xAcclG)
print ("Acceleration in Y-Axis : %.2f G" %yAcclG)
print ("Acceleration in Z-Axis : %.2f G" %zAcclG)
print (" X rotation : %f" % (get_x_rotation(xAcclG, yAcclG, zAcclG)))
print (" Y rotation : %f" % (get_y_rotation(xAcclG, yAcclG, zAcclG)))
print ("X-Axis of Rotation : %.2f" %xGyroDPS)
print ("Y-Axis of Rotation : %.2f" %yGyroDPS)
print ("Z-Axis of Rotation : %.2f" %zGyroDPS)
n += 1