Hall Sensor in Interrupt Mode

I’m using the Arduino Nano Matter board to develop a version for this board. I tested PWM and Hall Sensor (Polling, Interrupt), which work well. After that, I create an example (based on other examples) for controlling a BLDC motor with the Hall sensor in velocity control. I see the example work well if the Hall Sensor is in Polling Mode. When I enable the interrupt mode by calling sensor.enableInterrupts(doA, doB, doC). I see that the program is stuck when calling motor.initFOC.

MOT: Monitor enabled!
MOT: Init
MOT: Enable driver.
MOT: Align sensor.

Any suggestions for debugging this issue?

Thank you.

Hi @trungkstn , welcome to SimpleFOC!

Actually the Arduino Nano Matter is quite new board from Arduino, using a new MCU which we do not yet support.
So in the release version of the library it cannot work at the moment.

I have started work to support this chip in a branch of our library: GitHub - runger1101001/Arduino-FOC at silabs_support

The code is more or less finished for the PWM support, but I’m still testing and it’s still crashing :slight_smile: so not quite done yet…

Once PWM is working as expected I will merge to the main library, and it will be released as a MCU type which we support for motor driving but without current sensing.

I hope it will be enough for your needs.

It’s interesting you mention the Hall Sensors not working. We‘ll have to look into that as well, maybe to do with the interrupt pins. If you find out why, please let me know.

Try moving the motor by hand and see if it wakes up. I’ve had hall sensors alternate fast enough that the CPU is flooded with interrupts and can’t get a chance to move the rotor away from the position that’s causing the sensor output to alternate. Usually capacitors are used to filter out the high frequency changes, but the polling mode solves the problem without having to fiddle with hardware so I’d just use that.

1 Like

Hi @runger Thank for your solution but I’m using my implementation :slight_smile:

1 Like

Thanks @dekutree64 for the suggestion. I fixed this by reducing the PWM frequency. Now with 20 kHz, the Hall sensor doesn’t interrupt so often.