Online tech learner logo
Online Tech Learner
  • Please enable News ticker from the theme option Panel to display Post

S72MQTT, a Coreflux Flux Asset. 1. The Purpose of this Flux Asset | by Hugo Felgueiras | Coreflux Blog

S72MQTT, a Coreflux Flux Asset. 1. The Purpose of this Flux Asset | by Hugo Felgueiras | Coreflux Blog


Coreflux’s S72MQTT allows you to communicate with Siemens S7 devices, by generally or selectively identifying and porting them to an MQTT Broker in JSON format, where they can be further consumed by other systems.

From the newest Tia portal S7–1500 to the oldest S7–300. You can connect your plc via ethernet.

We are able to connect to all devices with ethernet of the families of products S7 300/400/1200/1500/WinAC.

  • There must be an MQTT Broker available (whether Coreflux’s MQTT Broker / Coreflux MQTT WebSockets Broker Flux Asset), to which the values will be written (the respective settings being used in the upcoming configuration of the S7 asset)
  • To install this Flux Asset, open the Coreflux interface, locate the S72MQTT Flux asset (check if you have available slots for the installation of this Flux Asset, this information is displayed on the asset box, in the “used slots / total available slots” format)
S72MQTT flux asset

The Flux Asset box within the Coreflux Hub app (this user has used 5 of a total of 12 owned assets)

  • Click the “Install” button, which will prompt the opening of the configuration overlay
  • Configure the S72MQTT Flux Asset to be installed.

The configuration window on the pre-install phase

  • Start the newly installed S72MQTT Flux Asset
  • After installation, the instance window for this asset installation will display the “Standby” status (to begin execution, press the Play button, and if successful, the instance status will change to “Running”)

Asset installed! Time to run it.

  • If for some reason the inputted configuration fails to execute (or permission to run is not confirmed by the system), the asset will try to enter a run state but return to a halted state when failing to do so, displaying an error popup (on the GUI Hub) or message (on the command-line Hub)

Name identifier attributed to this specific instance of the S72MQTT Flux Asset application (which can either be defined by the user or randomly assigned if null, at the time of the creation of that specific instance)

  • MQTT Broker Server Address (IP Address)

IP element of the address where the gathered and generated values should be written (if you have a local MQTT Broker Flux Asset installed and bound to any address, you can either use your specific network IP or localhost address)

  • MQTT Broker Server Port (TCP port)

Port element of the address where the gathered and generated values should be written (if you have a local MQTT Broker Flux Asset installed, you can either use it, inputting the specific port in which it is running). By default, it’s 1883.

IP element of the address of the target S7 PLC where we want to connect.

These 2 elements must meet the configuration of the running PLC, typically it should be PLC Rack=0 and PLC Slot=1 but you can check this configuration in TiaPortal Devices > Device Configuration > click on CPU > Project Information, Rack 0, Slot 1 in this example.

We can also use the following table as reference:

Rack/Slot reference table

Some examples of S7 CPU’s configurations

S7 400 can have different configurations

Cycle time for refresh variables in ms.

A number of communication retries. If set to Zero it will indefinitely try to connect!

If the communication is lost, here you can define the time between atempts to reconnect.

By default, the client connects as a PG (the programming console), with this function is possible to change the connection resource type to OP or S7 Basic (a generic data transfer connection).

In the hardware configuration (Simatic Manager) of the CPU, under the “Communication” tab, you can change, PLC-side, the connection’s distribution. So in a sense, this represents a protocol resource on the plc side.

Connection Resources

All status messages the service encounters will be published in this topic.

Enable the debug topic.

Since Siemens works with memory positions we need to provide the tags we require has topics. The structure for each tag is has followed:

<S7Address>DB5.DBB680 STRING 10</S7Address>

  • Name — A name used for the tag, just to serve as an identifier. In future with the editor version, they will come in handy to the user.
  • Writable — ToMqtt -> Reads from S7 writes in MQTT | ToS7 -> Reads from S7 writes to MQTT
  • mqttTopicThe topic to publish the value
  • mqttQosAtMostOnce — QOS 0 | AtLeastOnce — QOS 1 | ExactlyOnce — QOS2
  • mqttRetain Publish the value with Retain!
  • valueType — Value type fetching — BOOL |BYTE |INT |WORD |DINT |REAL |STRING
  • S7AddressThe address of the device var. Ex: M0.0 — bit memory for memory. For string, you need to write the number of bytes for the string followed by the keyword STRING ex:DB5.DBB680 STRING 10. In this string starts in DBB680 but the last character is @ DBB692 because the first two bytes are specific for the size and characters being used.
  • behaviour— TriggerOnlyDifferent — Only sends data when the variable is different | TriggerAlways — Publishes always the variable to the MQTT

Due to a series of hacking problems upon release of the Siemens Tia Portal and mainly targetting the models S7–1200 and S7–1500 series, Siemens adopted a solution where the user decides if it will permit access from remote partners to read/write the internal variables of the devices where it’s connecting.

In order for the S72MQTT Flux asset to be able to read/write into the PLC it is necessary to activate the access to PUT/GET communication and this is how to do it.

  • Step 1, connect your Tia Portal project to your target PLC and then go to “Local modules” and select your PLC CPU;
  • Step 2, double click on the device or go to Properties and scroll down and select “Protection & Security”;
  • Step 3, open “Protection & Security” and select “Connection mechanisms”.
  • Step 4, make sure that option “Permit access with PUT/GET communication from remote partner” is selected.
  • Step 5, compile and download your new hardware configuration.

Feel free to download Coreflux’s current version @!


Source link


Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *