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

Accelerometer ISM330DHCX on Nucleo-IKS02A1 #28947

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sergey-pilot
Copy link

Nucleo-H743ZI with installed X-Nucleo-IKS02A1 extension board. Driver for Accelerometer and Gyro ISM330DHCX

# board ID for firmware load
APJ_BOARD_ID 139

# the nucleo seems to have trouble with flashing the last sector?
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# the nucleo seems to have trouble with flashing the last sector?

define STM32_HSE_BYPASS

# board ID for firmware load
APJ_BOARD_ID 139
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably deserves a separate board ID; this new firmware is not going to boot on a board without the IMU available... you can reserve another id in board_types.txt (above 1000)

@@ -0,0 +1,49 @@
# hw definition file for processing by chibios_hwdef.py
Copy link
Contributor

Choose a reason for hiding this comment

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

This should include the hwdef.dat from the board this is derived from, undef APJ_BOARD_ID and set that alone.

@@ -0,0 +1,129 @@
# hw definition file for processing by chibios_hwdef.py
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be includiong a base hwdef.dat from somewhere and only updating/overriding what it needs to.

Comment on lines +91 to +94
PE9 TIM1_CH1 TIM1 PWM(1) GPIO(60)
PE11 TIM1_CH2 TIM1 PWM(2) GPIO(64)
PB1 TIM3_CH4 TIM3 PWM(3) GPIO(47)
PC8 TIM3_CH3 TIM3 PWM(4) GPIO(98)
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it does a little more than act as a test-bed :-)

Vector3f accel = Vector3f(accbuf[0], -accbuf[1], -accbuf[2]);
// Adjust for chip scaling to get m/s/s
//accel *= ISM330DHCX_ACCELEROMETER_SCALE_M_S;
float scale = 9.8f/4096.0f;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
float scale = 9.8f/4096.0f;
const float scale = 9.8f/4096.0f;


}
if (status & 0x02) {
int16_t girobuf[3];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
int16_t girobuf[3];
int16_t gyrobuf[3];

if (status & 0x02) {
int16_t girobuf[3];
if (_dev->read_registers(ISM330DHCX_ADDR_OUTX_L_G, (uint8_t *)girobuf, sizeof(girobuf))) {
Vector3f gyro = Vector3f(girobuf[0], -girobuf[1], -girobuf[2]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Vector3f gyro = Vector3f(girobuf[0], -girobuf[1], -girobuf[2]);
Vector3f gyro{girobuf[0], -girobuf[1], -girobuf[2]};

Comment on lines +315 to +317
float _gyro_scale = ISM330DHCX_GYRO_SCALE_R_S;

gyro *= _gyro_scale;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
float _gyro_scale = ISM330DHCX_GYRO_SCALE_R_S;
gyro *= _gyro_scale;
gyro *= ISM330DHCX_GYRO_SCALE_R_S;

#include <AP_HAL/AP_HAL.h>

#include <AP_HAL/I2CDevice.h>
#include <Filter/Filter.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#include <Filter/Filter.h>

@peterbarker
Copy link
Contributor

What testing has this driver had?

We have previously chosen not to support sensors as their results were too poor for flight - if you have some flight logs with a comparison IMU it would be nice to see them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants