Jump to content
I2Cdevlib Forums

Running MPU-6050 DMP Code on ATTiny85


Recommended Posts

Hello,

I have no Arduino evaluation board and wanted to run MPU-6050 DMP code on small ATTiny85 (DIP8) switched to 8Mhz which has 8KB for program memory and hardware USI Twire interface for I2C.

I think I can modify Arduino I2C red/write commands for my own to fit into MPU-6050 library, but unsure whether are other dependencies like bigger program memory for example?

I can attach external EEPROM  via I2C to my ATTiny85 if more configuration data needed to initailze and use MPU-6050 DMP, but have no idea about library size if optimized my AVR ATTiny code for size.

I do not need high frequencies while reading DMP data, so I can provide some kind of external memory buffers if needed.

What about memory requirements to use MPU-6050 DMP stuff with AVR ATTiny?

Do I need preload into MPU-6050 some kind of firmware (hidden in header include files) from i2cdevlib/MPU-6050 library using I2C during initialization or later to be able to read DMP data?

Just trying to figure out how this setup works in this library.

 

Thanks for any advice - Szan.

Link to comment
Share on other sites

  • 3 weeks later...

Hi Szan,

 

This would be quite a challenge, due primarily to the small code space available on the ATTiny, and partly due to the DMP requirements. Basically, you have to power on the MPU chip, then load a ~2 kByte block of binary data in over I2C in order to "prime" the DMP so that it can start generating quaternions. This data has to come from somewhere, and on the Arduino port, it is stored in the flash space. This would probably not be possible on the ATTiny85, since you'd run out of space too quickly. It is probably not impossible if you are very clever, but it would be difficult at best.

Link to comment
Share on other sites

Thank you Jeff for DMP memory requirements hints.

While I have this MPU-6050 running and successfully converted a few undocumented functions from your i2cdevlib library for accel & offset settings and I have full control of this device using raw accel & gyro readings, I've made a look into your motion apis 2 DMP6 example:

jrowberg-i2cdevlib-e2fa9a6-20131008/Arduino/MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino

and when made quick analysis of MPU6050.h and 6axis motion apis 20,  it looks like this block of data is this defined there in header file:

MPU6050_6Axis_MotionApps20.h:

 

#define MPU6050_DMP_CODE_SIZE       1929    // dmpMemory[]
#define MPU6050_DMP_CONFIG_SIZE     192     // dmpConfig[]
#define MPU6050_DMP_UPDATES_SIZE    47      // dmpUpdates[]

 

const unsigned char dmpMemory[MPU6050_DMP_CODE_SIZE] PROGMEM = {

...

}

 

One ATTiny85 has 8K Bytes of In-System Programmable Program Memory Flash, but it supports hardware I2C master/slave modes, so I could simply make one of them as I2C slave (they are not expensive) and use them as storage for system configuration data simply compiled into its program memory flash and make it available (eg. this 2kB DMP memory) via I2C bus to other I2C device.

 

So, I think I can store somewhere this DMP memory, but when looked in dmpInitialize in mentioned example, there are many steps to initialize DMP and it looks very dificult for me at the moment, while 2KB needed for this DMP is rather not so big problem I think.

 

I use PC Linux with my own I2C master library and custom made RS232 De9 <-> I2C bus and now can many complicated calculations fast and log many things from MPU-6050 powered on other side of optoisolated board 3.3Vcc own I2C  bus.

So I do not needed any microcontroler so far to talk to MPU-6050, but write my own MPU-6050 C library to be able run it on small ATTiny85 later, while I use I2C software implementation with a few functions for low level serial port (RS232) pins read/write to switch photocoupers and I have SDA and SCL bidirectional, so I can see if I2C slave makes SCL low, etc....

linux_pc_rs232_de9_i2c_mpu6050test_ADO1_

 

So, the biggest challenge for me at the moment is to understand which is the minimum setup to make successfull DMP readings while I do not need high frequency DMP data-100Hz could be great, but 10Hz will be ok too.

But I'd like to have sensors (accel & gyro) fusion computations made by MPU-6050  hardware if possible.

 

This what I'd like to get from MPU-6050 is gravitation component only (in MPU-6050 coords) with device acceleration removed in moveing (but not too fast (100km/h max) and up to 1g accel) electric vehicle to get tilt angle beetween motion vector and horizon.

Without acceleration I can do it using raw data and maybe complementary filter as well, but I'd like to try do it with hadrware DMP, while have many projects where this MPU-6050 could be very usable if hardware DMP enabled.

Link to comment
Share on other sites

  • 2 months later...

The Digispark is Attiny85 based and has a 24LC256 256Kbit eeprom shield option - i2c address at 0x50.

The connection uses P0 and P2 for SDA and SCL.So 4 useable pins remain for other uses.

http://digistump.com/category/2

 

It would be a very interesting project to enable connecting these two devices and the 6050 modules together.

Adding the motor control shield (which uses an additional two pins) would bring an entire 6050/digispark/eeprom/motorcontrol project to < 30 USD.

Leaving 2 pins remaining for other uses.

 

So reducing the code footprint to fit (with useful main) into the 6k left (after bootloader requirements subtracted from intial 8k) would be a good challenge.

I've just ordered some more from http://www.aliexpress.com/item/2pcs-GY-521-MPU-6050-MPU6050-Module-3-Axis-analog-gyro-sensors-3-Axis-Accelerometer-Module/960384365.html

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...