The compass chip I've attached is an HMC6352 (datasheet, link to breakout board supplier) by Honeywell mounted on a breakout board (very necessary if you are not a soldering pro). I've attached VCC and ground to the two pins carrying those current marked 10 and 11 in my previous post about the mainboard layout. The two i2c wires were attached to what I labeled C and D in said post. To be exact, I chose to attach the sensor to the i2c bus solder joints in the middle of the board, not next to the i2c eeprom; it was really easy to solder the cables on, no protective varnish of any kind. My warranty is probably void now, though. If you don't want to risk voiding your warranty I suggest glueing something onto those pins also I can not imagine that being a really solid connection. In a worst case scenario it's probably easiest if you swap the mainboard out for a replacement part and send the device in for warranty after that ;-)
The sensor is not attached to the same bus the firmware is using for the ground camera, an eeprom and another device I have yet to identify. I have not done excessive testing put I am able to poll the sensor while the firmware is operating so that seems to be a good sign. I slapped together a very small test program to retrieve the current heading from the sensor:
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <sys/time.h>
- #include "i2c-dev.h"
- #define ADDRESS 0x21
- int fd;
- int main(int argc, char *argv[]) {
- fd = open( "/dev/i2c-0", O_RDWR );
- if( ioctl( fd, I2C_SLAVE, ADDRESS ) < 0 )
- {
- fprintf( stderr, "Failed to set slave address: %m\n" );
- return 2;
- }
- if( i2c_smbus_write_byte( fd, 'A' ) < 0 )
- fprintf( stderr, "Failed to write 'A' to I2C device: %m\n" );
- usleep(10);
- unsigned result = i2c_smbus_read_word_data(fd, 0);
- unsigned upper = result >> 8 & 0x00FF;
- unsigned lower = result & 0x00FF;
- return 0;
- }
Files:
compass.c
compass (arm binary)
Where are you running this code? It's not running on the ar.drone is it?
AntwortenLöschenCan you flight on GPS only mode? And be able to control the drone remotely? Thanks
AntwortenLöscheni'm trying to run this code but:
AntwortenLöschen1. you can post the i2c-dev.h file?
2. the address 21? what is? you don't write the address of sensor?
Thanks