Measuring RMS current

Hi
I use sinusoidal commutation, I have low side current sensors, and I want to know the RMS current of the motor phases. The way to calculate it is to take the peak current and divide by a square root of 2. The problem is that the current is not pure sinusoidal like in theory, and that there will be some current spikes resulting from PWM that will not reflect the true peak current. Should I take current_q every 300ms (for example) and just divide it by sqrt(2)?
I also thought about averaging the 5 highest current readings every x [ms].

Hey @Geronimo
Yeah I am not sure what is the best way really.
I guess that averaging over several peak readings of multiple cycles would do the trick. You can also use the negative peak values. That will give you a bit more readings.

I dont think so, current_q will not give you the rm. For the RMS you’d hqve to use the phase currents.
Since you have three of them and if we assume that the motor is symmetric, you will have three max and three min peaks of the current for each electric rotation of the motor. So if you’d sample one electrical rotation, that seems good-enough to remove the possible outliers.

Thanks for your answer Anton, How do I know when an electric rotation has started and finished? is there a variable that shows that?

Hey, actually this is a new feature of the v2.1 if I am not mistaking, and you can get read the electrical angle from the variable:

motor.electrical_angle

This variable is set in the motor.loopFOC()