Zero electrical angle in torque mode

Hi,

I have a question about expected behavior of torque control mode. Specifically I am using the voltage mode in torque control loop.

The motor behaves rather random after every reboot of the driver. Let me explain :D!

First, it goes through the sensor alignment process to match the absolute zero of the sensor with electrical angle of the motor. This is where I am getting a little lost in the theory.

I’ve read through the “theory corner” docs for Motor-Sensor align and it states that the electrical angle is USUALLY defined by the vector of phase A (does usually mean that SimpleFOC uses this definition ???). But the provided images does not really correspond to that. Example:

This picture (from what I understand) shows magnetic field vector of the stator aligned to -180° and rotor being at what we call “zero electrical angle”. But I feel like neither of the 2 are really where they should be. Are all angles in this library based off the “vertical” axis?? I just assumed they follow the same rules as they do with trigonometric functions (“meaning 0° is the right half of horizontal axis”).

And I am even more confused about the definition of the vectors, since it also seems to differ from what the docs state.

According to this picture from the docs the vectors in the first diagram are incorrectly oriented.

Maybe I just horribly misunderstood, so can anyone please explain in simple terms what exactly does the “zero electrical angle” mean? Maybe even provide some context with the magnetic field orientation vectors.

Getting back to the sensor alignment procedure. The “zero electrical angle” is always different and seems to drastically influence the behavior of the torque voltage control mode. Here are some debug logs I got from running the code:

MOT: sensor_direction==CW
MOT: PP check: OK!
MOT: Zero elec. angle: 2.39

MOT: sensor_direction==CW
MOT: PP check: OK!
MOT: Zero elec. angle: 2.45

MOT: sensor_direction==CW
MOT: PP check: OK!
MOT: Zero elec. angle: 1.82

MOT: sensor_direction==CW
MOT: PP check: OK!
MOT: Zero elec. angle: 1.94

MOT: sensor_direction==CW
MOT: PP check: OK!
MOT: Zero elec. angle: 1.53

It seems that the lower the zero elec. angle, the faster the rotation speed. Some kind of slowing down and accelerating again in each revolution is also present in all my attempts. It looks something like this:

2.39 zero elec. angle:

1.53 zero elec. angle:

I am using the AS5600 I2C magnetic encoder with 4mm radial magnet. The sensor is mounted 1mm away from the magnet with plastic screws. Lowering the distance to 0.7mm didn’t help at all.

Does anyone know what might be the issue and how is the rotation related to zero electrical angle??

Thanks in advance :smiley:

Adam

Yeah, the auto-calibration doesn’t work very well. I always have to finetune the zero angle by hand and set motor.zero_electric_angle and motor.sensor_direction before calling initFOC to skip calibration.

I think the proper fix would be to record the zero angle during the motor back-and-forth movement, and average the values when approaching from both directions. As it is, the back-and-forth movement is only used to detect sensor direction, and then it does a single setPhaseVoltage call to jump to the zero position. But as you’ve found, it doesn’t reliably jump to the exact same position every time (although yours is even more random than I would expect). And if I remember correctly, the position it tries to jump to is half way between cogging steps, so coggy motors are physically incapable of holding it. So even with approaching from both directions, it may be better to record the sensor readings at a cogging step and then offset by half a step to get the desired zero position.

Some day I’ll work on it myself. But today is not that day.

Hey @Papouc ,

I think you have some confusion here between the physical angle and the electrical angle. All the calibration is about finding the zero electrical angle in terms of the sensor coordinates, which for an AS5600 measure physical angle and not electrical, and so you have to align them.

But how this alignment looks “in space” is a question of the motor construction, and the orientation of the stator teeth compared to the immobile frame, and the orientation of the magnet on the rotor vs the physical magnets on the rotor. And whether any of the electrical angles would be considered “vertical” is also a question of how you mount the motor in physical space…
So no - the diagrams are to help with understanding only, refer to the electrical and stator coordialnate spaces, and have no relation to “vertical” or the physical coordinates of your office.

The electrical rotations repeat N times in the motors complete physical rotation that the sensor measures, where N is the number of pole pairs. So if your motor has 22 poles, ie 11 pole-pairs, then there are 11 electrical rotations per physical one, and hence also 11 possible electrical zero values it could find during calibration.
So it is not expected that it finds the same electrical zero value each time you calibrate.

That said, it is expected that it should calibrate to one of the 11 electrical zeros, and since the magnetic sensor is absolute, those should always have the same 11 angles…

If the calibration isn’t working well the usual reasons are that the motor has too much friction or too much load to move freely, or too little alignment voltage to move it properly.

On stepper motors it’s also often the sensor accuracy compared to the high pole pair number of the stepper, but that’s not your case.

What alignment voltage are you using, and how many pole pairs is this motor?

My tuning procedure is to adjust until max achievable speed is the same in both directions. If the angle is off, one direction will be faster due to field weakening.

Hi,

sorry for the late answer (I had some important stuff to attend). Thanks for the zero electrical angle explanation. Still, I would like to ask what is the relation between the zero electrical angle and rotation speed in torque voltage mode? Why does the motor rotate quicker with lower el. angle values?

About the motor and alignment voltage… It is a 40 pole motor and I have tried several alignment voltages. I’ve started at 0.6V and later increased to 1.0V and 1.5V. None of which seems to cause any improvement in the calibration procedure. It just eats up more current :smiley: .

I’ll try to fine tune the el. angle myself and skip the calibration for now.