Sonntag, 16. Januar 2011

AR.Drone with GPS and a magnetic compass

I've put my drone back together with working GPS and compass attached. After calibrating the compass in it's new place the readings are pretty solid. I'm hoping to be able to correct navdata output for yaw with it pretty soon :-)

Pictures:







Montag, 10. Januar 2011

I2C Tools for the AR.Drone

As I've mentioned before, I've done some investigation concerning the i2c bus on the ar.drone. I just wanted to share the i2c tools used to probe the bus and a couple of results with you real quick. A link to the tools compiled for the drone can be found at the end of this post. Probing the two i2c busses yields the following results:


  1. # i2cdetect -y 0
  2.      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
  3. 00:          -- -- -- -- -- -- -- -- -- -- -- -- --
  4. 10-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  5. 20-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  6. 30-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  7. 40-- -- -- -- -- -- -- -- -- 49 -- -- -- -- -- --
  8. 5050 -- -- -- -- -- -- -- -- -- -- -- -- 5d -- --
  9. 60-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  10. 70-- -- -- -- -- -- -- --                        
  11. # i2cdetect -y 1
  12.      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
  13. 00:          -- -- -- -- -- -- -- -- -- -- -- -- --
  14. 10-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  15. 20-- 21 -- -- -- -- -- -- -- -- -- -- -- -- -- --
  16. 30-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  17. 40-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  18. 50-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  19. 60-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  20. 70-- -- -- -- -- -- -- --      

i2c 0, address 5d is the bottom camera
i2c 0, address 50 is the 24C32WI eeprom

The rest is unknown to me so far. I've not tried to dump the eeprom for fear of accidentally overwriting it, I will probably pull up it's read only pin and give it a shot at some point though. :-)

Files:
i2ctools (arm binaries)

Attaching an I2C compass to the AR.Drone

I've recently attached a magnetic compass to the drone using the i2c bus. Let me start by saying that a good compass is not exactly cheap, I paid about 25€ for it and I've seen it being sold for over 100€ so it's an expensive toy. Also, from what I've gathered, it's really hard to find a good position for it on the drone seeing as all the motors have a strong magnetic field. Right now, my drone isn't exactly flyable but I will share my experience with the additional sensor nonetheless, even though I have not found an ideal spot to place it at yet.



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:


  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <errno.h>
  5. #include <fcntl.h>
  6. #include <sys/time.h>
  7. #include "i2c-dev.h"
  8. #define ADDRESS 0x21
  9. int fd;
  10. int main(int argc, char *argv[]) {
  11.   fd = open( "/dev/i2c-0", O_RDWR );
  12.   if( ioctl( fd, I2C_SLAVE, ADDRESS ) < 0 )
  13.   {
  14.     fprintf( stderr, "Failed to set slave address: %m\n" );
  15.     return 2;
  16.   }
  17.   if( i2c_smbus_write_byte( fd, 'A' ) < 0 )
  18.     fprintf( stderr, "Failed to write 'A' to I2C device: %m\n" );
  19.   usleep(10);
  20.   unsigned result = i2c_smbus_read_word_data(fd, 0);
  21.   unsigned upper = result >> 8 & 0x00FF;
  22.   unsigned lower = result & 0x00FF;
  23.   printf("%u\n", (lower << 8) | upper);
  24.   return 0;
  25. }
So the sensor is attached and working. I will update this as soon as I figure out a good location for the sensor on the drone :-)

Files:
compass.c
compass (arm binary)

Donnerstag, 6. Januar 2011

AR.Drone mainboard overview

Top view (side with ground camera)



1: Camera, I2C bus 0 address 5d
2: I2C connectors for I2C Bus 0 arrive here
3: DRAM cache
4: Connector to navigation board, at least one serial port
5: USB driver SMSC USB3317 (datasheet)
6: Connector to front camera, probably not an I2C device
7: External connection port with TTYS0 serial port and USB port (see link)
8: ROCm Atheros AR6102G-BM2D wireless
9: Power supply for the engines
10: Ground
11: VCC +5V


Bottom view


A: Power supply for the engines
B: Connector to the engine-boards
C: I2C Bus (data)
D: I2C Bus (clock)
E: 5V
F: Ground
G: I2C EEPROM CSI 24C32WI, i2c bus0, address 50 (datasheet)