Skip to main content
SLori.1
Associate
September 24, 2021
Question

Using timer 3 to read hall sensors

  • September 24, 2021
  • 23 replies
  • 5077 views

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?

This topic has been closed for replies.

23 replies

cedric H
ST Technical Moderator
September 27, 2021

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
SLori.1Author
Associate
October 1, 2021

Hi,

thank you for your answere, in attached your request:

0693W00000FBBWuQAP.pngThanks

BR

SLori.1
SLori.1Author
Associate
October 1, 2021

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 Technical Moderator
October 1, 2021

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
SLori.1Author
Associate
October 1, 2021

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 Technical Moderator
October 1, 2021

Sorry, but I should have started from here :

Could you tell me which boards do you use ?

Cedric

SLori.1
SLori.1Author
Associate
October 1, 2021

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

Thanks

cedric H
ST Technical Moderator
October 1, 2021

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
SLori.1Author
Associate
October 1, 2021
cedric H
ST Technical Moderator
October 1, 2021

From what I saw, the workbench generated your IOC correctly. The timer 3 is properly configured.

I will not be able to reproduce your issue as it occurs on your custom hardware.

Are you able to probe the signals at pin level C6, C7, and C8 ?

Cedric

SLori.1
SLori.1Author
Associate
October 1, 2021
Yes the signal arrives correctly to the pins, is correct assume that the hall signals are read correctly since that the variable hall speed is update correctly when I move the rotol manually? Many thanks Il giorno venerdì 1 ottobre 2021, ST Community ha scritto: