Skip to content

Commit

Permalink
removed power factor bitwise operations
Browse files Browse the repository at this point in the history
  • Loading branch information
CircuitSetup committed Nov 12, 2019
1 parent 748d9f4 commit a01748c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
16 changes: 0 additions & 16 deletions ATM90E32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,34 +320,18 @@ double ATM90E32::GetFrequency() {
// POWER FACTOR
double ATM90E32::GetPowerFactorA() {
signed short pf = (signed short) CommEnergyIC(READ, PFmeanA, 0xFFFF);
//if negative
if (pf & 0x8000 != 0) {
pf = (~pf) + 1;
}
return (double)pf / 1000;
}
double ATM90E32::GetPowerFactorB() {
signed short pf = (signed short) CommEnergyIC(READ, PFmeanB, 0xFFFF);
//if negative
if (pf & 0x8000 != 0) {
pf = (~pf) + 1;
}
return (double)pf / 1000;
}
double ATM90E32::GetPowerFactorC() {
signed short pf = (signed short) CommEnergyIC(READ, PFmeanC, 0xFFFF);
//if negative
if (pf & 0x8000 != 0) {
pf = (~pf) + 1;
}
return (double)pf / 1000;
}
double ATM90E32::GetTotalPowerFactor() {
signed short pf = (signed short) CommEnergyIC(READ, PFmeanT, 0xFFFF);
//if negative
if (pf & 0x8000 != 0) {
pf = (~pf) + 1;
}
return (double)pf / 1000;
}

Expand Down
16 changes: 8 additions & 8 deletions ATM90E32.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ The MIT License (MIT)
#define UrmsA 0xD9 // A RMS Voltage
#define UrmsB 0xDA // B RMS Voltage
#define UrmsC 0xDB // C RMS Voltage
#define IrmsN 0xDC // Calculated N RMS Current
#define IrmsA 0xDD // A RMS Current
#define IrmsB 0xDE // B RMS Current
#define IrmsC 0xDF // C RMS Current
#define IrmsN 0xD8 // Calculated N RMS Current

#define PmeanTFLSB 0xE0 // Lower Word (Tot. Act. Fund. Power)
#define PmeanAFLSB 0xE1 // Lower Word (A Act. Fund. Power)
Expand All @@ -223,14 +223,14 @@ The MIT License (MIT)
#define IrmsBLSB 0xEE // Lower Word (B RMS Current)
#define IrmsCLSB 0xEF // Lower Word (C RMS Current)

/* THD, FREQUENCY, ANGLE & TEMPTEMP REGISTERS*/
#define THDNUA 0xF1 // A Voltage THD+N
#define THDNUB 0xF2 // B Voltage THD+N
#define THDNUC 0xF3 // C Voltage THD+N
/* PEAK, FREQUENCY, ANGLE & TEMP REGISTERS*/
#define UPeakA 0xF1 // A Voltage Peak - THD+N on ATM90E36
#define UPeakB 0xF2 // B Voltage Peak
#define UPeakC 0xF3 // C Voltage Peak
///////////////// 0xF4 // Reserved Register
#define THDNIA 0xF5 // A Current THD+N
#define THDNIB 0xF6 // B Current THD+N
#define THDNIC 0xF7 // C Current THD+N
#define IPeakA 0xF5 // A Current Peak
#define IPeakB 0xF6 // B Current Peak
#define IPeakC 0xF7 // C Current Peak
#define Freq 0xF8 // Frequency
#define PAngleA 0xF9 // A Mean Phase Angle
#define PAngleB 0xFA // B Mean Phase Angle
Expand Down

0 comments on commit a01748c

Please sign in to comment.