
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
//-------------------------------------------------------//
// Project Code : ESS100K3L-01-19
// File Name : RmsAvgCal.cpp
// Created on : 2019. 06. 07.
// Description :
// Author : KimJeongWoo
// Last modified Date :
//-------------------------------------------------------//
#include "CommonLib.h"
float VbatSum = 0.;
float VbatAvg = 0.;
float IbatSum = 0.;
float IbatAvg = 0.;
float VboostSum = 0.;
float VboostAvg = 0.;
float VdabSum = 0.;
float VdabAvg = 0.;
float VdcHSum = 0.;
float VdcHAvg = 0.;
float VdcLSum = 0.;
float VdcLAvg = 0.;
float VdcSum = 0.;
float VdcAvg = 0.;
float VunInvRms = 0.;
float VunInvRmsSum = 0.;
float VnwInvRms = 0.;
float VnwInvRmsSum = 0.;
float VacInvRms = 0.;
float VacInvRmsSum = 0.;
float VunGridRms = 0.;
float VunGridRmsSum = 0.;
float VnwGridRms = 0.;
float VnwGridRmsSum = 0.;
float VacGridRms = 0.;
float VacGridRmsSum = 0.;
float IacInvRms = 0.;
float IacInvRmsSum = 0.;
float IuInvRms = 0.;
float IuInvRmsSum = 0.;
float IwInvRms = 0.;
float IwInvRmsSum = 0.;
float InInvRms = 0.;
float InInvRmsSum = 0.;
float IacGridRms = 0.;
float IacGridRmsSum = 0.;
float IuGridRms = 0.;
float IuGridRmsSum = 0.;
float IwGridRms = 0.;
float IwGridRmsSum = 0.;
float InGridRms = 0.;
float InGridRmsSum = 0.;
float IzctRms = 0.;
float IzctRmsSum = 0.;
float PinvReactive = 0.;
float PinvReactiveSum = 0.;
float PinvReactiveAvg = 0.;
float PinvActive = 0.;
float PinvActiveSum = 0.;
float PinvActiveAvg = 0.;
float PinvApparentAvg = 0;
float Pbat = 0.;
float PbatAvg = 0.;
float PbatSum = 0.;
float IdeSum = 0.;
float IdeAvg = 0.;
float IqeSum = 0.;
float IqeAvg = 0.;
float VdeSum = 0.;
float VdeAvg = 0.;
float VqeSum = 0.;
float VqeAvg = 0.;
float PfAvg = 0.;
void RmsAvgCal()
{
VbatAvg = AVG(&VbatSum, INV_RMS_T500ms);
IbatAvg = AVG(&IbatSum, INV_RMS_T500ms);
VboostAvg = AVG(&VboostSum, INV_RMS_T500ms);
VdabAvg = AVG(&VdabSum, INV_RMS_T500ms);
VdcLAvg = AVG(&VdcLSum, INV_RMS_T500ms);
VdcHAvg = AVG(&VdcHSum, INV_RMS_T500ms);
VdcAvg = AVG(&VdcSum, INV_RMS_T500ms);
VunInvRms = RMS(&VunInvRmsSum, INV_RMS_T500ms);
VnwInvRms = RMS(&VnwInvRmsSum, INV_RMS_T500ms);
VacInvRms = RMS(&VacInvRmsSum, INV_RMS_T500ms);
VunGridRms = RMS(&VunGridRmsSum, INV_RMS_T500ms);
VnwGridRms = RMS(&VnwGridRmsSum, INV_RMS_T500ms);
VacGridRms = RMS(&VacGridRmsSum, INV_RMS_T500ms);
IuInvRms = RMS(&IuInvRmsSum, INV_RMS_T500ms);
IwInvRms = RMS(&IwInvRmsSum, INV_RMS_T500ms);
InInvRms = RMS(&InInvRmsSum, INV_RMS_T500ms);
IacInvRms = RMS(&IacInvRmsSum, INV_RMS_T500ms);
IuGridRms = RMS(&IuGridRmsSum, INV_RMS_T500ms);
IwGridRms = RMS(&IwGridRmsSum, INV_RMS_T500ms);
InGridRms = RMS(&InGridRmsSum, INV_RMS_T500ms);
IacGridRms = RMS(&IacGridRmsSum, INV_RMS_T500ms);
IzctRms = RMS(&IzctRmsSum, INV_RMS_T500ms);
PinvActiveAvg = AVG(&PinvActiveSum, INV_RMS_T500ms);
PinvReactiveAvg = AVG(&PinvReactiveSum, INV_RMS_T500ms);
PinvReactive = AVG(&PinvReactiveSum, INV_RMS_T500ms);
Pbat = AVG(&VbatSum, INV_RMS_T500ms);
}
void RmsAvgSum()
{
// VbatSum += Vbat;
// IbatSum += Ibat;
// VboostSum += Vboost;
// VdabSum += Vdab;
// VdcLSum += VdcL;
// VdcHSum += VdcH;
// VdcSum += Vdc;
//
// VunInvRmsSum += VunInv * VunInv;
// VnwInvRmsSum += VnwInv * VnwInv;
// VacInvRmsSum += VacInv * VacInv;
//
// VunGridRmsSum += VunGrid * VunGrid;
// VnwGridRmsSum += VnwGrid * VnwGrid;
// VacGridRmsSum += VacGrid * VacGrid;
//
// IuInvRmsSum += IuInv * IuInv;
// IwInvRmsSum += IwInv * IwInv;
// InInvRmsSum += InInv * InInv;
// IacInvRmsSum += IacInv * IacInv;
//
// IuGridRmsSum += IuGrid * IuGrid;
// IwGridRmsSum += IwGrid * IwGrid;
// InGridRmsSum += InGrid * InGrid;
// IacGridRmsSum += IacGrid * IacGrid;
//
// IzctRmsSum += Izct * Izct;
//
// PinvActive = -1.5 * (VdsGrid * IdsGrid + VqsGrid * IqsGrid);
// PinvActiveSum += PinvActive;
//
// PinvReactive = -1.5 * (VqsGrid * IdsGrid - VdsGrid * IqsGrid);
// PinvReactiveSum += PinvReactive;
//
// PinvApparentAvg = sqrt(PinvActiveAvg * PinvActiveAvg + PinvReactiveAvg * PinvReactiveAvg);
//
// PfAvg = PinvActiveAvg / PinvApparentAvg;
// Pbat = Vbat * Ibat;
// PbatSum += Pbat;
}
float RMS(float *RMSSum, float InversTime)
{
float Rms_Value = 0;
Rms_Value = sqrt((*RMSSum) * InversTime);
(*RMSSum) = 0;
return Rms_Value;
}
float AVG(float *Sum, float InversTime)
{
float Avg_Value = 0;
Avg_Value = (*Sum) * InversTime;
(*Sum) = 0;
return Avg_Value;
}