I am using ArduPilot with IMU and ublox GPS, connected to an XBee telemetry chip. I need acceleration data from the IMU accelerometers, i.e. raw an3, an4, an5 readings. Hence I tried to modify the code in IMU as follows:

 

In arduimu code, under 'Output', I basically added the bolded code as below:

  // This section outputs the IMU orientatiom message
  Serial.print("DIYd");  // This is the message preamble
  IMU_buffer[0]=0x06;
  ck=6;
  IMU_buffer[1] = 0x02;     

  tempint=ToDeg(roll)*100;  //Roll (degrees) * 100 in 2 bytes
  IMU_buffer[2]=tempint&0xff;
  IMU_buffer[3]=(tempint>>8)&0xff;
     
  tempint=ToDeg(pitch)*100;   //Pitch (degrees) * 100 in 2 bytes
  IMU_buffer[4]=tempint&0xff;
  IMU_buffer[5]=(tempint>>8)&0xff;
     
  templong=(ToDeg(yaw)+gc_offset)*100;  //Yaw (degrees) * 100 in 2 bytes
  if(templong>18000) templong -=36000;
  if(templong<-18000) templong +=36000;
  tempint = templong;
  IMU_buffer[6]=tempint&0xff;
  IMU_buffer[7]=(tempint>>8)&0xff;

 

  tempint=Accel_Vector[0]*1000;   //AccX * 1000 in 2 bytes
  IMU_buffer[8]=tempint&0xff;
  IMU_buffer[9]=(tempint>>8)&0xff;

  tempint=Accel_Vector[1]*1000;   //AccY * 1000 in 2 bytes
  IMU_buffer[10]=tempint&0xff;
  IMU_buffer[11]=(tempint>>8)&0xff;

  tempint=Accel_Vector[2]*1000;   //AccZ * 1000 in 2 bytes
  IMU_buffer[12]=tempint&0xff;
  IMU_buffer[13]=(tempint>>8)&0xff;
      
  for (int i=0;i<ck+2;i++) Serial.print (IMU_buffer[i]);
  
  for (int i=0;i<ck+2;i++) {
   IMU_ck_a+=IMU_buffer[i];  //Calculates checksums
   IMU_ck_b+=IMU_ck_a;      
  }
  Serial.print(IMU_ck_a);
  Serial.print(IMU_ck_b);

 

Then in ArduPilot, I added in similar code to receive the data. However, when I uploaded the code and tried to start up the system, it seems to keep iterating the start up message, i.e. start up message keeps looping.

 

Does anyone have any idea whether there's an error in my code or if I did something wrong? I did not change anything else to the codes..

 

Many thanks in advance!!

Views: 279

Reply to This

Replies to This Discussion

You did not adjust the packet length, so the checksum is probably failing on the receive end....

 

Need to change;

IMU_buffer[0]=0x06;
ck=6;

Does ck=6 correspond to a total of 6bytes sent? Is 0x06 the packet length corresponding to ck=6?

 

On the receiving end, Ardupilot side I suppose I also have to adjust accordingly?

Reply to Discussion

RSS

Groups

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

© 2019   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service