How to estimate the speed of the motor

Thread Starter

Vihaan@123

Joined Oct 7, 2025
220
I wanted to know from the 1st Hall signal input capture interrupt how do i start estimating the motor speed to predict the next electrical angle. The issue is, i get the first input capture time but i do not have the reference time, so i need to discard it. Is it the correct method? I am implementing FOC using hall sensors.
 

Irving

Joined Jan 30, 2016
4,996
Welcome to AAC

The short answer is - you can't, you have to wait for the second signal. If you have 3 sensors you will have another reading within the first 120deg of rotation. If you know the motor characteristics and load parameters you could estimate the torque for that initial energisation and the rotational acceleration to get a time estimate, but it probably won't be that useful...
 

MaxHeadRoom

Joined Jul 18, 2013
30,562
To find the pole count number, short the three supply terminals and turn the shaft by hand one revolution and count the number of 'bumps.'
 
Last edited:

Thread Starter

Vihaan@123

Joined Oct 7, 2025
220
Welcome to AAC

The short answer is - you can't, you have to wait for the second signal. If you have 3 sensors you will have another reading within the first 120deg of rotation. If you know the motor characteristics and load parameters you could estimate the torque for that initial energisation and the rotational acceleration to get a time estimate, but it probably won't be that useful...
Thank you for the reply, i am stuck with an issue in the logic, when i start the motor under load conditions, i slowly ramp the Iq value and at certain value of Iq the motor starts to turn very slowly, but the problem is that the logic waits for 150ms before the next hall interrupt and then resets the variables. In the reset function calculates the position information based on the 3 hall inputs and turns a little then stops, start and continues this process till the hall signal is less than 150ms (60 deg rotation) and then rotates continuously without problem. The code is basically from ST so i don't understand the way the variables are used and it is little complicated. Can you tell me how do i handle this scenario? How do i estimate the rotor angle with that single pulse and does not allow it to reset.
 

Thread Starter

Vihaan@123

Joined Oct 7, 2025
220
To find the pile count number, short the three supply terminals and turn the shaft by hand one revolution and count the number of 'Bumps'.
Could you please tell me how do i implement using FOC logic, i have seen a similar front end application from ST where they lock the rotor and a timer starts counting down from 1 min and in that time i have to keep turning the shaft with hand and i can really feel the bumps, i wanted to do that but i don't know the logic.
 

drjohsmith

Joined Dec 13, 2021
1,549
Could you please tell me how do i implement using FOC logic, i have seen a similar front end application from ST where they lock the rotor and a timer starts counting down from 1 min and in that time i have to keep turning the shaft with hand and i can really feel the bumps, i wanted to do that but i don't know the logic.
one normaly uses one edge of the purse as reference, and times till the next , or counts number of edges in a fixed period, from which simple maths gives you the speed.
if you very slow , then you could use both edges of the pulse , and the between is proportional to the speed . the width of the pulse is going to be highly dependent on the system, so hard to be general.

im concerned, you say you have pre existing code, for this task ? and its complex/ to hard to use, but you now want to write your own code to do the same...
id ge tempted to say learn how to use the existing code is the best way forward.
 

drjohsmith

Joined Dec 13, 2021
1,549
Thank you for the reply, I am trying to modify the existing code and fix the issue.
Just ask yourself
is code , used by otheres broken ?
does code not work / do what you thought ?
does code work in different way to your expecting ?
are you using code correct ?
we've all assumed the first, but it was one of the other reason in something in our careers
 

MisterBill2

Joined Jan 23, 2018
27,186
Thank you for the reply, i am stuck with an issue in the logic, when i start the motor under load conditions, i slowly ramp the Iq value and at certain value of Iq the motor starts to turn very slowly, but the problem is that the logic waits for 150ms before the next hall interrupt and then resets the variables. In the reset function calculates the position information based on the 3 hall inputs and turns a little then stops, start and continues this process till the hall signal is less than 150ms (60 deg rotation) and then rotates continuously without problem. The code is basically from ST so i don't understand the way the variables are used and it is little complicated. Can you tell me how do i handle this scenario? How do i estimate the rotor angle with that single pulse and does not allow it to reset.
In this case it does not seem that the pole count is the solution at all. So the logical choice is to use an encoder with adequate resolution. If that is not possible, then measuring the time-period of the hall transducer pulse will be an option. If the pulse is a constant angular span, that should work rather well. No need to wait for the second pulse.
 
Last edited:

Thread Starter

Vihaan@123

Joined Oct 7, 2025
220
If the pulse is a constant angular span, that should work rather well. No need to wait for the second pulse.
The problem is only at the start of the motor as it takes time for the motor to start spinning under load and in this case the time gap between the hall sensor edges is greater than 150ms the hall timeout is detected,
 

MisterBill2

Joined Jan 23, 2018
27,186
The problem is only at the start of the motor as it takes time for the motor to start spinning under load and in this case the time gap between the hall sensor edges is greater than 150ms the hall timeout is detected,
OK, then it is back to adding an actual encoder. OR adjusting the hall timeout time setting.
 

MaxHeadRoom

Joined Jul 18, 2013
30,562
Not sure why you need to estimate the pole positions; the sensors should indicate the position. As suggested, adjust the min time between sensors.
This could help.
Are you running the motor in 3ph AC or BLDC mode?

 

MisterBill2

Joined Jan 23, 2018
27,186
REread post #1, MAX! The TS is evidently having a problem getting ready for the second phase drive turn on. How longcan it take for that magnetic field to build up and start delivering force? OR is the estimation of speed required for some other purpose??
 

Thread Starter

Vihaan@123

Joined Oct 7, 2025
220
Thank you all for the support.
Are you running the motor in 3ph AC or BLDC mode?
I am running the motor in 3ph AC
Not sure why you need to estimate the pole positions; the sensors should indicate the position. As suggested, adjust the min time between sensors.
No i am not estimating the pole positions, the sensors are indicating the position. At the start the motor starts very slowly i tried adjusting the hall sensor time out but could not solve the problem. As i requested some help in the other post
Placement Angle | All About Circuits
this is one manual method which i need to perform for each motor and give as input to the configuration file, in case if this is wrong the initial torque may be less and motor may start slower (this is one suspect i have).
OR is the estimation of speed required for some other purpose??
Only for estimating the rotor position.
 

Thread Starter

Vihaan@123

Joined Oct 7, 2025
220
My other question, is it necessary to run the trapezoidal control when the motor is stand still and then switch over to FOC even if i have hall sensor? Some documents say it is not required but some suggest using it, confused on this.
 

JanekSMC

Joined Mar 24, 2023
1
May I suggest a perhaps overlooked and very basic modification?

double the number of magnets on the sensor ring. You can secure them in many ways, with many types of small magnets. Can epoxy them in/on, get smal cylindrical ones that you can drill into the ring and epoxy/goop it in. If you opt for a neodymium one, you could potentially resolve down to a specific 60 degree mark you’re at- stronger magnet will have a larger “spike” in the hall sensor readout.

This would very likely be much easier than playing with code you’re not very familiar with. I hope my suggestion makes sense.
 

Thread Starter

Vihaan@123

Joined Oct 7, 2025
220
May I suggest a perhaps overlooked and very basic modification?

double the number of magnets on the sensor ring. You can secure them in many ways, with many types of small magnets. Can epoxy them in/on, get smal cylindrical ones that you can drill into the ring and epoxy/goop it in. If you opt for a neodymium one, you could potentially resolve down to a specific 60 degree mark you’re at- stronger magnet will have a larger “spike” in the hall sensor readout.

This would very likely be much easier than playing with code you’re not very familiar with. I hope my suggestion makes sense.
But I can't modify the motor it is from supplier.
 

MisterBill2

Joined Jan 23, 2018
27,186
This is a unique application issue. The TS has given us a clue about the problem: The code is basically from ST so i don't understand the way the variables are used !
So it seems that the application is rather unique, and probably some direct communication with the code provider (ST) could help a lot.
As for adding magnets to the motor, THAT would be a very demanding process that would be much more complex than adding an external encoder. AND probably more expensive as well. Certainly the motor being controlled is not small, some level of Integral HP, at least. And it appears that the actual starting is done with either a speed control package or a soft-start package. So it is by no means a simple project.
 
Top