硬件:
ESP32C3FH4;
MT6701.
软件:simpleFOC库2.2.1
MT6701角度数据寄存器:

main.cpp:
MagneticSensorI2C sensor = MagneticSensorI2C(0x06, 14, 0x03, 8);
修改MagneticSensorI2C库函数:
MagneticSensorI2C::MagneticSensorI2C(uint8_t _chip_address, int _bit_resolution, uint8_t _angle_register_msb, int _bits_used_msb){
// chip I2C address
chip_address = _chip_address;
// angle read register of the magnetic sensor
angle_register_msb = _angle_register_msb;
// register maximum value (counts per revolution)
cpr = pow(2, _bit_resolution);
// depending on the sensor architecture there are different combinations of
// LSB and MSB register used bits
// used bits in LSB
lsb_used = _bit_resolution - _bits_used_msb;
// extraction masks
lsb_mask = (uint8_t)( (2 << lsb_used) >> 2 );
msb_mask = (uint8_t)( (2 << _bits_used_msb) - 1 );
wire = &Wire;
}

263

被折叠的 条评论
为什么被折叠?



