I am sampling the Isa, Isb and Isc every fast tick. Then averaging the 4 values every slow tick and calculating the RMS. You can see what I am doing here - I'll share for phase A:
void PriConvManager_UpdateMotorData_FastTick()
{
motorCurrentPhaseA_Array[rms_sample_num] = inputs->feedbackOutput->Isa;
rms_sample_num++;
if(rms_sample_num >= FAST_TICK_TO_SLOW_TICK) // 4 - 4kHz fast thread
{
rms_sample_num = 0;
}
}
void PriConvManager_UpdateMotorData_SlowTick()
{
rms_sample_num = 0; // Reset RMS Sample Number
// Average Motor Currents for Past 4 250us samples
for (int i = 0; i < FAST_TICK_TO_SLOW_TICK; i++)
{
// Divides by 16384 and multiplies by the Full scale of 400A
motorCurrentPhaseA += Util_SQPerUnitToFloat(motorCurrentPhaseA_Array[i], FULL_SCALE_CURRENT);
}
motorCurrentPhaseA /= FAST_TICK_TO_SLOW_TICK;
// How I take the RMS - it is a continuous RMS - not over a specific time period - Tc (time constant) = 1
squareMotorCurrentPhaseA = ((motorCurrentPhaseA*motorCurrentPhaseA - squareMotorCurrentPhaseA)*0.001/motorCurrentTc + squareMotorCurrentPhaseA);
rmsMotorCurrentPhaseA = sqrt(fabs(squareMotorCurrentPhaseA));
}
I take the RMS this way so that I can also filter the currents.
I thought at first I had a problem with the way I was calculating the RMS so I compared it to the KMS RMS. I have compared my RMS to KMS RMS - both line up with each other (except mine is filtered) and both are just as unbalanced. It does not look like it is this RMS function that is causing the imbalance since my RMS seems to match KMS RMS.
See below - My RMS compared to KMS RMS:
Green = KMS RMS Phase C - Cyan = My RMS Phase C (Draws a line through KMS RMS)
Navy = KMS RMS Phase A - Black = My RMS Phase A (Draws a line through KMS RMS)
Red = KMS RMS Phase B - Bright Blue = My RMS Phase B (Draws a line through KMS RMS)
