Other Parts Discussed in Thread: INSTASPIN-BLDC
I am using the InstaSPIN BLDC to run a small 12 volt motor. I am using the SPEED_PR_MACRO to calculate the RPM of the motor. From what I can see this just counts the number of electrical rotations within a certain time and calculates the RPM. The speed RPM output from this fucntions seems to be very noisy, so I filter it in order to get an averaged value. The RPM seems to be with 20 RPM most of the time for some motors, but around 1400 RPM on some motors the RPM reported by the software is 1400, but the mechanical RPM of the motor is around 1300. All the motors tested are the same model motor, but I guess slight differences in the inductance from motor to motor can cause different RPM error.
I am just wondering is why there is so much noise on the speedRPM and what can I do to get the speedRPM to match the mechanical RPM? Is there a better way to measure the RPM?
Below is the code which I believe is still the same as the example InstaSpin BLDC from the TI lab.
//while counting up we want positive speed
if((mod_dir1.Counter==5)&&(PreviousState==4)&&(mod_dir1.TrigInput))
{
speed1.TimeStamp = VirtualTimer;
SPEED_PR_MACRO(speed1);
SpeedLoopFlag = TRUE;
}
//while counting down we want negative speed
else if((mod_dir1.Counter==0)&&(PreviousState==1)&&(mod_dir1.TrigInput))
{
speed1.TimeStamp = VirtualTimer;
SPEED_PR_MACRO(speed1);
speed1.Speed = _IQmpy(speed1.Speed,_IQ(-1.0));
SpeedLoopFlag = TRUE;
}