Velocity spikes using HallSensor class

Hi, Kindly can you tell me how you managed to use the generic sensor, I have a similar motor and with an integrated hall sensor, the data is not smooth, and also the motor is not running smoothly.