Hi Guys,

Today feels like very slow progress. I guess its the end of the week and I'm not thinking straight. I have a question regrading the binary Message protocol used in the main loop in ArduIMU. I am trying to send the Gyro Rate values through to another micro but somewhere along the way the numbers get jumbled. I can say right now that I am receiving the data fine. I think I am just not formatting it correctly. The format I am sending the Gyro_vector out of ArduIMU in is below:
      
      tempint = ToDeg(Gyro_Vector[0])*100; //X Rate
      IMU_buffer[8] = tempint&0xff;
      IMU_buffer[9]=(tempint>>8)&0xff;
      
      tempint = ToDeg(Gyro_Vector[1])*100; //Y Rate
      IMU_buffer[10] = tempint&0xff;
      IMU_buffer[11]=(tempint>>8)&0xff;
      
      tempint = ToDeg(Gyro_Vector[2])*100; //Z Rate
      IMU_buffer[12] = tempint&0xff;
      IMU_buffer[13]=(tempint>>8)&0xff;


And I am assembling it on the other side with this code:

        //Storing Z Rate
        intUnion.byte[0] = buffer[8];
        intUnion.byte[1] = buffer[9];
        Xrate = intUnion.word/100;
        
        //Storing Z Rate
        intUnion.byte[0] = buffer[10];
        intUnion.byte[1] = buffer[11];
        Yrate = intUnion.word/100;
        
        //Storing Z Rate
        intUnion.byte[0] = buffer[12];
        intUnion.byte[1] = buffer[13];
        Zrate = intUnion.word/100;

Assuming I have received it correctly (I use all the checksums etc just too much code to put here) then what is wrong. Instead of getting values from -355 to 600 when reading directly off ArduIMU I now get values like -416 and 555. 

Thanks in advance,

Will

Tags: Ardu, Ardupilot, IMU, gyro

Views: 39

Reply to This

Replies to This Discussion

Your scaling (*100) is too large for transmitting with 2 bytes.

Also there is lots of potential for error in how your parser decodes the message. Without looking at your code that cannot be discounted. Do the buffer indexes line up? The tx buffer may include package length and message ID, while the rx buffer may not (assuming you are reusing a lot of the existing code). Just hard code values in for tempint and verify the basics.
Hi Doug, I though that two bytes were able to represent numbers up to 65,535? my rates dont exceed 600degrees per sec so 600*100= 60,000 which is less than 65,535. Or is my problem that it is a signed number? does this mean only numbers between -65535/2and +65535/2 can be represented? The buffer indexes do all line up. I will try with the constant values tomorrow. Thanks for the tip. If It still doesn't work I'll put my code up tomorrow.

Cheers,

Will
afirmative, signed values
ok, Thanks guys. It's all coming together.

RSS

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service