Aligning Sensor

Hi,
I am new in here and I am trying to understand SimleFOC. I reviewed to github code.

My question is that how to align sensor I dont understand. Do you have any comment or any recommendation article or source about aligning sensor.

Maybe my question is quite easy. Thank you for comments.

"int BLDCMotor::alignSensor() {
if(monitor_port) monitor_port->println(“MOT: Align sensor.”);
// align the electrical phases of the motor and sensor
// set angle -90 degrees "

Why sen angle -90 degrees ?

Hey @Gokhan_Kiremit!
Welcome to the community.

There aro some docs about the motor and sensor alignement, it is a bit outdated but the idea is the same. Here is the link:
https://docs.simplefoc.com/foc_implementation#motor-and-sensor-alignment-initfoc

I am not sure that I understand your question. Do you wish to implement your own sensor?
Do you have something that does not work or you just try to understand the principle?

How to align sensor?
In openloop mode, sensor alignment is not necessary. In fact, a sensor isn’t even necessary! You need to provide correct pole pairs for simple foc to correctly map from electrical degrees to shaft degrees. The motor will move as instructed but may slip if the voltage limit is too low. SimpleFOC won’t know about this slip because it is in openloop mode.

In closed loop, sensor alignment is achieved automatically when you call motor.initFOC(). If your sensor type offers ‘absolute angles’ then initFOC will set the same calibration values each time and there is a mechanism to skip calibration by setting these values yourself in code.

The -90 refers to the angle simplefoc wishes to place the magnetic field in order to achieve the most efficient torque on the motor.