Get_CPU_Battery

Overview

The Get_CPU_Battery function block retrieves the current battery status of the PLC CPU. It provides the measured battery voltage, the configured voltage limit threshold, and an alarm indication when the battery voltage drops below the defined limit.

Voltage         =>  (UINT)
Voltage_Limit   =>  (UINT)
Alarm           =>  (BOOL)

Interface

Inputs

This function block has no inputs.

💡 Battery Monitoring

The CPU battery maintains the real-time clock (RTC) when the PLC is powered off. The alarm output indicates when the battery voltage is low and may need replacement to ensure continued RTC operation.

Outputs

NameTypeRange / UnitsDescription
VoltageUINT0 - 3400Measured CPU battery voltage (in mV).
Voltage_LimitUINT0 - 3400Configured minimum battery voltage threshold (in mV).
AlarmBOOLTRUE / FALSETRUE if the battery voltage is below the configured limit, otherwise FALSE.

Example:

PROGRAM PROG_Get_CPU_Battery
    VAR
        CPU_Battery     : Get_CPU_Battery;
        BatteryVoltage  : UINT;
        BatteryLimit    : UINT;
        BatteryAlarm    : BOOL;
    END_VAR

    (* Read CPU battery status *)
    CPU_Battery();

    (* Copy outputs to local variables (optional) *)
    BatteryVoltage := CPU_Battery.Voltage;
    BatteryLimit   := CPU_Battery.Voltage_Limit;
    BatteryAlarm   := CPU_Battery.Alarm;
END_PROGRAM


CONFIGURATION Config0
    RESOURCE Res0 ON PLC
        TASK task1_100ms(INTERVAL := T#100ms, PRIORITY := 1);
        PROGRAM Prog_Instance_GetCPUBattery WITH task1_100ms : PROG_Get_CPU_Battery;
    END_RESOURCE
END_CONFIGURATION