Calibrate and get energy readings from ADE7758 IC from Analog Devices
Fork of ADE7758 by
Currently this library can be used to calibrate and get VRMS, IRMS, active, and apparent energy. I havent worked on reactive energy measurement.
Revision 7:54310bde2e53, committed 2015-04-22
- Comitter:
- bonchenko
- Date:
- Wed Apr 22 10:21:55 2015 +0000
- Parent:
- 6:513b3b5750de
- Commit message:
- Able to read VRMS, IRMS, active and apparent energy
Changed in this revision
ade-example.cpp | Show diff for this revision Revisions of this file |
diff -r 513b3b5750de -r 54310bde2e53 ade-example.cpp --- a/ade-example.cpp Mon Apr 20 08:15:24 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -//#include "mbed.h" -//#include "ade7758.h" -// -//#define AIRMSOFFSET 0xFB1 -//#define BIRMSOFFSET 0xFB0 -//#define CIRMSOFFSET 0xFB1 -//#define AVRMSOFFSET 0xFFB -//#define BVRMSOFFSET 0x2 -//#define CVRMSOFFSET 0xFFF -// -//Serial DBG(PA_9, PA_10); // tx, rx -//ADE7758 ADE(PB_5, PD_2, PB_4, PB_6, PB_7); -// -//void printBytes(long input, uint8_t numBits); -//bool CALIBRATE = true; -// -//float AWattHr, BWattHr, CWattHr, AVAHr, BVAHr, CVAHr; -// -//void ade_main() { -// DBG.baud(115200); -// DBG.format(8,Serial::None,1); -// DBG.printf("Starting...\r\n"); -// -// ADE.begin(); -// -// if (CALIBRATE) { -// DBG.printf("Calibrating...\r\n"); -// ADE.calibrateVI(20); -// DBG.printf("V calibration: %.2f, %.2f, %.2f\r\n", ADE.AVRMSCalib, ADE.BVRMSCalib, ADE.CVRMSCalib); -// DBG.printf("I calibration: %.2f, %.2f, %.2f\r\n", ADE.AIRMSCalib, ADE.BIRMSCalib, ADE.CIRMSCalib); -// ADE.writeRMSOffset(AIRMSOFFSET, BIRMSOFFSET, CIRMSOFFSET, AVRMSOFFSET, BVRMSOFFSET, CVRMSOFFSET); -// ADE.calibrateGain(PHASE_A); -// DBG.printf("Watt gain calibration: %.5f, %.5f, %.5f\r\n", ADE.AWGCalib, ADE.BWGCalib, ADE.CWGCalib); -// DBG.printf("VA gain calibration: %.5f, %.5f, %.5f\r\n", ADE.AVAGCalib, ADE.BVAGCalib, ADE.CVAGCalib); -// DBG.printf("Wh/LSB: %.8f, %.8f, %.8f\r\n", ADE.AWhLSB, ADE.BWhLSB, ADE.CWhLSB); -// DBG.printf("VAh/LSB: %.8f, %.8f, %.8f\r\n", ADE.AVAhLSB, ADE.BVAhLSB, ADE.CVAhLSB); -// } -// -// DBG.printf("Start measurement\r\n"); -// -// while(1) { -// DBG.printf("VRMS for each phase: %.2f, %.2f, %.2f\r\n", ADE.calculateVRMS(PHASE_A), ADE.calculateVRMS(PHASE_B), ADE.calculateVRMS(PHASE_C)); -// DBG.printf("IRMS for each phase: %.2f, %.2f, %.2f\r\n", ADE.calculateIRMS(PHASE_A), ADE.calculateIRMS(PHASE_B), ADE.calculateIRMS(PHASE_C)); -// ADE.getEnergy(PHASE_A, 1, &AWattHr, &BWattHr, &CWattHr, &AVAHr, &BVAHr, &CVAHr); -// DBG.printf("WattHR for each phase: %.2f, %.2f, %.2f\r\n", AWattHr, BWattHr, CWattHr); -// DBG.printf("VAHR for each phase: %.2f, %.2f, %.2f\r\n", AVAHr, BVAHr, CVAHr); -// DBG.printf("\r\n"); -// wait(10); -// } -//} -// -//void printBytes(long input, uint8_t numBits) { -// for (int i = numBits-1; i >= 0; i--) { -// DBG.printf("%d", ((input >> i) & 1)); -// } -//} \ No newline at end of file