System Specification

The system level specification of the PLC is specified as a prototxt file of the SystemConfiguration proto message format specified in system_spectification.proto file. In this guide we will use an example of the proto definition given here.

configuration_name: A name given to identify this PLC. In this example it is Pendulum_PLC:

configuration_name: "Pendulum_PLC"

log_level: Logging level. 5 types are supported: LOG_NONE, LOG_NOTICE, LOG_INFO, LOG_ERROR, LOG_VERBOSE.

log_level: LOG_NOTICE

log_file_path: (optional) If specified the logs are stored here.

run_time_secs: (optional) Total time for which the PLC should run. If unspecified, will run forever untill interrupted.

hardware_spec: Description about the PLC’s hardware according to HardwareSpecification message defined in system_spectification.proto. (Full example is not included here for brevity). In this hardware_spec, num_resources specifies the number of CPUs attached to the PLC. Here it is 1. The hardware_spec also includes the mean and standard deviation of execution times of all instructions, system functions and system function blocks. The mean and standard deviation execution times are all specified in nanoseconds:

hardware_spec {
    num_resources: 1
    ram_mem_size_bytes: 10000

    # Instruction mean, std execution times, used only in virtual time mode
    ins_spec {
        ins_name:   "ADD"
        mu_exec_time_ns:    1000
        sigma_exec_time_ns: 100
    }

    ins_spec {
        ins_name:   "AND"
        mu_exec_time_ns:    1000
        sigma_exec_time_ns: 100
    }

    ...

    # SFCs (System functions) - mean, std of execution times
    sfc_spec {
        sfc_name: "ABS"
        mu_exec_time_ns: 2000
        sigma_exec_time_ns: 0
    }

    ...

    # SFBs (System function blocks) - mean, std of execution times
    sfb_spec {
        sfb_name: "TON"
        mu_exec_time_ns: 1500
        sigma_exec_time_ns: 0
    }

    ...
}

datatype_declaration: Multiple datatypes can be declared in the system specification and later used inside PLC programs or function blocks. A datatype can belong to one of the categories belonging to DataTypeCategory enum defined in configuration.proto. Full explanation of the datatype_declaration message will be included in subsequent sections. In this example 4 datatypes are declared.

var_global: Variables which can be used by all programs running on this PLC can be declared in the system specification. All PLC level global variables are declared in the var_global section. Variable declaration is similar to datatype declaration with an optional interface_type and storage_specification. Interface types assign meaning to the way the variable is interpreted by the PLC program. For instance a variable of interface_type VAR_INPUT is equivalent to an INPUT variable defined in IEC 61131-3 specification. A variable declared inside the var_global section can only optionally have VAR_EXPLICIT_STORAGE interface type.

Storage specifications denote where the variable is stored, i.e whether the address of the variable is backed by RAM/IO memory. They can only be present if the interface type is VAR_EXPLICIT_STORAGE, otherwise the variable is allocated statically and does not point to any byte in the PLC’s RAM or IO memory. Further explation of variable interface_types and storage_specifications are described in the IL programming section.

In this example, 4 PLC level global variables are declared:

resource_file_path: Indicates where to find specification this PLC first and only CPU. Since the PLC can have multiple CPUs, this field can be repeated:

resource_file_path: "~/OpenSCADA/examples/inverted_pendulum/CPU_001.prototxt"