Hello together,
I have a problem calculating the electrical efficiency of a device.
In short: I have a gas powergenerator, I am measuring the Gas input in Standart Liters per minute
and the electrical output with a currentmeter.
Both sensors work verifiably fine. And verifiably good data gets returned to the ESP 32 Wrover module.
For calculating efficiency Im using Pin/Pout
Pin would thus be The gas inflow * the calorific value of the gas , in my case 6.83kWh/liter
Pout being The approximately equal voltage of 230Volts * the current flowing to a device.
Since the caloriofic value is in KWh but i need KW i divide the calue by 60. (6830Wh/liter)/60 =113.83W/liter
Thus my equation is Efficiency= (gasflow*113.83)/(230/current)
Sadly from my code my ESP32 Wrover module just straight up crashes everytime it does this calculation.
This is the error which apparently is a Stack overflow, though i dont know where that would happen.
Stack smashing protect failure!
abort() was called at PC 0x400ef580 on core 1
Backtrace: 0x4008d9ec:0x3ffd9880 0x4008dbc7:0x3ffd98a0 0x400ef580:0x3ffd98c0 0x400d6c07:0x3ffd98e0 0x40150964:0x3ffd9920
Im certain it has something to do with the datatypes and some kind of conversion error. But i dont know too much about that.
void setup() {
// put your setup code here, to run once:
double calorific= 113.83; //Heizwert LPG propan 6830Wh/l divided by 60 to only get W
long Currentaverage;
int Voltage= 230;
double eff; //efficiency
}
void loop() {
// put your main code here, to run repeatedly:
getFlowData(SLPM); // Returns the flow in liters between 0-10 Standart Liters per Minute
getCurrentData(Currentaverage);
eff= (SLPM*calorific)/(Voltage*(Currentaverage/1000));
}
quadrolo:
Since the caloriofic value is in KWh but i need KW i divide the calue by 60. (6830Wh/liter)/60 =113.83W/liter
This is wrong. A volume of gas contains an amount of energy which is measured in kWh. It cannot be converted to W/litre - the concept is meaningless. It could be converted to W/litre/second when know the gas flow rate.
Pout being The approximately equal voltage of 230Volts * the current flowing to a device.
This too is wrong, or rather it is only correct for a resistive load. For reactive loads, such as an electric motor, you have to consider power factor. To do that you take the cosign of the phase angle between voltage and current. Multiply the result by the simple apparent power you got from simply multiplying voltage and current.
quadrolo:
The Generator powers a resistive load, A few Pcs /microcontrollers and a battery pack
Do you mean that it power a resistive load (unspecified), a few PCs / microcontrollers and a battery pack or do you mean that all the loads are resistive, specifically a few PCs / microcontrollers and a battery pack?
I would not assume those things are purely resistive although they might be. For testing purposes I would use something that is pure resistance, such as an electric heater.
[EDIT]
Having thought some more those things are not resistive as they typically have switch mode power supples in them. Switch mode power supplies do not present purely resistive loads, although I cannot say they are definitely reactive (inductive / capacitive), they certainly don't present simple resistance, they are non-linear.
quadrolo:
The Gas in my case ist Liquid Propane Gas with 6,83 kWh/Liter.
so 6830Wh/Liter times 3600 to convert into wattsecond/watt is 24.588.000Watt per Liter.
Is that per litre of gas or of liquid? If of gas then you need to know what pressure the gas it at for that to be valid.
The Gas in my case ist Liquid Propane Gas with 6,83 kWh/Liter.
so 6830Wh/Liter
times 3600 to convert into wattsecond/watt is 24.588.000Watt per Liter.
seems kinda high
If you just put the units into the equation you are using is makes it easier to get the unit correct.
KWh/Litre*s/h = KWs/Litre
W=J/s One Joule per second is a Watt
KWs/L = KJ/L
Watts => Power
Joules => Energy
So your value is 24,588,000 J/L or 24.588 MJ/L
Your value of 6.83 KWh/L sounds about right for liquid Propane given Kero is about 10KWh/L.
quadrolo:
times 3600 to convert into wattsecond/watt is 24.588.000Watt per Liter.
The unit of measurement is NOT watts per litre. It might be watts per litre per second or it might be watt-seconds per litre. You need to get your units sorted out if you are ever going to get your maths right.
A watt is a unit of power. A watt-second (which is also known as a Joule) is a unit of energy. Your gas contains energy.