MA730 torque mode: Motor reverses when blocked

I tried simulating SPI but encountered the same issue. The chip with the marking “AVQJ” works fine. However, the MA730 with the marking “AZAJ” exhibits jumps when the motor is obstructed at high speeds. This could be due to either excessive acceleration causing incorrect readings in the MA730, or the filter introducing significant angle errors.

However, if the motor is gradually slowed down by applying gentle pressure at high speed, no issue occurs. The reverse jump only happens when the motor is suddenly blocked and forced to decelerate abruptly.

#define MOSI_PIN PB15
#define MISO_PIN PB14
#define SCLK_PIN PB13
// #define CS_PIN PC14 //CS2
#define CS_PIN PB12 //CS1
class MA730SIM : public Sensor {
public:
MA730SIM() {};
virtual ~MA730SIM(){};
virtual float getSensorAngle() override {
float angle_data = readRawAngle();
angle_data = (angle_data / 65536.0f) * _2PI;
return angle_data;
};
virtual void init() {
pinMode(SCLK_PIN, OUTPUT);
pinMode(MOSI_PIN, OUTPUT);
pinMode(MISO_PIN, INPUT);
pinMode(CS_PIN, OUTPUT);
digitalWrite(SCLK_PIN, HIGH); // 模式3:空闲时SCLK为高电平
digitalWrite(CS_PIN, HIGH); // 初始取消片选
};
uint16_t readRawAngle() {
digitalWrite(CS_PIN, LOW); // 使能芯片
uint16_t dataIn = 0;
for (int i = 15; i >= 0; i–) {
// 下降沿:设置MOSI
digitalWrite(SCLK_PIN, LOW);
digitalWrite(MOSI_PIN, (0x0000 & (1 << i)) ? HIGH : LOW);
delayMicroseconds(1); // 短暂延时
// 上升沿:采样MISO
digitalWrite(SCLK_PIN, HIGH);
if (digitalRead(MISO_PIN)) {
dataIn |= (1 << i);
}
delayMicroseconds(1);
}
digitalWrite(CS_PIN, HIGH); // 禁用芯片
// Serial.print("MA730 RAW: ");
// Serial.println(dataIn);
return dataIn;
}
private:
};
MA730SIM sensor;