Friday, February 22, 2013

AVR Atmega 10dof IMU attitude estimation using Mahony filter + processing

Updated to version 02

This is a 10DOF (Degrees of Freedom) AVR Atmega libray.
An inertial measurement unit, or IMU, is an electronic device that measures and reports on a craft's velocity, orientation, and gravitational forces, using a combination of accelerometers and gyroscopes and magnetometers.



This IMU is built on:
  • 3DOF ADXL345 3-axis accelerometer
  • 3DOF L3G4200D 3-axis gyroscope
  • 3DOF HML5883L 3-axis magnetometer
  • 1DOF BMP085 barometer


Attitude estimation is computed using Mahony complementary filter algorithm available from here: http://www.x-io.co.uk/.


Setup parameters are stored in files:
adxl345/adxl345.h (setup the accelerometer)
l3g4200d/l3g4200d.h (setup the gyroscope)
hmc5883l/hmc5883l.h (setup the magnetometer)
bmp085/bmp085.h (setup the barometer)
imu10dof01/imu10dof01.h (setup the 10dof attitude estimation)

This library was developed on Eclipse, built with avr-gcc on Atmega328 @ 16MHz.


Changelog
  • 02: attitude estimation refactored to fit standards
  • 01: first release


Code


Notes
  • read risk disclaimer
  • excuse my bad english

Monday, February 18, 2013

Light intensity (LUX) measure using BH1750 sensor with an AVR Atmega library

updated to version 02

This is a BH1750 light intensity sensor module with built-in a 16 bit AD converter generating digital signal. With the BH1750 Light Sensor intensity can be directly measured by the luxmeter, without needing to make calculations.
This library provides function to measure lux through I2C.
This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.

User has to setup only resolution mode.
Setup parameters in bh1750.h


Changelog
  • 02: fixed a bug in lux conversion formula.
  • 01: first release.

Code

Notes
  • read risk disclaimer
  • excuse my bad english

Wednesday, February 13, 2013

Reading Temperature and Humidity on AVR Atmega using DHT11 or DHT22/AM2302 library

Updated to version 03

The DHT11/22 are a basic, low-cost digital temperature and humidity sensors. They uses a capacitive humidity sensor and a thermistor to measure the surrounding
air, and spits out a digital signal on the data pin (no analog input pins needed). Compared to the DHT11, DHT22 is more precise, more accurate and works in a bigger
range of temperature/humidity.


This library use DHT11/22 sensor to read temperature and humidity on Atmega micro.
Setup the data port connected to the micro pin in file dht.h
This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.


DHT11
  • Power supply 3.5/5.5V DC
  • Measuring range Humidity: 20/90 %RH
  • Measuring range Temperature: 0/50 Celsius.

DHT22
  • Power supply 3.5/5.5V DC
  • Measuring range Humidity: 0/100 %RH
  • Measuring range Temperature: -40/80 Celsius.

Changelog
  • 03: prevent blocking if something goes wrong
  • 02: first release

Code

Notes
  • read risk disclaimer
  • excuse my bad english

Monday, February 4, 2013

AVR Atmega MPU6050 gyroscope and accelerometer lib + processing

Updated to version 05

The MPU-6050 has an embedded 3-axis MEMS gyroscope, a 3-axis MEMS accelerometer, and a Digital Motion Processor (DMP) hardware accelerator engine with an auxiliary I2C port that interfaces to 3rd party digital sensors such as magnetometers.



In this libray, two attitude extimation mode are implemented, based on gyro + accelerometer
  • internal DMP processor
  • mahony filter


Gyro calibration is suggested to get more accurate parameters.
Setup parameters are stored in file mpu6050.h

A processing.org sketch is provided to display attitude estimation.


This library is developed on Eclipse, built with avr-gcc on Atmega168 @ 16MHz.

In addition to the processing sketch, Omid Abolghasemi provides this Matlab code to visualize quaternion data:
http://www.mathworks.com/matlabcentral/fileexchange/45302-serialport-quaternion-data-visualize


Changelog
  • 05: moved timer settings to header file
  • 04: fixed get/set accelerometer and accelgyroscope offset for DMP
  • 03: init fix to prevent random incorrect +/- 16g scaling register setup at startup (fix by Len Spyker)
  • 02: attitude estimation refactored to fit standards
  • 01: first release


Code


Notes
  • read risk disclaimer
  • excuse my bad english