Using pixhawk4 (FMUv5) CAP inputs for LidarLite v3

I’m trying to run a LidarLite v3 in PWM mode and measure with CAP. But found no working implementation for that.

Quick code investigations reveals that:

LidarLite’s driver publishes to distance_sensor while reads data published by pwm_input driver in /dev/pwmin0.
pwm_input driver in turn measures on GPIO_PWM_IN with corresponding timer defined in board_config.h.
This pin seems to be available on PPM RC connector on the board.

There are 3 CAP pins available as well on pins GPIO_INPUT_CAP{1…3} with corresponding timers. But those are not used by any driver implementation in master branch.

Which is the best approach to make use of those CAPs for connecting LidarLite? I’m considering duplicating pwm_input driver for those CAPs and rewriting LidarLitePWM driver to make use of this new pwm_input driver. Maybe there is a better approach?

Next question is about i2c. I’ve tried connecting LidarLite to both I2C A and I2C B ports with no great success. It gives error on attempt to start the driver. That’s actually why I switched to PWM which is at least I can verify by oscilloscope working well. Does it matter whether I connect it to A or B port?

Regarding the CAP pins currently there is not support for this driver. If you want to use it in PWM mode you need to connect to the GPIO_PWM_IN pin. Regarding I2C it scans all the busses so you can connect to I2CA, I2CB or the i2c on the gps port. Therefore it should work on any port. You are starting the driver by setting the SENS_EN_LL40LS parameter to ‘i2c’ right?

Hi @DanielePettenuzzo!

Yes I set SENS_EN_LL40LS to i2c. I also set EKF2_HGT_MODE to 2 and EKF2_RNG_AID to 1.

ll40ls status


WARN [ll40ls] No ll40ls driver running


ll40ls start i2c


ERROR [ll40ls] failed to initialize LidarLiteI2C on busnum=1

At the same time running in PWM mode works well. Driver starts.

My bad. pwm_input uses AUX5 on pixhawk4 not PPM RC port. Should I use special fmu mode? Like mode_pwm3cap1 to make sure AUX5 is configured in capture mode? Where AUX5 is physically located? Is it 5th AUX PWM pin? My pixhawk has 8 PWM AUX.