Servers by jDrones

I2C communication to SDP810 not working despite software changes


(Florian) #1

Hi all,

I am trying to connect a SDP810-500 differential I2C pressure sensor to a Pixhawk 3 for a scientific work.

I adapted the existing Airspeed_SDP3X files and created a new Airspeed_SDP810 file.
The problem is that the sensor seems not to be recognized.

  • The sensor was successfully tested with my own AVR-Library
  • The address was changed to 0x25
  • The sensor is correctly connected via I2C to my Pixhawk (other differential pressure sensor works, swap SCL and SDA did not help also)
  • I tried to change the address of the existing Airspeed_SDP3X file with no success (same problem: init is already left after trying to send “CONT_MEAS_STOP”)
  • The init routine is called (verified via UART)
  • The “CONT_MEAS_STOP” command cannot be sent and the “CONT_MEAS_AVG_MODE” command also
  • I tried connecting the sensor with and without pullups at SDA/SCL lines
  • No errors or warnings at the compiler

My init-code is the following:

bool AP_Airspeed_SDP810::init()
{

hal.console->printf(“SDP810 INIT\n”);

const uint8_t address = SDP810_I2C_ADDR;
bool ret = false;

_dev = hal.i2c_mgr->get_device(get_bus(), address);

// lots of retries during probe
_dev->set_retries(10);

hal.console->printf(“STAGE: 1\n”);

// stop continuous average mode
if (!_send_command(SDP810_CONT_MEAS_STOP)) {
_dev->get_semaphore()->give();
return false;
}

hal.console->printf(“STAGE: 2\n”);

// these delays are needed for reliable operation
_dev->get_semaphore()->give();
hal.scheduler->delay_microseconds(20000);

// start continuous average mode
if (!_send_command(SDP810_CONT_MEAS_AVG_MODE)) {
_dev->get_semaphore()->give();
return false;
}

hal.console->printf(“STAGE: 3\n”);

// these delays are needed for reliable operation
_dev->get_semaphore()->give();
hal.scheduler->delay_microseconds(20000);

// step 3 - get scale
uint8_t val[9];
ret = _dev->transfer(nullptr, 0, &val[0], sizeof(val));
if (!ret) {
_dev->get_semaphore()->give();
return false;
}

hal.console->printf(“STAGE: 4\n”);

// Check the CRC
if (!_crc(&val[0], 2, val[2]) || !_crc(&val[3], 2, val[5]) || !_crc(&val[6], 2, val[8])) {
_dev->get_semaphore()->give();
return false;
}

hal.console->printf(“STAGE: 5\n”);

_scale = (((uint16_t)val[6]) << 8) | val[7];

_dev->get_semaphore()->give();

hal.console->printf(“SDP810: Found on bus %u address 0x%02x scale=%u\n”, get_bus(), address, _scale);

hal.console->printf(“STAGE: 6\n”);

/*
this sensor uses zero offset and skips cal
*/
set_use_zero_offset();
set_skip_cal();
set_offset(0);

// drop to 2 retries for runtime
_dev->set_retries(2);

_dev->register_periodic_callback(20000, FUNCTOR_BIND_MEMBER(&AP_Airspeed_SDP810::_timer, void));
return true;
}

UART shows “SDP810 INIT” and “STAGE: 1” but nothing more so I think the I2C communication to the sensor is not working.

I only have a few weeks ArduPilot experience, so I would appreciate help from someone more experienced which may find the cause of this problem.

Thank you in advance!


(Florian) #2

When I set my sensor in the EEPROM settings the SCL line is switched off after some ms, so I think this happens because the sensor is not recognized…
And the sensor does still not answer.

Does nobody have an idea what I can do next?


(Florian) #3

If anyone has the same issue and the sensor is not recognized at all (but hardware connection is correct): try to set the “ARSPD_BUS” EEPROM Setting to “0”. Same issue happens with SDP3X (I2C version)…