WAGO PFC200
To install logiccloud Control on your WAGO PFC200 device, you must first deactivate the CODESYS Runtime and install Docker on your PFC200. You can find the instructions here: Install Docker on WAGO PFC200. You can find video instructions from WAGO on YouTube.
Install logiccloud Control
To install logiccloud Runtime on your PFC200, please follow the instructions here: install logiccloud Control.
In addition, an MQTT Broker and the WAGO PFC KBUS API MQTT container must now be installed. First we install the Mosquitto Broker. Our prefabricated container deployed Mosquitto 2.0.11
with allow_annonymous
activated.
# MQTT Broker Mosquitto 2.0.11
docker run -it -p 1883:1883 -d logiccloud/mosquitto:2.0.11
Now we can install the WAGO PFC KBUS API container. To do this, please follow these instructions.
logiccloud Control Runtime
After building your project and creating a runtime, you can add a new connection.
MQTT connection to the inputs and outputs
So that we can access the inputs and outputs, we need to define the corresponding MQTT topics. The values arrive in MQTT with the following example payload:
{
"state": {
"reported": {
"node_id": "PFC200",
"timestamp": 1649356003,
"switch_state": "RUN",
"module_count": 6,
"modules": {
"module1": {
"pn": 36865,
"position": 1,
"type": "DI",
"input_channel_count": 2,
"output_channel_count": 0,
"process_data": {
"inputs": {
"channel1": {
"value": true,
"label": "myFirstLabeledChan"
},
"channel2": {
"value": false,
"label": "m1_input2"
}
}
}
}
}
}
}
}
We now need to create a new MQTT connection. The host is the DEVICE IP
, PORT: 1883
and the Client ID
is, for example, PFC200-Runtime
. We can leave the user name and password empty, as the broker allows login without user data.
We now create a new Payload
and give it a name of our choice. Now the Read
and Write
format must be defined. The syntax here follows the JSON path format and we can copy the example payload above:
Reading inputs
$[state][reported][modules][module1][process_data][inputs][channel1][value]
We can already see that several channels
can be created here, so we would have to create a separate payload for each channel. To do this, we have created placeholders in logiccloud that can be used via the ##tag##
variable. We can therefore define the payload as follows:
$[state][reported][modules][module1][process_data][inputs][##tag##][value]
Writing outputs
To write the outputs, we must define the payload according to the object that is to be sent via MQTT. We can also use placeholders with ##tag##
here.
{
"state": {
"desired": {
"modules": {
"module2": {
"process_data": {
"outputs": {
"##tag##": { //Placeholder ##tag## is replaced by the variable name.
"value": ##v## // Placeholder ##v## is replaced by the corresponding process value.
}
}
}
}
}
}
}
}
You can now assign your process variables to the topics and define the corresponding data types in the Payload Mappings.