MA730 torque mode: Motor reverses when blocked

In SimpleFOC, I used two types of magnetic encoders. One has the marking “AVQJ,” but I’m not sure what model it is—it works perfectly at both low and high speeds. The other one is marked “AZAJ,” which should be the MA730. This encoder works fine at low speeds but has issues at high speeds. In voltage-controlled torque mode, when I stop the motor from rotating at high speed, the motor briefly spins in reverse before rotating forward again. It even starts oscillating, causing the motor to spin back and forth automatically.

I suspect that when the motor is forced to stop abruptly during high-speed rotation, the rapid deceleration causes incorrect encoder readings.

That sounds more like a PID tuning problem than a sensor problem. The graph looks ok to me. The sensor reading is increasing when velocity is positive, and decreasing when velocity is negative. Try decreasing motor.PID_velocity.I and P

NOT PID set problem, this work at torque mode not need PID
In torque mode, the motor runs perfectly fine when there’s no interference. The issue only occurs when I physically block the motor.

The encoder with the marking “AVQJ” has no problems at all.

Now that I think about it, the velocity is calculated from the rate of change of the sensor reading, so there’s no way they could be mismatched in the graph even if they are in reality.

Post your code so we can rule out any software problems. Double check the magnet is rigidly mounted to the shaft. People have gone insane from slightly loose magnets in the past :slight_smile:

This code ,but The encoder with the marking “AVQJ” work very well. it’s not code problem
#define SERIAL_UART_INSTANCE 1

#include <SimpleFOC.h>

MagneticSensorSPI sensor = MagneticSensorSPI(MA730_SPI,PC14);

BLDCMotor motor = BLDCMotor(7);
BLDCDriver3PWM driver = BLDCDriver3PWM(PB4, PB5, PB9, PC15);

float target_angle = 1;
Commander command = Commander(Serial);
void doTarget(char* cmd) { command.scalar(&target_angle, cmd); }
void onMotor(char* cmd){ command.motor(&motor, cmd); }

SPIClass SPI_2(PB15, PB14, PB13);

void setup() {

Serial.begin(115200);
SimpleFOCDebug::enable(&Serial);

sensor.init(&SPI_2);
motor.linkSensor(&sensor);
driver.voltage_power_supply = 12;
driver.init();
motor.linkDriver(&driver);

motor.foc_modulation = FOCModulationType::SpaceVectorPWM;

motor.controller = MotionControlType::torque;

motor.useMonitoring(Serial);

motor.init();
motor.initFOC();

command.add(‘T’, doTarget, “target angle”);
command.add(‘M’, onMotor, “motor”);

motor.monitor_downsample = 0; // disable monitor at first - optional
Serial.println(F(“Motor ready.”));
Serial.println(F(“Set the target angle using serial terminal:”));
_delay(1000);
}

void loop() {

motor.loopFOC();
motor.move(target_angle);

motor.monitor();
command.run();
}

This marked “AVQJ” work very well, not problem 。 But i can’t know the model, this not MA730
This chip is different from the MA730. I checked it with an oscilloscope and found that it doesn’t output SSI, ABS, or PWM signals.

After repeatedly installing and removing it multiple times, the chip with the “AVQJ” marking shows no issues at all. The “AZAJ”-marked MA730 works perfectly at low speeds, but when obstructed during high-speed operation, it causes motor reversal and vibration/jitter.

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;

Hi @lg28702426 , welcome to SimpleFOC!

It sounds a bit like this could be a filtering issue. What cutoff frequency is the filter set to?

I’ve found the cause: According to the MA730 datasheet, its low-pass filter is set at only 23Hz, which is an extremely low frequency. This causes incorrect angle readings at high speeds. Moreover, the


filter frequency cannot be adjusted.
Filter cutoff frequency 23 Hz

Understanding the MagAlpha Digital Filter: Benefits of the MA732 & MA330