Nabend!
Ich zähle erstmal garnix, den Programmcode habe ich nicht selber geschrieben, ist ein fertiger FB der die Daten aus der Klemme ausliest.
so gesehn ist der Wert in der Klemme direkt ( ST ist nicht so meins......
)
was mich halt wundert, einmal setzt es bei 0,8 kWh aus dann bei 1,5 dann 2,7 sollte wenn dann bei Relativ gleichem Wert aussteigen oder sehe is das falsch?
Diese Zeile ist die Zählung bzw. Rechnung also TotalEnergy ist der Zählwert.
TotalEnergy := L1_Data.Energy_Wh + L2_Data.Energy_Wh + L3_Data.Energy_Wh ;
(* Current *)
L1_Data.Current_A := DINT_TO_REAL(L1_Current)*0.000001*CurrentTransformer;
L2_Data.Current_A := DINT_TO_REAL(L2_Current)*0.000001*CurrentTransformer;
L3_Data.Current_A := DINT_TO_REAL(L3_Current)*0.000001*CurrentTransformer;
(* Voltage *)
L1_Data.VoltageLine_V := DINT_TO_REAL(L1_Voltage)*0.0001;
L2_Data.VoltageLine_V := DINT_TO_REAL(L2_Voltage)*0.0001;
L3_Data.VoltageLine_V := DINT_TO_REAL(L3_Voltage)*0.0001;
L1_Data.VoltageFase_V := SQRT(3)*L1_Data.VoltageLine_V;
L2_Data.VoltageFase_V := SQRT(3)*L2_Data.VoltageLine_V;
L3_Data.VoltageFase_V := SQRT(3)*L3_Data.VoltageLine_V;
(* ActivePower *)
L1_Data.ActivePower_W := DINT_TO_REAL(L1_ActivePower)*0.01*CurrentTransformer;
L2_Data.ActivePower_W := DINT_TO_REAL(L2_ActivePower)*0.01*CurrentTransformer;
L3_Data.ActivePower_W := DINT_TO_REAL(L3_ActivePower)*0.01*CurrentTransformer;
CASE State OF
0: (* ApparentPower *)
L1_IndexOut:=State;
L2_IndexOut:=State;
L3_IndexOut:=State;
IF (L1_IndexIn=State) AND (L2_IndexIn=State) AND (L3_IndexIn=State) THEN
L1_Data.ApparentPower_VA := DINT_TO_REAL(L1_VariantValue)*0.01*CurrentTransformer ;
L2_Data.ApparentPower_VA := DINT_TO_REAL(L2_VariantValue)*0.01*CurrentTransformer ;
L3_Data.ApparentPower_VA := DINT_TO_REAL(L3_VariantValue)*0.01*CurrentTransformer ;
State:=State+1;
END_IF
1: (* ReactivePower *)
L1_IndexOut:=State;
L2_IndexOut:=State;
L3_IndexOut:=State;
IF (L1_IndexIn=State) AND (L2_IndexIn=State) AND (L3_IndexIn=State) THEN
L1_Data.ReactivePower_VAR := DINT_TO_REAL(L1_VariantValue)*0.001*CurrentTransformer ;
L2_Data.ReactivePower_VAR := DINT_TO_REAL(L2_VariantValue)*0.001*CurrentTransformer ;
L3_Data.ReactivePower_VAR := DINT_TO_REAL(L3_VariantValue)*0.001*CurrentTransformer ;
State:=State+1;
END_IF
2: (* Energy *)
L1_IndexOut:=State;
L2_IndexOut:=State;
L3_IndexOut:=State;
IF (L1_IndexIn=State) AND (L2_IndexIn=State) AND (L3_IndexIn=State) THEN
L1_Data.Energy_Wh := DINT_TO_REAL(L1_VariantValue)*0.000001*CurrentTransformer ;
L2_Data.Energy_Wh := DINT_TO_REAL(L2_VariantValue)*0.000001*CurrentTransformer ;
L3_Data.Energy_Wh := DINT_TO_REAL(L3_VariantValue)*0.000001*CurrentTransformer ;
State:=State+1;
END_IF
3: (* CosPhi *)
L1_IndexOut:=State;
L2_IndexOut:=State;
L3_IndexOut:=State;
IF (L1_IndexIn=State) AND (L2_IndexIn=State) AND (L3_IndexIn=State) THEN
L1_Data.CosPhi := DINT_TO_REAL(L1_VariantValue)*0.001 ;
L2_Data.CosPhi := DINT_TO_REAL(L2_VariantValue)*0.001 ;
L3_Data.CosPhi := DINT_TO_REAL(L3_VariantValue)*0.001 ;
State:=State+1;
END_IF
4: (* Frequency *)
L1_IndexOut:=State;
L2_IndexOut:=State;
L3_IndexOut:=State;
IF (L1_IndexIn=State) AND (L2_IndexIn=State) AND (L3_IndexIn=State) THEN
L1_Data.Frequency_Hz := DINT_TO_REAL(L1_VariantValue)*0.1 ;
L2_Data.Frequency_Hz := DINT_TO_REAL(L2_VariantValue)*0.1 ;
L3_Data.Frequency_Hz := DINT_TO_REAL(L3_VariantValue)*0.1 ;
State:=State+1;
END_IF
5: (* EnergyNegative *)
L1_IndexOut:=State;
L2_IndexOut:=State;
L3_IndexOut:=State;
IF (L1_IndexIn=State) AND (L2_IndexIn=State) AND (L3_IndexIn=State) THEN
L1_Data.EnergyNegative_Wh := DINT_TO_REAL(L1_VariantValue)*0.001*CurrentTransformer ;
L2_Data.EnergyNegative_Wh := DINT_TO_REAL(L2_VariantValue)*0.001*CurrentTransformer ;
L3_Data.EnergyNegative_Wh := DINT_TO_REAL(L3_VariantValue)*0.001*CurrentTransformer ;
State:=0;
END_IF
END_CASE
(* Power and Energy *)
CurrentActivePower := L1_Data.ActivePower_W + L2_Data.ActivePower_W + L3_Data.ActivePower_W;
TotalEnergy := L1_Data.Energy_Wh + L2_Data.Energy_Wh + L3_Data.Energy_Wh ;
TotalEnergyNegative := L1_Data.EnergyNegative_Wh + L2_Data.EnergyNegative_Wh + L3_Data.EnergyNegative_Wh ;
(*===============*)
(* Reset Energy *)
(*===============*)
Trigger(CLK:= ResetEnergy);
(* Register communication *)
FB_EcCoESdoWrite_EL3403(
sNetId:= F_CreateAmsNetId( EL3403_NetId ),
nSlaveAddr:= EL3403_Port,
nSubIndex:= 16#01,
nIndex:= 16#FB00,
tTimeout:= t#30s);
CASE i OF
0: (* Start sequence *)
IF Trigger.Q THEN
FB_EcCoESdoWrite_EL3403.bExecute := FALSE;
Value := 16#0004;
i := i + 1;
END_IF
1: (* Start sending Value *)
FB_EcCoESdoWrite_EL3403(
pSrcBuf:= ADR(Value),
cbBufLen:= SIZEOF(Value),
bExecute:= TRUE);
i := i + 1;
2: (* Stop sending Value *)
IF FB_EcCoESdoWrite_EL3403.bBusy THEN
FB_EcCoESdoWrite_EL3403.bExecute := FALSE;
i := i + 1;
END_IF
3: (* Ready *)
IF NOT FB_EcCoESdoWrite_EL3403.bBusy THEN
Value := 16#0000;
i := i + 1;
END_IF
4: (* Start sending Value=0 *)
FB_EcCoESdoWrite_EL3403(
pSrcBuf:= ADR(Value),
cbBufLen:= SIZEOF(Value),
bExecute:= TRUE);
i := i + 1;
5: (* Stop sending Value *)
IF FB_EcCoESdoWrite_EL3403.bBusy THEN
FB_EcCoESdoWrite_EL3403.bExecute := FALSE;
i := i + 1;
END_IF
6: (* Ready *)
IF NOT FB_EcCoESdoWrite_EL3403.bBusy THEN
i := 0;
END_IF
END_CASE