add more files

master
Andrew Woodlee 2 weeks ago
parent 5451c04eaf
commit bd24ccff2f

@ -1,12 +1,16 @@
// ********* Configuration of ATM90E26 ********* //
// L line calibration gain
// L line calibration gain - check datasheet () and Excel sheet
double lgain = 0x1D39;
// voltage RMS gain
// voltage RMS gain - check datasheet () and Excel sheet
double ugain = 0x6F0B;
// L line current gain
// L line current gain - check datasheet () and Excel sheet
double igainl = 0x7FF4;
// voltage sag threshold
// voltage sag threshold - check datasheet (2.3.2) and Excel sheet
double vsag = 0x0CD5;
// PL_Constant - check datasheet (3.2.2) and Excel sheet
double PLConstH = 0x0007;
double PLConstL = 0x24A1;
// ********************************************* //

@ -140,7 +140,7 @@ unsigned short ATM90E26_UART::GetSysStatus() {
/*
Initialise Energy IC, assume UART has already began in the main code
*/
void ATM90E26_UART::InitEnergyIC(double ugain, double lgain, double igainl, double vSagTh) {
void ATM90E26_UART::InitEnergyIC(double ugain, double lgain, double igainl, double vSagTh, double pl_consth, double pl_constl) {
unsigned short systemstatus;
CommEnergyIC(0, SoftReset, 0x789A); // Perform soft reset
@ -151,8 +151,8 @@ void ATM90E26_UART::InitEnergyIC(double ugain, double lgain, double igainl, doub
// Set metering calibration values
CommEnergyIC(0, CalStart, 0x5678); // Metering calibration startup command.
// Register 21 to 2B need to be set
CommEnergyIC(0, PLconstH, 0x0007); // PL Constant MSB
CommEnergyIC(0, PLconstL, 0x24A1); // PL Constant LSB
CommEnergyIC(0, PLconstH, pl_consth); // PL Constant MSB
CommEnergyIC(0, PLconstL, pl_constl); // PL Constant LSB
CommEnergyIC(0, Lgain, lgain); // Line calibration gain
CommEnergyIC(0, Lphi, 0x0000); // Line calibration angle
CommEnergyIC(0, PStartTh, 0x08BD); // Active Startup Power Threshold

@ -92,7 +92,7 @@ public:
double GetPowerFactor();
double GetImportEnergy();
double GetExportEnergy();
void InitEnergyIC(double ugain, double lgain, double igainl, double vSagTh);
void InitEnergyIC(double ugain, double lgain, double igainl, double vSagTh, double pl_consth, double pl_constl);
unsigned short GetSysStatus();
unsigned short GetMeterStatus();

@ -267,7 +267,7 @@ void setupEnergyMonitor()
// Serial TX pin
ATMSerial.begin(9600, SERIAL_8N1, PIN_SerialATM_RX, PIN_SerialATM_TX);
eic.InitEnergyIC(ugain, lgain, igainl, vsag);
eic.InitEnergyIC(ugain, lgain, igainl, vsag, PLConstH, PLConstL);
delay(1000);
}

Loading…
Cancel
Save