Part Number: RM48L952
Other Parts Discussed in Thread: MOTORWARE
Hello!
There is an error in arm_sin_cos_f32() function included in math lib.
If you play that code then you may check that error between arm_sin_f32() and arm_sin_cos_f32() is about 9% at iterations 121, 131, 141, 151 and 3591..3600. Problem is with errors in FPU: sometimes instruction i = (uint32_t) (theta - x1); in arm_sin_cos_f32() function lead to invalid index when accessing sine table, because of loss FPU resolution in substraction.
static void showSin()
{
for (float angle_deg = 0.0F; angle_deg < 360.0F; angle_deg+=0.1F) {
const float angle_rad = angle_deg * 2.0F * PI / 360.0F;
float vsin;
float vcos;
float vsin2;
float vcos2;
arm_sin_cos_f32(-(angle_deg - 180.0F), &vsin2, &vcos2); /* invesion of phase due to CMSIS Cortex R DSP Library sin/cos table access method */
vcos2 = -vcos2; /* inversion because of CMSIS Cortex R DSP Library cosine table access method */
vsin = arm_sin_f32(angle_rad);
vcos = arm_cos_f32(angle_rad);
showOneLine(angle_deg, vsin, vcos, vsin2, vcos2);
}
}
What can I do with that?
arm_sin_cos_f32() is much more prefferable for motor control instead of arm_sin_f32() and arm_cos_f32() for perfomance reason.