Servers by jDrones

Multiple I2C airspeed sensor help

i2c
airspeed-sensor
airspeed
hal
pixhawk

(Hunt0r) #1

I’m working on a multi-hole probe, so I’d like to log 3 additional pressure sensors via I2C. So far, I have some success and some failure… could someone help me understand what I’m doing wrong?

Issue 1: Do I need a separate HAL i2c_device for each sensor? Or can a single HAL device talk to all 3 separate I2C addresses? Right now I’m using separate HAL devices, despite “the sensor” being a single “device” physically.

Issue 2: I don’t understand semaphores yet. (Feel free to chuckle if I say something silly…) Can a single semaphore cover all 3 I2C sensors? Or should I be getting a “separate semaphore” for each individual measure()/collect() call from timer()?

Issue 3: How important are determining “accurate” scheduler values for the rate and maximum-time of the sensor-reading-and-logging task? In other words, could my random-guesses (10Hz rate and 200us maximum) actually be my problem? How would I determine that from logs?

Some background, in case that helps to find the underlying problem(s):
In my mind, the 3 pressure sensors are part of a single “unit” so I originally had my sensor’s driver (copied-and-modified from AP_Airspeed) read() and collect() from all 3 sensors with a single function call (from the timer() functionality.) This worked in bench-testing, when I would disable arming checks, arm the pixhawk, and log the sensors. However, when I flew the firmware, only 1 sensor logged correctly, while the other 2 logged always-zero values. I’m confused by this behavior, and don’t know how to diagnose my problem.


(tridge) #2

maybe you could push your changes to a branch on github for us to look at?


(Hunt0r) #3

Unfortunately I can’t figure out how to pull-request against the ArduPlane-3.7.1 tag in the ArduPilot repository. (Not sure if I’m overlooking something?) So I have a temporary solution for now…

I’ve forked ArduPilot, checked out ArduPlane-3.7.1, branched as Hunt0r_THPS, and pushed my changes there: https://github.com/ArduPilot/ardupilot/compare/ArduPlane-3.7.1...hunt0r:Hunt0r_THPS

Unfortunately, I’m not sure that I saved logs of it only logging 1 of the 3 sensors while airborne… I can post those tomorrow if they’re needed? I can also post a log of it working (logging all 3) on the bench if that’s helpful.