I'm coding a PIC24FJ256GA106 to make a PIPD velocity control for a BLDC motor by using the Hall sensors instead of back-emf. Currently I can control start, stop and direction of rotation of the motor.
When I try to measure the current velocity of the motor I'm facing a problem, because I'm reading the time between position changes of the Hall sensors, which allows me to detect when the motor has moved 60 mechanical grades. Using that, I can calculate the velocity of the motor as if the motor has a constant velocity, but this gives me problems when the motor is accelerating or or slowing down its velocity.
Looking at the internet, I found a couple of papers from ST and Microchip where they describe how specific models of ASIC for BLDC motor control work for calculating the velocity of the motor. The Microchip document explains that they simply calculate the velocity as I explained before, measuring time between position changes and considering the velocity change if it is linear.
The ST document on the following link
explains that they use a monostable circuit which generates a fixed width pulse being triggered by the rising edge of the Hall sensor pulse. This fixed width pulse forms a square signal whose "on time" is the fixed width of pulse generated by the monostable circuit, and the "off time" is the remaining time until the next rising edge of the Hall sensor occurs. This finally makes a square signal of variable duty cycle and from that it is possible to obtain a DC signal with a voltage proportional to the velocity of the motor. From that, I can calculate the velocity of the motor.
On the second method, I don't plan to add a monostable physical circuit to the system that I have, but I can easily add that behavior to my code. The only problem here is that my motor has a nominal velocity of 4000 r.p.m. and when I do the code for the fixed pulse with an appropriate width for this velocity, I think it will be narrow enough to have a very low DC voltage from the square signal when the velocity of the motor is too low. The outcome will be the same problem as if I was using the method of measuring time and calculating the linear velocity, as explained first.
So, is there a method for calculating the velocity using the Hall sensors accurate enough to have good velocity calculations when the motor is accelerating or decelerating, or not?