Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARK SCH16T driver updated for new Murata modules #24029

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions src/drivers/imu/murata/sch16t/SCH16T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,28 @@ int SCH16T::probe()
PX4_INFO("COMP_ID:\t 0x%0x", comp_id);
PX4_INFO("ASIC_ID:\t 0x%0x", asic_id);

bool success = asic_id == 0x21 && comp_id == 0x23;
// Determine chip version based on COMP_ID and ASIC_ID

return success ? PX4_OK : PX4_ERROR;
if (asic_id == 0x21 && comp_id == 0x23) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For actually storing the detected version I would do all of this in the configure() (after the reset) where it actually matters.

_detected_version = ChipVersion::REV_1;

} else if ((asic_id == 0x20 && comp_id == 0x17) || (asic_id == 0x21 && comp_id == 0x24)) {
// ASIC_ID = 0x20, COMP_ID = 0x17 is a B13 variant of REV_2
// ASIC_ID = 0x21, COMP_ID = 0x24 is a B10 variant of REV_2
_detected_version = ChipVersion::REV_2;

} else {
_detected_version = ChipVersion::UNKNOWN;
PX4_ERR("Unsupported COMP_ID and ASIC_ID combination");
PX4_ERR("COMP_ID: 0x%04X, ASIC_ID: 0x%04X", comp_id, asic_id);
return PX4_ERROR;
}

// Log the detected version
PX4_INFO("Detected Chip Version: %d", static_cast<int>(_detected_version));

// Return success
return PX4_OK;
}

void SCH16T::Reset()
Expand Down Expand Up @@ -375,8 +394,18 @@ void SCH16T::ConfigurationFromParameters()
acc12_ctrl.bits.DYN_ACC_XYZ2 = ACC12_RANGE_80;
acc3_ctrl.bits.DYN_ACC_XYZ3 = ACC3_RANGE_260;

_px4_gyro.set_range(math::radians(327.5f)); // 327.5 °/sec
_px4_gyro.set_scale(math::radians(1.f / 1600.f)); // 1600 LSB/(°/sec)
// Set the range and scale for the sensors based on the detected chip version
if (_detected_version == ChipVersion::REV_1) {
_px4_gyro.set_range(math::radians(327.5f)); // 327.5 °/sec
_px4_gyro.set_scale(math::radians(1.f / 1600.f)); // 1600 LSB/(°/sec)
PX4_INFO("Configured gyro for VERSION_1");

} else {
_px4_gyro.set_range(math::radians(5000.f)); // 5000 °/sec
_px4_gyro.set_scale(math::radians(1.f / 100.f)); // 100 LSB/(°/sec)
PX4_INFO("Configured gyro for VERSION_2");
}

_px4_accel.set_range(163.4f); // 163.4 m/s2
_px4_accel.set_scale(1.f / 3200.f); // 3200 LSB/(m/s2)

Expand Down
7 changes: 7 additions & 0 deletions src/drivers/imu/murata/sch16t/SCH16T.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ class SCH16T : public device::SPI, public I2CSPIDriver<SCH16T>, public ModulePar
uint16_t value;
};

enum class ChipVersion {
UNKNOWN = 0,
REV_1 = 1, // ASIC_ID = 0x21, COMP_ID = 0x23
REV_2 = 2 // ASIC_ID = 0x20, COMP_ID = 0x17
};
ChipVersion _detected_version = ChipVersion::UNKNOWN;

int probe() override;
void exit_and_cleanup() override;

Expand Down
Loading