Skip to main content
Associate
March 26, 2026
Question

Sensor switch in motor control with FOC algorithm

  • March 26, 2026
  • 1 reply
  • 185 views

I am using the EVLSPIN32G0B1 demo board and the MC Workbench v6.4.1 software, and I would like to use the FOC control algorithm.

More specifically, I would like to use the Hall sensors when the motor starts and operates at low speeds, and then switch to sensorless control at higher speeds.

I have read that the library does not support automatic switching, so I will need to implement it manually in the code.

How should I proceed?

Thank you for your support.

1 reply

GMA
Technical Moderator
March 26, 2026

Hello @Diego3,

User-accessible APIs are defined in the mc_api.c file:

  • MC_GetAverageMecSpeedMotor1_F() returns the last computed average mechanical rotor speed in rpm.
  • MC_SensorSwitchMotor1() is used to switch between the primary and the auxiliary sensor.
If you agree with the answer, please accept it by clicking on 'Accept as solution'.Best regards.GMA
Diego3Author
Associate
March 26, 2026

Thank you for your reply.
How should I use the MC_SensorSwitchMotor1 function?
If I later want to switch back to the Hall sensors, how should I do it? Can I use the MCI_SensorSet function? However, I wouldn’t know how to use it…
Also, how can I check that the PLL is locked before performing the switch?

 

Thank you for your support.

GMA
Technical Moderator
March 26, 2026

Hello @Diego3,

An example that uses MC_SensorSetMotor1() is provided in the "Auxiliary speed sensor usage" chapter of the "User Manual" available through "Workbench tool">About>Documentations>Documentation.

Starting with PLL you can use MC_GetSTMStateMotor1() API to wait for the RUN state.

If you agree with the answer, please accept it by clicking on 'Accept as solution'.Best regards.GMA