Accelerometer data from IMU

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!!

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Developer

    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;

This reply was deleted.

Activity

DIY Robocars via Twitter
RT @a1k0n: @SmallpixelCar @diyrobocars It's just something that's easy to track with chroma keying. I ended up using different colors on th…
yesterday
DIY Robocars via Twitter
yesterday
DIY Robocars via Twitter
RT @TinkerGen_: "The Tinkergen MARK ($199) is my new favorite starter robocar. It’s got everything — computer vision, deep learning, sensor…
Nov 23
DIY Robocars via Twitter
Nov 23
DIY Robocars via Twitter
RT @roboton_io: Join our FREE Sumo Competition 🤖🏆 👉 https://roboton.io/ranking/vsc2020 #sumo #robot #edtech #competition #games4ed https://t.co/WOx…
Nov 16
DIY Drones via Twitter
First impressions of Tinkergen MARK robocar https://ift.tt/36IeZHc
Nov 16
DIY Robocars via Twitter
Our review of the @TinkerGen_ MARK robocar, which is the best on the market right now https://diyrobocars.com/2020/11/15/first-impressions-of-tinkergen-mark-robocar/ https://t.co/ENIlU5SfZ2
Nov 15
DIY Robocars via Twitter
RT @Ingmar_Stapel: I have now explained the OpenBot project in great detail on my blog with 12 articles step by step. I hope you enjoy read…
Nov 15
DIY Robocars via Twitter
RT @DAVGtech: This is a must attend. Click the link, follow link to read the story, sign up. #chaos2020 #digitalconnection #digitalworld ht…
Nov 15
DIY Robocars via Twitter
RT @a1k0n: Got a new chassis for outdoor races (hobbyking Quantum Vandal) but I totally didn't expect that it might cause problems for my g…
Nov 11
DIY Drones via Twitter
First impressions of the Intel OpenBot https://ift.tt/36qkVV4
Nov 10
DIY Robocars via Twitter
Nov 9
DIY Robocars via Twitter
Excellent use of cardboard instead of 3D printing! https://twitter.com/Ingmar_Stapel/status/1324960595318333441
Nov 7
DIY Robocars via Twitter
RT @chr1sa: We've got a record 50 teams competing in this month's @DIYRobocars @donkey_car virtual AI car race. Starting today at 10:00am…
Nov 7
DIY Robocars via Twitter
Nov 6
DIY Robocars via Twitter
RT @a1k0n: Car's view, using a fisheye camera. The ceiling light tracking algorithm gave me some ideas to improve ConeSLAM, and having grou…
Nov 5
More…