Skip to content

MQTT Client inside an IEC 61131-3 program

For a project we need an MQTT client as a function block inside an IEC 61131-3 program, which is able to write a defined number of process data from the program to an MQTT broker outside of the PLCnext or to read it from there. This should also be possible with the PLC cycle time of 50 ... 100 ms. The previously available MQTT client in the PLCnext shop is unfortunately not suitable for this.

A few years ago we developed a FB for PCWORX that can establish a fast MQTT over Websocket connection to a broker directly from the PLC program. But this solution uses libraries from OSCAT (BASE64_ENCODE_STR, HEX_to_DWORD, SHA1_STR etc.) and isn't working in PLCnext because OSCAT libraries are not yet available for the PLCnext.

Is it likely that equivalent libraries will also be available for the PLCnext in the near future?

Reinhard
Competence Center Automation Duesseldorf

Comments

  • Hi Reinhard,

    before coming to your question I'd like to ask if you've already tried the MQTT Client Library 3?
    We recommend to use this Client in a 500ms idle to prevent task watchdogs, you might be able to go lower.

    Keep in mind that the design of the Library is based on an asynchron running paho MQTT client. So you do not need n task cycles to publish a message...

    However, you can create your own client, but there is currently no port of the OSCAT library available.
    Oscat is moreover an open source project and not activly maintained from Phoenix Contact, so it might me sense to ask the developers at OSCAT if and when a port maybe planned.

    But, we've very powerful alternatlivese for your requested alternatives.
    You can call via the PLCnext Base native bash commands on the Linux OS.
    So whatever works on the bash of the PLC can be used than in your 61131 application.

    Please find attached some screenshots which demonstrates how you easily convert base64 or create a sha256 hash.

    Especially in combination with MQTT might also our json library be helpfull...

    Take care,
    Frank
Sign In or Register to comment.