Skip to content

Commit 0598eed

Browse files
committed
change the way we read the ma730 angle
1 parent 20d191a commit 0598eed

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/encoders/ma730/MA730.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ void MA730::init(SPIClass* _spi) {
1616
};
1717

1818
float MA730::getCurrentAngle() {
19-
return ((float)readRawAngle())/(float)MA730_CPR * 2.0f * (float)PI;
19+
return (readRawAngle() * _2PI)/MA730_CPR;
2020
}; // angle in radians, return current value
2121

2222
uint16_t MA730::readRawAngle() {
2323
uint16_t angle = transfer16(0x0000);
24-
return angle>>2;
24+
return angle;
2525
}; // 14bit angle value
2626

2727
uint16_t MA730::getZero() {

src/encoders/ma730/MA730.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ enum FieldStrength {
1313
};
1414

1515

16-
#define MA730_CPR 16384
16+
#define _2PI 6.28318530718f
17+
#define MA730_CPR 65536.0f
1718

1819
#define MA730_REG_ZERO_POSITION_LSB 0x00
1920
#define MA730_REG_ZERO_POSITION_MSB 0x01
@@ -27,7 +28,7 @@ enum FieldStrength {
2728

2829
#define MA730_BITORDER MSBFIRST
2930

30-
static SPISettings MA730SPISettings(8000000, MA730_BITORDER, SPI_MODE3); // @suppress("Invalid arguments")
31+
static SPISettings MA730SPISettings(1000000, MA730_BITORDER, SPI_MODE3); // @suppress("Invalid arguments")
3132
static SPISettings MA730SSISettings(4000000, MA730_BITORDER, SPI_MODE1); // @suppress("Invalid arguments")
3233

3334

0 commit comments

Comments
 (0)