Skip to content

Commit 7453a2d

Browse files
committed
Documentation ready
1 parent d0cc42d commit 7453a2d

File tree

2 files changed

+135
-16
lines changed

2 files changed

+135
-16
lines changed

MCM_ATM90E32.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ double ATM90E32::CalculateVIOffset(unsigned short regh_addr, unsigned short regl
176176

177177
offset = val; // keep lower 16 bits
178178

179-
CommEnergyIC(WRITE, CfgRegAccEn, 0x55AA); // 7F enable register config access
180-
CommEnergyIC(WRITE, offset_reg, offset);
181-
CommEnergyIC(WRITE, CfgRegAccEn, 0x0000); // 7F end configuration
179+
//CommEnergyIC(WRITE, CfgRegAccEn, 0x55AA); // 7F enable register config access
180+
//CommEnergyIC(WRITE, offset_reg, offset);
181+
//CommEnergyIC(WRITE, CfgRegAccEn, 0x0000); // 7F end configuration
182182

183183
Serial.print(", Offset: ");
184184
Serial.println(offset);
@@ -217,9 +217,9 @@ double ATM90E32::CalculatePowerOffset(unsigned short regh_addr, unsigned short r
217217

218218
offset = val; // keep lower 16 bits
219219

220-
CommEnergyIC(WRITE, CfgRegAccEn, 0x55AA); // 7F enable register config access
221-
CommEnergyIC(WRITE, offset_reg, offset);
222-
CommEnergyIC(WRITE, CfgRegAccEn, 0x0000); // 7F end configuration
220+
//CommEnergyIC(WRITE, CfgRegAccEn, 0x55AA); // 7F enable register config access
221+
//CommEnergyIC(WRITE, offset_reg, offset);
222+
//CommEnergyIC(WRITE, CfgRegAccEn, 0x0000); // 7F end configuration
223223

224224
Serial.print(", Offset configured:");
225225
Serial.println(offset);

docs/readme.md

Lines changed: 129 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,132 @@ void setup() {
6666

6767
## Summary
6868

69-
Members | Descriptions
70-
--------------------------------------------|------------------------------------------
71-
| `class` [`ModulinoClass`](#modulinoclass) | The base class for all Modulino components, providing essential functionality and structure for all subsequent Modulino modules. |
72-
| `class` [`ModulinoButtons`](#modulinobuttons) | Handles the functionality of Modulino Buttons, enabling detection of presses and handling input events. |
73-
| `class` [`ModulinoBuzzer`](#modulinobuttons) |Handles the functionality of Modulino Buzzer, enabling the sound generation for feedback or alerts. |
74-
| `class` [`ModulinoPixels`](#modulinopixels) | Handles the functionality of Modulino Pixels, managing LEDs strip color, status and brightness. |
75-
| `class` [`ModulinoKnob`](#modulinoknob) | Handles the functionality of Modulino Knob, interfacing with the rotary knob position. |
76-
| `class` [`ModulinoMovement`](#modulinomovement) | Handles the functionality of Modulino Movement,interfacing with the IMU sensor to get acceleration readings. |
77-
| `class` [`ModulinoThermo`](#modulinothermo) | Handles the functionality of Modulino Thermo, managing temperature sensors to provide real-time temperature and humidity readings. |
78-
| `class` [`ModulinoDistance`](#modulinodistance) | Handles the functionality of Modulino Distance, enabling distance measurement using ToF (Time-of-Flight) sensors for precise range detection. |
69+
| Members | Descriptions |
70+
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
71+
| `class` [`ATM90E32`](#ATM90E32) | The base class for the MCM Energy Monitor, it provides essential functionality and structure for all subsequent methods. |
72+
73+
### Electrical Parameters Methods
74+
75+
- `GetLineVoltageA()`: Returns the RMS voltage value of channel A
76+
- `GetLineVoltageB()`: Returns the RMS voltage value of channel B
77+
- `GetLineVoltageC()`: Returns the RMS voltage value of channel C
78+
79+
- `GetLineCurrentA()`: Returns the RMS current value of channel A
80+
- `GetLineCurrentB()`: Returns the RMS current value of channel B
81+
- `GetLineCurrentC()`: Returns the RMS current value of channel C
82+
- `GetLineCurrentN()`: Returns the RMS current value of Neutral
83+
84+
- `GetActivePowerA()`: Returns the Active Power (W) of channel A
85+
- `GetActivePowerB()`: Returns the Active Power (W) of channel B
86+
- `GetActivePowerC()`: Returns the Active Power (W) of channel C
87+
88+
- `GetTotalActivePower()`: Returns the Active Power (W) of all channels
89+
- `GetTotalActiveFundPower()`: Returns the total active fundamental power
90+
- `GetTotalActiveHarPower()`: Returns the total active harmonical power
91+
92+
- `GetReactivePowerA()`: Returns the Reactive Power (VAR) of channel A
93+
- `GetReactivePowerB()`: Returns the Reactive Power (VAR) of channel B
94+
- `GetReactivePowerC()`: Returns the Reactive Power (VAR) of channel C
95+
- `GetTotalReactivePower()`: Returns the Reactive Power (VAR) of all channels
96+
97+
- `GetApparentPowerA()`: Returns the Apparent Power (VA) of channel A
98+
- `GetApparentPowerB()`: Returns the Apparent Power (VA) of channel B
99+
- `GetApparentPowerC()`: Returns the Apparent Power (VA) of channel C
100+
- `GetTotalApparentPower()`: Returns the Apparent Power (VA) of all channels
101+
102+
- `GetFrequency()`: Returns the grid frequency (Hz)
103+
104+
- `GetPowerFactorA()`: Returns the Power Factor of channel A
105+
- `GetPowerFactorB()`: Returns the Power Factor of channel B
106+
- `GetPowerFactorC()`: Returns the Power Factor of channel C
107+
- `GetTotalPowerFactor()`: Returns the mean Power Factor of all channels
108+
109+
- `GetPhaseA()`: Returns the Phase Angle of channel A
110+
- `GetPhaseB()`: Returns the Phase Angle of channel B
111+
- `GetPhaseC()`: Returns the Phase Angle of channel C
112+
113+
- `GetImportEnergy()`: Returns the active energy imported in (Wh)
114+
- `GetImportReactiveEnergy()`: Returns the reactive energy imported in (VARh)
115+
- `GetImportApparentEnergy()`: Returns the apparent energy imported in (VAh)
116+
- `GetExportEnergy()`: Returns the active energy exported in (Wh)
117+
- `GetExportReactiveEnergy()`: Returns the reactive energy exported in (VARh)
118+
119+
### Calibration Methods
120+
121+
- `CalculateVIOffset(unsigned short regh_addr, unsigned short regl_addr, unsigned short offset_reg)`: Returns the offset of the voltage and current channels to be used within the `setVIOffset()` function.
122+
123+
This function admits several parameters, see the following example as reference:
124+
125+
```arduino
126+
void VIoffsetCal()
127+
{
128+
// Voltage Offset Calibration
129+
mcm.CalculateVIOffset(UrmsA, UrmsALSB, UoffsetA);
130+
mcm.CalculateVIOffset(UrmsB, UrmsBLSB, UoffsetB);
131+
mcm.CalculateVIOffset(UrmsC, UrmsCLSB, UoffsetC);
132+
133+
// Current Offset Calibration
134+
mcm.CalculateVIOffset(IrmsA, IrmsALSB, IoffsetA);
135+
mcm.CalculateVIOffset(IrmsB, IrmsBLSB, IoffsetB);
136+
mcm.CalculateVIOffset(IrmsC, IrmsCLSB, IoffsetC);
137+
}
138+
```
139+
140+
The `VIoffsetCal()` function from above will calculate and return the offset of each input channel of the system. Take notes of the results because will be needed for the next method explained.
141+
142+
**Note:** The offset must be calculated without voltage and current input. No grid voltage and no powered loads connected to the CTs.
143+
144+
- `setVIOffset(unsigned short VoffA, unsigned short VoffB, unsigned short VoffC, unsigned short IoffA, unsigned short IoffB, unsigned short IoffC)`: Configures the offset for each channel to compensate the initial error of the ADC input stages.
145+
146+
This function admits several parameters, see the following example as reference:
147+
148+
```arduino
149+
mcm.setVIOffset(64608, 64608, 64608, 64606, 64608, 64606); // Values obtained with VIoffsetCal()
150+
```
151+
152+
**Note:** Enter the offset values in the same order the `VIoffsetCal()` function prints them.
153+
154+
- `CalculatePowerOffset(unsigned short regh_addr, unsigned short regl_addr, unsigned short offset_reg)`: Returns the offset of the power registers. Optional depending on your setup.
155+
156+
- `CalibrateVI(unsigned short reg, float actualVal)`: Returns the calibration factor of your voltage and current readings using a known voltage and current.
157+
158+
This function admits the register to be calibrated and the voltage or current value measured by a reference tool. See the following example for reference:
159+
160+
- I measured a voltage of **121.54 VAC** with my lab multimeter. (The MCM Split-Phase Energy Monitor only uses channels A and C for voltage).
161+
- I measured a current of **0.4815 Amps** with my lab multimeter. (The MCM Split-Phase Energy Monitor only uses channels A and C for current).
162+
163+
With those known values currently being present in the system input, run the following functions:
164+
165+
```arduino
166+
VCalibration(121.54, 0, 121.54); // Voltage in A, Voltage in B, Voltage in C
167+
168+
...
169+
170+
void VCalibration(float VoltA, float VoltB, float VoltC)
171+
{
172+
// Voltage Offset Calibration
173+
mcm.CalibrateVI(UrmsA, VoltA); // Voltage Channel A, Actual Reference Voltage
174+
mcm.CalibrateVI(UrmsB, VoltB); // Voltage Channel B, Actual Reference Voltage
175+
mcm.CalibrateVI(UrmsC, VoltC); // Voltage Channel C, Actual Reference Voltage
176+
delay(5000);
177+
}
178+
```
179+
180+
```arduino
181+
ICalibration(0.4815, 0, 0.4815); // Current in A, Current in B, Current in C
182+
183+
...
184+
185+
void ICalibration(float CurrA, float CurrB, float CurrC)
186+
{
187+
// Voltage Offset Calibration
188+
mcm.CalibrateVI(IrmsA, CurrA); // Voltage Channel A, Actual Reference Voltage
189+
mcm.CalibrateVI(IrmsB, CurrB); // Voltage Channel B, Actual Reference Voltage
190+
mcm.CalibrateVI(IrmsC, CurrC); // Voltage Channel C, Actual Reference Voltage
191+
delay(1000);
192+
}
193+
```
194+
195+
The functions from above will print in the Serial Monitor the calibration factors of each channel. Write them down and use them to populate the `begin()` function of the ATM90E32 class as explained in the [beginning](#library-initialization).
196+
197+

0 commit comments

Comments
 (0)