FUNCTION_BLOCK FB_InverterErrors
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
arstReportCollection : ARRAY[0..255] OF ST_ReportCollection; (* Array for error reports *)
bReportCounter : BYTE := 0; (* Counter for report position *)
arstInverterErrors : ARRAY[1..MAX_INVERTER] OF ST_InverterErrors; (* Array for inverter errors *)
arxTriggerInvErr : ARRAY [1..MAX_INVERTER, 1..MAX_INVERTER_ERR] OF R_TRIG; (* Array for error triggers *)
bInverterCount : BYTE; (* Counter for current processed inverter *)
END_VAR
VAR CONSTANT
MAX_INVERTER : BYTE := 10; (* Maximum number of connected inverter *)
MAX_INVERTER_ERR : BYTE := 3; (* Maximum number of errors per inverter *)
END_VAR
FOR bInverterCount := 1 TO MAX_INVERTER DO
arxTriggerInvErr[bInverterCount, 1](CLK := arstInverterErrors[bInverterCount].SCU);
IF arxTriggerInvErr[bInverterCount, 1].Q THEN
arstReportCollection[bReportCounter].sTimestamp := TIME_TO_STRING(TIME());
arstReportCollection[bReportCounter].sInverter := BYTE_TO_STRING(bInverterCount);
arstReportCollection[bReportCounter].sReport := 'error: SCU';
bReportCounter := bReportCounter + 1;
END_IF
arxTriggerInvErr[bInverterCount, 2](CLK := arstInverterErrors[bInverterCount].overcurrent_peak);
IF arxTriggerInvErr[bInverterCount, 2].Q THEN
arstReportCollection[bReportCounter].sTimestamp := TIME_TO_STRING(TIME());
arstReportCollection[bReportCounter].sInverter := BYTE_TO_STRING(bInverterCount);
arstReportCollection[bReportCounter].sReport := 'error: overcurrent peak';
bReportCounter := bReportCounter + 1;
END_IF
arxTriggerInvErr[bInverterCount, 3](CLK := arstInverterErrors[bInverterCount].overcurrent_rms);
IF arxTriggerInvErr[bInverterCount, 3].Q THEN
arstReportCollection[bReportCounter].sTimestamp := TIME_TO_STRING(TIME());
arstReportCollection[bReportCounter].sInverter := BYTE_TO_STRING(bInverterCount);
arstReportCollection[bReportCounter].sReport := 'error: overcurrent rms';
bReportCounter := bReportCounter + 1;
END_IF
END_FOR