463 changes: 334 additions & 129 deletions emonLibCM.cpp

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion emonLibCM.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@
// and pulse counting incorporated into the library, by Robert Wall
// Release for testing 4/1/2017
//

// Version 3.0.0 20/04/2022 AVR-DB branch
// Version 3.0.1 07/07/2022 SAMP PIN lower level IO
// Version 3.0.2 20/08/2022 6 channel support
// Version 3.0.3 05/10/2022 Fix online configuration
// Version 3.0.4 21/11/2022 Option to return channel mean value
// Version 3.0.5 22/11/2022 Fix for ADCDuration needs to be double
// Version 3.0.6 29/11/2022 Slow down sample rate to DIV32 (39.3 us) improved zero power level
// Version 3.0.7 03/12/2022 Option to fetch analog channel mean
//
// Version 3.0.8 25/04/2023 Skip ISR processing with flag if precise one-wire timing required
// this reduces DS18B20 temperature sensing interference
// on the continuos sampling electricity monitoring
// Update includes more efficient data structure swap
// which also eliminates an ISR over-run
// Version 3.0.9 26/04/2023 Use memset_v rather than memset to get rid of compiler errors (from emonLibDB)

// Version 2.0 21/11/2018
// Version 2.01 3/12/2018 No change.
// Version 2.02 13/07/2019 getLogicalChannel( ), ReCalibrate_VChannel( ), ReCalibrate_IChannel( ) added, setPulsePin( ) interrupt no. was obligatory,
Expand Down Expand Up @@ -77,7 +94,7 @@ typedef uint8_t DeviceAddress[8];
void EmonLibCM_cycles_per_second(unsigned int _cycles_per_second);
void EmonLibCM_min_startup_cycles(unsigned int _min_startup_cycles);
void EmonLibCM_datalog_period(float _datalog_period_in_seconds);
void EmonLibCM_setADC(int _ADCBits, int ADCDuration);
void EmonLibCM_setADC(int _ADCBits, double ADCDuration);
void EmonLibCM_ADCCal(double _RefVoltage);
void EmonLibCM_SetADC_VChannel(byte ADC_Input, double _amplitudeCal);
void EmonLibCM_SetADC_IChannel(byte ADC_Input, double _amplitudeCal, double _phaseCal);
Expand All @@ -104,6 +121,7 @@ int EmonLibCM_getRealPower(int channel);
int EmonLibCM_getApparentPower(int channel);
double EmonLibCM_getPF(int channel);
double EmonLibCM_getIrms(int channel);
double EmonLibCM_getMean(int channel);
double EmonLibCM_getVrms(void);
double EmonLibCM_getAssumedVrms(void);
double EmonLibCM_getDatalog_period(void);
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "EmonLibCM",
"keywords": "electricity, energy, monitoring",
"description": "Energy Monitoring Continuous Sampling Library",
"version": "2.1.0",
"version": "3.0.6",
"repository":
{
"type": "git",
Expand Down
27 changes: 24 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# EmonLibCM
# EmonLibCM (AVR-DB Branch)

The EmonLibCM library is maintained by @Robert.Wall and mirrored here for users of github.
This is an adaptation of Robert Wall's EmonLibCM library to work with the AVR-DB microcontrollers.

See forum release: [EmonLibCM](https://community.openenergymonitor.org/t/emonlibcm-version-2-03/9241/1)
See Robert Wall's original forum release: [EmonLibCM](https://community.openenergymonitor.org/t/emonlibcm-version-2-03/9241/1)

The following release notes are copied from the forum thread. The installation section is modified to reflect git command line installation.

Expand Down Expand Up @@ -48,6 +48,27 @@ Reload Arduino to start using the library.

## Changelog

Version 3.0 includes AVR-DB specific changes:

```
// Version 3.0.0 20/04/2022 AVR-DB branch
// Version 3.0.1 07/07/2022 SAMP PIN lower level IO
// Version 3.0.2 20/08/2022 6 channel support
// Version 3.0.3 05/10/2022 Fix online configuration
// Version 3.0.4 21/11/2022 Option to return channel mean value
// Version 3.0.5 22/11/2022 Fix for ADCDuration needs to be double
// Version 3.0.6 29/11/2022 Slow down sample rate to DIV32 (39.3 us) improved zero power level
// Version 3.0.7 03/12/2022 Option to fetch analog channel mean
//
// Version 3.0.8 25/04/2023 Skip ISR processing with flag if precise one-wire timing required
// this reduces DS18B20 temperature sensing interference
// on the continuos sampling electricity monitoring
// Update includes more efficient data structure swap
// which also eliminates an ISR over-run
// Version 3.0.9 26/04/2023 Use memset_v rather than memset to get rid of compiler errors (from emonLibDB)
```

Version 2.0 corrected some errors generated when converting from the original sketch, and incorporates improved handling of phase/timing compensation and improved removal of the d.c. bias. There are no other major changes from the version that has been tested by @TrystanLea since early 2017.

- Changes for V2.01: Errors in phase error correction.
Expand Down