About

I am a final year Electronics student. The purpose of this blog is to document the making of a quadrotor and to get feedback from other people.


15 responses to “About

  • Diego Aguilera

    Thanks for the intro on i2c on BeagleBone. I was hoping you could tell me or share with me the i2c.h and i2c-dev.h files. I am just starting my first bit of programming on the BeagleBone and I’m having trouble finding those files. Thanks.

  • Diego Aguilera

    Thanks. But I still can’t find the i2c-dev.h that you call in the i2c.h file.

  • ajaykumarkannan

    Ah, you’re taking about that file! It’s actually a system header file. In fact, the linux kernel provides native support for i2c. You just need to make use of the API calls. If you would like to understand the underlying principly behind i2c, you could look at how i2c is used with lower-end processors like the atmega series and to some extent, the arduinos (But they have an API call as well…)

  • flitjes

    He there, I’m doing currently working on the exact same project!
    My goal is to build a WifI enabled quadcopter with video streaming.

  • Diego Aguilera

    I got a few more questions I am hoping you have time for. Quick background on my project. We are trying build a data acquisition system for an off road vehicle at school. Part of the original idea was to use an Arduino, MPU6050 gyroscope/accelerometer, and SD card on the vehicle. I had the bright idea to use the beaglebone instead of the Arduino. The beaglebone stores the gyro/accel along with other voltages/sensors, convertes it to graphs, and pushes to a remote computer. And I’m not a programmer. Needless to say, I’m in over my head. I choose the MPU6050 because this guy Jeff has a great library written for it (as well as other sensors – http://www.i2cdevlib.com/ ). I’ve converted his code over to C++ and got it to compile. But it’s not sure if it’s working 100%. I’ve gone back and looked how I’ve converted his basic i2c readByte, readBytes, and writeByte commands. The new C++ code, which are based (basically exactly) your work, is the code in question. The other readBit(s) and writeBit(s) are dependent on the readByte, readBytes, and writeByte. I was hoping you could look at these sections of code for errors. In particular, the last variable passed, data. I would really appreciate it.
    Code: goo.gl/7XJv6

    I can send you all the code if you are interested. I plan on making all this public once it’s working. I don’t feel there is much info on i2c for the BeagleBone. Thanks.

    • ajaykumarkannan

      Hmmm… I thought I was fairly comprehensive on the i2c post. Well, if you can, let me know what other details should be added to it in a second post so hopefully it will help more so in the future.

      As for your code, one thing which is weird is this. In the readBytes function, you assume that the i2cFile handle is already present but in the other two cases, you open the file handle explicitly and close it at the end. I’m referring to these lines in particular:
      //Open for reading
      i2cFile = open("/dev/i2c-3", O_RDWR);
      if (i2cFile < 0) {
      perror("Error opening");
      exit(1);
      }
      .............................................
      //Close
      close(i2cFile);

      If the file is opened elsewhere in the class, then these two functions will throw up a runtime error. On the other hand, if you are not opening the file elsewhere, then the readBytes function will throw up an error because the file handle i2cFile doesn’t point to anything.
      What I suggest is to open the file handle once in the beginning, probably in the constructor or explicitly if you’re not sure about constructors and close it once at the end of the program or use of the i2c.

      In my code,

      // Constructor
      myI2C::myI2C(){
      this->i2cOpen();
      }

      //Destructor
      myI2C::~myI2C(){
      this->i2cClose();
      }

      // open the Linux device
      void myI2C::i2cOpen()
      {
      g_i2cFile = open("/dev/i2c-3", O_RDWR);
      if (g_i2cFile < 0) {
      perror("i2cOpen");
      exit(1);
      }
      }

      // close the Linux device
      void myI2C::i2cClose()
      {
      close(g_i2cFile);
      }

      The constructor myi2c::myi2c() opens the file (When the class is instantiated) and the destructor myi2c::~myi2c() closes the file when the class is done being used.
      The other option is to open the file each time in all the functions (But this MAY have overheads).

      Hope this helped.

  • Diego Aguilera

    Yes! I had missed an open and close function. And I also added a destructor. I’m still getting some errors with the read/writeBits commands. Thanks again.

  • Diego Aguilera

    One of these days, I’ll post on github. For right now, I’ve copied it here. http://goo.gl/hGSqT

    After playing with it last night, I think the problem is still in the readByte(s) function. Not how I’m reading it, but what it returns. I need it to interact with the rest of the library Jeff has written. It’s a work in progress.

  • Diego Aguilera

    Yeah, exams have slowed me down too. It looks like I am able to read/write to the device fine (reset settings, set clock, set ranges). But I’ve yet to get back the actual gyro/accel readings. I have a feeling there is some setting that needs to be enabled or disabled. I just haven’t found it yet.

  • Atmaj

    Hey I am doing same project, I have some doubts and I have mailed you same thing. I hope you would be able to help me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: