4/29/2020 5:19 PM | |
Joined: 5/11/2016 Last visit: 6/27/2024 Posts: 16 Rating: (0) |
hello everyone. I'm using librarry FB "LMQTT_Client" for SIMATIC S7-CPU with PLC Sim advanced V2.0, but can't connect to MQTT broker. Block Mqtt client not show code error. Librarry Link: https://support.industry.siemens.com/cs/document/109748872/fb-lmqtt_client-for-simatic-s7-cpu?dti=0&lc=en-MW hope the helping, thank very much. |
4/29/2020 6:42 PM | |
Joined: 7/7/2010 Last visit: 11/14/2024 Posts: 15399 Rating: (2443)
|
3 things I noticed. 1. The done / busy / error outputs are not being monitored (or counted as I call it). At first, you should count these events by adding 1 to a tag when DONE / ERROR are ON (or incrementing a tag). In doing this, you can see how many times they happen since some of them are only for a single scan (meaning you are not likely to see them while online monitoring random scans of the logic). 2. Local Port = 0. Give it a valid port number - at least until you get everything working - rather than having the block to auto-assign one. You can look up online suggested ports for mqtt clients. How about just use 1883 for both inbound and outbound MQTT traffic. If you ever have to packet capture to analyze (using wireshark or similar tool), knowing it is MQTT traffic will help that tool display MQTT data automatically. 3. Not really a problem, but if you look at the MQTTdata.status at the output of the block, it is converted the datatype from word to whatever is defined in the DB MQTTdata for status. The little green "triangle" means it is implicitly performing data conversion. Should still show the status, but having the data types match helps because the PLC does not need to perform an extra task. So, really, #1 is the only thing that's REQUIRED for you to do. The reason I say required is because the block may well be telling you something, but you're assuming those outputs will stay on more than a single scan. You should probably have logic in the next network that handles the done/error outputs. If you need to know the done happened, you better set a tag so it can remember it was done, and compare it against tcpEstablished and mqttEstablished as well. Save the status and statusID anytime the error output is ON. A couple MOVE blocks with NO contacts at the enable inputs to the MOVE blocks should do the trick. Something like "last_MQTT_Client_status" and "last_MQTT_Client_statusID". Just a little post-block-call debug logic (which I nearly always do for Siemens blocks with done/error/status outputs) tells you so much about what happened during commissioning, during service calls, and during upgrades. And #4, make sure the MQTT username & password are eXaCTly as tYPed on the MQTT server.
|
science guy |
|
This contribution was helpful to1 thankful Users |
4/30/2020 6:18 AM | |
Joined: 5/11/2016 Last visit: 6/27/2024 Posts: 16 Rating: (0) |
thank you verry much! It has worked well |
6/28/2020 2:35 AM | |
Posts: 5 Rating: (0) |
Hi, I have the same problem with library and PLCSIM advanced. Could you navigate me, where that change you have made? (TCON_IP_V4_SEC). Tnx |
8/19/2020 8:05 PM | |
Posts: 1 Rating: (0) |
Can you share project for me, thank you |
10/21/2020 11:13 PM | |
Posts: 1 Rating: (1) |
I was able to achieve connectivity using a simulated PLC via PLCSIM Advanced with a local MQTT (mosquitto) broker. It appears that the LMQTT Client library was not designed to be PLCSIM friendly. ND_Hung was correct that the TCON_IP_V4_SEC type does not work on the simulator. I was able to modify the function block to adapt to a simulator. I added an input called "simulator" to the function block. I also added another static type called "statTcpConnParamSIM" with the "TCON_IP_v4" data type. From there, I went around looking for where "statTcpConnParam" was used, and I added conditionals to check if the "simulator" input was enabled, it would use/modify the "statTcpConnParamSIM" instead. I went through the whole function block and basically modified the block so that if the user enabled the new "simulator" input on the block, the block would use "statTcpConnParamSIM" (TCON_IP_v4) type instead of the "statTcpConnParam" (TCON_IP_V4_SEC) to connect. The broker and the PLC need to be under the same subnet. My network is as configured... PLCSIM Virtual Ethernet's IPV4: 192.168.142.130 CPU 1512C-1 PN's IP: 192.168.142.10 Find attached the updated LMQTT Client library that I modified to be compatible with PLCSIM Advanced. It is has gone through very limited testing. I hardcoded "ActiveEstablished" to be true inside the code. My application wouldn't work otherwise (YMMV). To use this updated library, you will need to go under your project tree and to "External source files" and add the file attached, and then right click it to generate the block. AttachmentLMQTT_Client_SIM.zip (654 Downloads) |
This contribution was helpful to4 thankful Users |
9/18/2021 3:19 PM | |
Posts: 3 Rating: (0) |
Bom dia baixei seu bloco reconfigurado, mas ainda não consigo conectar o mqtt e habilitar o bloco, pode me ajudar com isso? |
Follow us on