Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3-Phase Timing and Calculation Problem #76

Open
donemuhendislik opened this issue Nov 16, 2023 · 0 comments
Open

3-Phase Timing and Calculation Problem #76

donemuhendislik opened this issue Nov 16, 2023 · 0 comments

Comments

@donemuhendislik
Copy link

donemuhendislik commented Nov 16, 2023

Hi All,

We try to develop a device, and according to it's working algorithm, we need to calculate L1, L2 and L3 instant voltage and current value (3-Phase energy monitoring.)

For just one line (L1), we can measure everything good. But while we try to use L2 and L3 emon object everything is blocked.

Our summarized code is : (Testing is done with Arduino Mega 2560 and Arduino Giga R1)

`#include "EmonLib.h"

//Device Energy Line 1
EnergyMonitor device_energy_line_1;
//Device Energy Line 2
EnergyMonitor device_energy_line_2;
//Device Energy Line 3
EnergyMonitor device_energy_line_3;

//
/** ENERGY MONITOR CALCULATION PARAMETERS **/
/
/
//Number of half wavelengths (crossings)
#define WAVE_LENGTHS_AMOUNT 20
#define CALCULATION_TIMEOUT 50

//
/** VOLTAGE LINE PARAMETERS **/
/
/
//Define Analog pins
#define VOLTAGE_LINE_1 A0
#define VOLTAGE_LINE_2 A1
#define VOLTAGE_LINE_3 A2

//Voltage calibration value
#define VOLTAGE_CALIBRATION_1 234.26
#define VOLTAGE_CALIBRATION_2 234.26
#define VOLTAGE_CALIBRATION_3 234.26
//Voltage phase shift value
#define VOLTAGE_PHASE_SHIFT 1.7
/*************************************************************/

/*************************************************************/
/** CURRENT PARAMETERS **/
//Define Analog pins
#define CURRENT_LINE_1 A3
#define CURRENT_LINE_2 A4
#define CURRENT_LINE_3 A5

//Phase calibration value : The phase calibration value has 2 different values. We use them because of ACS724's different reading values
#define CURRENT_CALIBRATION_1 26
#define CURRENT_CALIBRATION_2 26
#define CURRENT_CALIBRATION_3 26

void setup() {

//Device energy line 1-2-3 : Voltage
device_energy_line_1.voltage(VOLTAGE_LINE_1, VOLTAGE_CALIBRATION_1, VOLTAGE_PHASE_SHIFT);
device_energy_line_2.voltage(VOLTAGE_LINE_2, VOLTAGE_CALIBRATION_2, VOLTAGE_PHASE_SHIFT);
device_energy_line_3.voltage(VOLTAGE_LINE_3, VOLTAGE_CALIBRATION_3, VOLTAGE_PHASE_SHIFT);

//Device energy line 1-2-3 : Current
device_energy_line_1.current(CURRENT_LINE_1, CURRENT_CALIBRATION_1);
device_energy_line_2.current(CURRENT_LINE_2, CURRENT_CALIBRATION_2);
device_energy_line_3.current(CURRENT_LINE_3, CURRENT_CALIBRATION_3);
}

void loop() {

device_energy_line_1.calcVI(WAVE_LENGTHS_AMOUNT, CALCULATION_TIMEOUT);
//Test Mode : device_energy_line_1.serialprint(); //This is for printing for all data : realpower, apparent power, Vrms, Irms, power factor
device_energy_line_2.calcVI(WAVE_LENGTHS_AMOUNT, CALCULATION_TIMEOUT);
//Test Mode : device_energy_line_2.serialprint(); //This is for printing for all data : realpower, apparent power, Vrms, Irms, power factor
device_energy_line_3.calcVI(WAVE_LENGTHS_AMOUNT, CALCULATION_TIMEOUT);

/*
Rest of our codes, include millis() timing elements like momentary button value read as in 1000ms, LED animations like 100 ms, 75 ms etc. These are blocking because of emon instance's calculations.
*/

}

`

As I wrote in code block, We have some functions have own millis() measurings, button reading state, LED animations. All of them, have own millis() calculations. Without emon instances for 3-phases, all of them work good.

For testing or finding blocking thing, we deleted device_energy_line_2 and 3 instances. Just for device_energy_line_1 for example, it doesnt block anything in code.

Could you have any advices or what we do wrong for 3-phases EnergyMonitor instances ?

Thanks a lot for your help...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant