I am currently working in collaboration with Jon Verbeke on a project with multiple ultrasonic sensors on a quadrotor. We started from available analog ultrasonic sensors, an I2C ADC (analog to digital converter) to read out the sonars and I2C expander to trigger the sonars.
This setup was already implemented on an APM2.5 and we expected a similar implementation procedure on the Pixhawk. However, we were wrong :/ As we found out the best way to implement the i2c devices on the pixhawk is by writing drivers for them (see post).
We started with writing a drivers for the i2c expander (PCF8575) and plan to write one for the i2c ADC(ADS7828) as well, if we get the hang of it! We would gladly share these drivers IF we can get them to work! The hmc5883 driver code is used as guiding example. Together with the drivers, libraries are being written. I start to understand most of the driver implementation. But i still have some issues and ran into a problem:
1)First how does the code know which driver it has to use? You can add drivers in arducopter/mk/PX4/config_px4fmu-v2_APM.mk but how are they linked to the library components? For example the compass: the only link i can find in the library files (AP_Compass_PX4.h en cpp) is a link to the drv_mag.h file. But this file does not link to the hmc5885 compass as far as i can tell.
2) Second the drivers and libraries compile and can be uploaded. But when i wanted to start to test the code by uploading a slightly changed code (set all pins to zero), i ran into a problem. The code still compiles, and uploads, but when it is done uploading the Pixhawk is getting in some kind of error state: the RGB led is solid red and the buzzer continuously makes 3 short and 3 long beeps. I can still upload other code, but i still get the same error signals (red + beeps).
Has someone else encountered this problem? Can some one lend me a hand with these issues? Or even better, has someone wirtten these i2c drivers for these boards? Anyhow when the drivers work they are made available to the community!!