Using the the I2C and AP_ADC_ADS1115

Hi,

I’m new to the forum, so if I’m breaking any rules or missing any pertinent information, please let me know, and I will address it as soon as I can.

Hardware/Software:

  • CubeOrange
  • ADS1115 analog to digital converter
  • Analog potentiometer
  • WSL2 + VSCode for editing and compiling. (if it matters)

Goal:
I am trying to create an angle of attack sensor that consists of a potentiometer connected to a 16-bit A2D (ADS1115) that connects to the Pixhawk via the I2C2 port.

What I’ve done:
I’ve added an AoA sensor class to the libraries/ directory and had it call the init method of the ADS1115 class. All it’s doing is grabbing the I2C device and initiating the periodic callback of AP_ADC_ADS1115::_update. --All this compiles and loads onto the Pixhawk without an issue.

The Issues:
The problem occurs when it runs the periodic AP_ADC_ADS1115::_update method. Within update, the AP_ADC_ADS1115::read_registers method fails upon calling of AP_HAL::Device::transfer function and I cannot for the life of me figure out why. This is where I cannot find any information to assist in my problem. Any direction would be great.

I should probably add:

  • I have verified that I can talk to the A2D by using the I2C ports on a Raspberry Pi, so the board isn’t DOA.
  • I’ve gone through the very general sensor driver page. It doesn’t provide much help.
  • I’ve read through this AoA sensor addition with different hardware. I actually used this one as a baseline.
  • I’ve loaded the sensor driver onto two different Pixhawks, both fail the same way.
  • I even hooked the SCL/SDA lines to a scope to verify nothing was being written to the port. Spoiler: something was written to the port, but not what I was trying to send it.

I appreciate your time,
John

We actually already have support for the ADS1115, however only for Linux hal. A port to ChibiOS would be cool tho.

Quite hard to advice on code without seeing it, can you share your branch.

My apologies, I should have linked my fork in the original post. Thanks for taking a look.

I think we need to do a move on the device. So line 126 of AP_ADC_ADS1115.cpp should be

_dev = std::move(hal.i2c_mgr->get_device(ADS1115_I2C_BUS, ADS1115_I2C_ADDR));

Might be worth looking at the git blame for that one, presumably it does still work on Linux boards.

The std::move on the device resulted in the same issue, unfortunately. Is there something specific I should be looking for in the git blame? The last time it was updated was around 4 years ago.