# DCM matrix implementation problem

Hello all, I'm Leonardo from argentina. I'm implementing dcm algorithm on an lpc1769 and can't make it work.

I test my gyro, obtain raw data, calculate standar deviation on each axis and note that l3g4200 is a litle noise gyro.

I integrate Wt over my timestep, 20msec, and obtain rotating angle for each axis. I note a drift of 1 degree per minute. I check gyro gains and seems to be very close to datasheet.

Finally a porting dcm matrix to my uC. I don't make it work. rigth now I want to implement just gyro on my DCM matrix. well, when I do that I notice that, on still position, dcm is drift too fast. i.e. it go from 1 0 0 to 0 1 0 on first row, then to -1 0 0 in 30 second... On the same time I see that angle calculated by integration is less than 1 degree...

then I make a new test. I put 0 to Y and Z gyro and work only with X gyro. when i log dcm matrix I see that is not drifting to fast, but when a rotate my gyro 4 values, of 9, on dcm matrix change a lot with litle rotation angle. and if a go back to still position dcm is not close to identity....

becouse I log angle integration and chek that the angle calculated is close to rotate angle I think thta gyro offset and gain is correct.

Now I'm asking myself if what I expect is ok,l mean, working with one axis gyro i have to see only 4 values change on my dcm matrix while y rotate de imu. and I should see that a row on dcm have to change from, i.e., 1 0 0 to -1 0 0 when I rotate 180 degrees. is that ok?

I will debug my code with the help of matlab. I'm thinking on log data with my gyro and put it onto matlab implementation and see where the error is, cheking partial calculation.

Can anyone tell me another way to verify where the error is?

thk and best regards

and sorry for my english!!!!!

Views: 1058

### Replies to This Discussion

You could try ArduIMU_test.  You can find it in the downloads for ArduIMU.  ArduIMU_test will need to get output in a format like this:

```             Serial.print("!!!VER:");        Serial.print(SOFTWARE_VER);  //output the software version
Serial.print(",");
Serial.print("RLL:");
//Serial.print(roll * 180/M_PI);
Serial.print(-euler_y);
Serial.print(",PCH:");
//Serial.print(pitch * 180/M_PI);
Serial.print(-euler_z);
Serial.print(",YAW:");
//Serial.print(yaw * 180/M_PI);
Serial.print(-euler_x);
//Serial.print(ToDeg(yaw));
Serial.print(",IMUH:");
Serial.print((imu_health>>8)&0xff);
Serial.print (",");
Serial.print("TOW:");
Serial.print(test);
Serial.println("***");```

Study the ArduIMU program where it prints DCM values and add those to the output. ArduIMU_test doesn't care how you calculate but it does need the right format to display. It will also let you save to buffer and then paste to a document.

1

2

3

4

5

6

7

8

9

10

## Groups

284 members

633 members

32 members

1472 members

• ### Japan ArduCopter Group

215 members

Season Two of the Trust Time Trial (T3) Contest
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here