cancel
Showing results for 
Search instead for 
Did you mean: 

Using timer 3 to read hall sensors

SLori.1
Associate II

I’m trying to use the timer3 ch1 ch2 ch3 of stm32g4 to read the hall sensors of motor but selecting this config under workbench 5.y. the motor doesn’t work. The default hall sensors timer is timer2. Any idea?

23 REPLIES 23
cedric H
ST Employee

Hello,

The question is vast !

The first thing I would try is to generate a project with sensorless (STO-PLL) as primary sensor, and Hall sensor as auxiliary sensor.

With this project build with SDK 5.Y.2, you will be able to plot the angle generated by the STO-PLL algo, and the Hall sensor algo.

The signals name are STO_PLL_EL_ANGLE and HALL_EL_ANGLE.

Attach to this thread a screen shot of this plot containing the two angles, and based on it I will have more clues to help you.

Regards

Cedric

SLori.1
Associate II

Hi,

thank you for your answere, in attached your request:

0693W00000FBBWuQAP.pngThanks

BR

SLori.1
Associate II

In attached another print screen where seems that are read by MCU and sent to the PC firmware but not use by FOC algorithm, consider that i'm rotating the motor by hand (very slow):0693W00000FBBubQAH.pnganother where i'm rotating the motor around 1000rpm:

0693W00000FBBwmQAH.pngthanks BR

cedric H
ST Employee

Hello,

Is your motor spinning fine with the STO-PLL as primary sensor ? the shape of your angle is not what I expected.

Please have a look at the following thread :

https://community.st.com/s/question/0D53W000016n4ZZSAY/can-we-use-hall-sensor-as-main-sensor-and-no-auxiliary-sensor-to-run-the-motor-can-we-control-the-speed-of-the-motor-how-to-decide-the-placement-electrical-angle-default-300-in-workbench

The image I post is done with an oscilloscope based on 5.4.7. but I do expect the same curve with the 5.Y.2 with the new mPilot.

So the first thing is to have a clean STO_PLL_ANGLE shape.

Now regarding the Hall sensors, the first thing I would advise you to do is to set a break point in the SPD_TIM_M1_IRQHandler function inside the stm32g4xx_mc_it.c in order to check that when you manually rotate your rotor, your timer interrupt is properly triggered. You have to be sure that each transition of the three hall sensors signals are able to trigger the timer interrupt.

Regards

Cedric

SLori.1
Associate II

The first answere is no.

I'm not able to debug application only flashing the compiled program, in any case it should think it about generating the code as it happens if you select the timer2.

Thanks

cedric H
ST Employee

Sorry, but I should have started from here :

Could you tell me which boards do you use ?

Cedric

SLori.1
Associate II

Sorry you, i have replicated the IHM16M1 board but with the all sensors on TIMER 3 C6 C7 and C8.

Thanks

cedric H
ST Employee

Could you attach the IOC file that has been generated in your project directory.

I will check that the timer 3 is properly configured.

Cedric

SLori.1
Associate II

of course