PMSM based on FOC using Hall effect sensors

I have to design the Hall effect sensor on PMSM using FOC control, but I’m stuck after the output of the hall sensors, comes the *position estimation * my question is what’s inside the block of position estimation? I want to do it using Matlab/Simulink but I don’t where to start… thank you

In SimpleFOC, position estimation is done using the SmoothingSensor class in the drivers repository. You’ll have to read through some code to fully understand it.

Start with HallSensor.cpp. It uses interrupts to detect when the sensor state changes, and records the time when the interrupt occurred. HallSensor::getVelocity() uses the time between changes to calculate the motor velocity.

Then the velocity gets low-pass filtered in FOCMotor::shaftVelocity(), which is called from BLDCMotor::move(). This helps prevent feedback effects where a jumpy velocity signal causes jumpy predicted angles which the PID tries to correct, inadvertently making the velocity even more jumpy.

Then BLDCMotor::loopFOC() calls sensor->update(), which in this case will go to SmoothingSensor::update(). It calls HallSensor::update() (which copies the volatile interrupt variables into the base Sensor class variables), and then uses the low-pass filtered velocity and the time since last sensor change to estimate the true rotor position. It’s a very simple extrapolation, but works surprisingly well.

Hall sensors also require a phase correction, because the extrapolation always puts the predicted angle ahead of where it otherwise would be. Offsetting by pi/6 (half of a 60 degree sector) makes the average angle throughout each sector equal to what it would be without extrapolation.

1 Like