Loading
Remote Control

MicroLink Remote Control, MicroLink MQTT Remote Control

Revision: A (08/08/2023) - Deploy Time: 60 Minutes
Micro800
On This Page:
  • What is this for?
  • Installation guide
Innovation Center Home

MicroLink MQTT is a transformative suite of User-Defined Function Blocks (UDFBs) for Micro800 controllers, enabling seamless MQTT communication with any MQTT broker. This package includes three function blocks: one for establishing connections, one for subscribing to specific topics, and one for publishing data. It offers high customizability with settings for unique MQTT IDs, broker/server IP addresses, usernames, passwords, and your chosen Quality of Service (QoS).

Target to use with PowerFlex 523 and 525 component drives from Rockwell Automation.

This code can be used with the following equipment:

  • PowerFlex 523
  • PowerFlex 525
  • Micro850
  • Micro870
  • PanelView 800d

 

What is this for?

MicroLink MQTT is a UDFBs suite designed for seamless integration with Micro800 controllers from Rockwell Automation. It's meant to enhance the capabilities of these controllers by enabling MQTT communication with any MQTT broker.

This solution is especially useful for remote control use cases and in the industrial field where data exchange and communication efficiency are critical. MicroLink MQTT provides three function blocks for establishing connections, subscribing to specific topics, and publishing data.

With MicroLink MQTT, users can easily establish a connection to an MQTT broker, subscribe to the data they need, and publish data back to the broker. It offers high customization options for MQTT IDs, broker/server IP addresses, usernames, passwords, and your chosen Quality of Service (QoS), ensuring efficient and secure data communication.

Therefore, whether you're an industrial operator looking to optimize data communication or a developer who needs to integrate efficient data exchange in your applications, MicroLink MQTT can be the perfect solution.

General Features

Our package provides three core User-Defined Function Blocks:

  • RA_MQTT_CONNECT_v2: Step into the future with our connection function block. It lets your Micro800 controller establish a connection with an MQTT broker, setting the stage for robust data interchange.
  • RA_MQTT_SUBSCRIBE_v2: Leverage our subscription function block to stay connected with the data you need. Tailor your subscriptions to specific topics from the MQTT broker and always keep your operations data-rich and up-to-date.
  • RA_MQTT_PUBLISH_v2: Take control with our publish function block. Transmit data with precision by publishing topics to the MQTT broker, making your data-driven operations a benchmark for others to follow.

Each function block is highly customizable, allowing you to specify unique MQTT IDs, broker/server IP addresses, usernames, passwords, and your preferred Quality of Service (QoS). With RA_MQTT v2, every aspect of your MQTT communications is in your hands.

Limitations / Disadvantages

  • Limited to Micro820, Micro850 and Micro870
  • Third-party MQTT broker dependent

 

How can I make it work?

The architecture implies using Micro820, Micro850, Micro870 hardware. And this is the required software:

  • Connected Component Workbench, version 21 or higher.
  • The firmware of the equipment used must be compatible with the version of Connected Component Workbench.
  • User-defined Function Blocks:
    • RA_MQTT_CONNECT_v2
    • RA_MQTT_SUBSCRIBE_v2
    • RA_MQTT_PUBLISH_v2

Knowledge

A foundational understanding of ladder programming and system configuration using the Connected Components Workbench software is highly recommended. Additionally, familiarity with MQTT protocols would be beneficial.

Downloads

Please note: You will need to agree to the Terms & Conditions for each download.

MicroLink MQTT files ›
Legal Disclaimer Acceptance. ROCKWELL AUTOMATION WILL PROVIDE ACCESS TO ROCKWELL PRODUCTS (BEST PRACTICES, APPLICATIONS AND KNOWLEDGE) ON THE CONDITION THAT YOU ACCEPT AND COMPLY WITH THE FOLLOWING TERMS AND CONDITIONS. YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS AGREEMENT BY DOWNLOADING, INSTALLING, COPYING, OR OTHERWISE USING PRODUCTS. IF YOU ARE ACCEPTING THESE TERMS ON BEHALF OF ANOTHER PERSON, COMPANY, OR OTHER LEGAL ENTITY, YOU REPRESENT AND WARRANT THAT YOU HAVE FULL AUTHORITY TO BIND THAT PERSON, COMPANY, OR LEGAL ENTITY TO THESE TERMS. IF YOU DO NOT AGREE TO THESE TERMS, DO NOT DOWNLOAD, INSTALL, COPY, ACCESS, OR USE THE PRODUCTS, SOFTWARE AND/OR CLOUD SERVICES. 1. Rockwell Automation retains full ownership and title to all Products and related documentation. No rights or licenses are granted other than those set forth in this Agreement. Company grants to Rockwell Automation a non-exclusive, worldwide, royalty-free, perpetual, non-revocable license to use any feedback Company provides regarding the Products, even if Company has designated the feedback as confidential. Rockwell Automation will be entitled to use the feedback without restriction or compensation to Company. 2. Company may not lease sub-lease, assign, license, sub-license or otherwise transfer any of the Products without the prior written consent of Rockwell Automation. Company may not assign or otherwise transfer access rights to the Products without the prior written consent of Rockwell Automation. Any reverse assembly, reverse engineering, decompilation, and creation of derivative works based on the Products by Company is prohibited. 3. Company acknowledges that Products provided under this Agreement are Rockwell Automation’s Confidential Information and are covered by effective or pending copyrights, patents, trademarks and/or trade secrets of Rockwell Automation, and Company agrees to maintain confidentiality by not disclosing Products or documentation to any third party without the prior written consent of Rockwell Automation and to protect the confidentiality of the Products as it would Company’s own confidential information. Company agrees that its obligation of confidentiality under this paragraph shall survive expiration or termination of this Agreement. 4. Company agrees that Products provided under this Agreement are prototypes and examples and its application and results may vary depending on each customer and project conditions. Rockwell Automation do not warranty the same results. This Agreement shall in no way be construed as a commitment by Rockwell Automation at any time to manufacture and/or offer Products for sale. There is no explicit or implicit service level agreement associated with using the Products. Rockwell Automation does not warrant that the functions contained in the Products will meet Company’s requirements. Company agrees to use all Products only in accordance with the instructions and only for the intended usages identified in the documentation. 5. EXCLUSION OF WARRANTIES AND LIMITATION OF LIABILITY. THE PRODUCTS ARE PROVIDED "AS IS". ROCKWELL AUTOMATION DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. ROCKWELL AUTOMATION EXPLICITLY DISCLAIMS ALL WARRANTIES OF NON- INFRINGEMENT AND EXPRESSLY DOES NOT WARRANT THAT THE PRODUCTS, IN WHOLE OR IN PART, WILL BE ERROR FREE OR FREE FROM SECURITY VULNERABILITIES. IN NO EVENT SHALL ROCKWELL AUTOMATION BE LIABLE FOR (i) LOST PROFITS, LOST SAVINGS, DOWNTIME, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR (ii) ANY PERSONAL INJURY, PROPERTY DAMAGE OR ENVIRONMENTAL DAMAGE ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT, WHETHER IN AN ACTION IN CONTRACT, STRICT LIABILITY OR IN TORT INCLUDING NEGLIGENCE. 6. COMPANY AGREES TO INDEMNIFY AND HOLD ROCKWELL AUTOMATION HARMLESS FROM ALL COSTS, AWARDS, DAMAGES, EXPENSES AND FEES (INCLUDING ATTORNEYS FEES) RESULTING FROM OR RELATED TO ANY THIRD-PARTY CLAIMS (INCLUDING EMPLOYEES AND AGENTS OF COMPANY) AGAINST ROCKWELL AUTOMATION, ITS DISTRIBUTORS, AGENTS, OFFICERS, DIRECTORS OR EMPLOYEES FOR PERSONAL INJURY (INCLUDING DEATH), PROPERTY DAMAGE OR ENVIRONMENTAL DAMAGE RELATED TO OR RESULTING FROM THE USE OF THE PRODUCTS. 7. In the event a Product is exported, Company agrees to comply with all applicable United States Export Control Law and Regulations, and the applicable export control laws of other countries. This Agreement shall be governed by the laws of the state of Wisconsin. This Agreement is the complete and exclusive Agreement between Rockwell Automation and the Company, and supersedes all prior agreements, whether written or oral, relating to the Products.

Need Help?

If you need help with an application or have feedback from the Innovation Center, please contact us.

Installation Guide 

Workflow step by step icon

Step 1:

Establishing Connection Settings to Connect to or Disconnect from a MQTT Broker

An MQTT broker essentially serves as a server to manage MQTT messages. To connect to an MQTT broker, we must input the broker's IP address and port number into the RA_MQTT_CONNECT_v2 UDFB. The broker could be housed on your computer (in which case you would need to install and operate an MQTT broker compatible with your OS), or it could be a remote server, such as the ones previously mentioned.

1.1 Assign the IP address and port number of the MQTT broker to your RA_MQTT_CONNECT_v2 UDFB

This example is for connecting to the test.mosquitto.org broker in the cloud.  An alternative to entering the IP address directly is to enable Domain Name Service (set ‘EnableDNS’ TRUE) after entering in the MQTT broker URL into ‘MQTTBrokerName’ and the local DNS server IP address into ‘DNSIPaddr’ in rung 2.

1.2 Enter a unique ‘clientName’, as well as a ‘userID’ and ‘userPass’ if your MQTT broker requires it. (Many public MQTT brokers do not require a username and password, so these fields are optional and can be left blank if not required.)

1.3 Set ‘EnableMQTT’ to TRUE to connect to the MQTT broker.

Note:

There are a few things to keep in mind to ensure a successful connection. The MQTTsocketSts should eventually display a 9. If it shows a 7 and then reverts back to 0, it could imply that your broker is either not running or doesn't exist.

The data in resultData_Out is helpful for diagnostic troubleshooting. Typically, when you send a connect command to the server, the server responds with an acknowledgement. The acknowledgement is indicated by the 1st byte, which in this instance, is '32'.

Another frequent response you'll receive is a ping acknowledgement, denoted by '208' in the 1st byte of the returned data. The ping command is sent to the remote broker at 50-second intervals. This interval is hardcoded in the UDFB but can be modified if needed.

If the return data is something other than 32 or 208 upon connection, it could suggest that the client has subscribed to a topic that was broadcasted while it was offline. The message is retained and sent to the client when it comes back online. If you encounter this, process the message and then reinitialize the connection.

1.4 If you want to configure for LWT, you need to access these parameters in the UDFB:

322| willTopic := willTopic_In;
323| willData := willData_In;

‘willTopic_In’ is where you enter the Last Will topic for the connection.

‘willData_In’ is where you enter the testament for the connection.

The MQTT broker will publish the testament to all clients that subscribe to the Last Will topic when the client is disconnected abruptly.

1.5 If you want to disconnect gracefully from the server (without triggering LWT), set ‘disconnect_Cmd’ to TRUE.

This is a rising edge triggered bit, so you can reset it immediately.

  • Step 1 - screenshot

    Step 1 - Image 1

  • Step 1 - screenshot

    Step 1 - Image 2

  • Step 1 - screenshot

    Step 1 - Image 3

  • Step 1 - screenshot

    Step 1 - Image 4

Step 1 - screenshot
Step 1 - screenshot
Step 1 - screenshot
Step 1 - screenshot
Workflow step by step icon

Step 2

Subscribing to or Unsubscribing from a Topic

The MQTT protocol exchanges data through subscribe and publish methods. Clients communicate directly only with the MQTT broker. Clients subscribing to a topic will receive a message from the broker when another client publishes to that topic. Clients can be of any form as long as they have a running MQTT client application. For example, it could be software on a PC, a connector or API for the software, an app on a phone, or application code on a PLC.

2.1. Enter the name of the topic (‘topicName_input’) to subscribe to or unsubscribe from.

2.2. Set the quality of service (‘subQoS’) for the subscription. By default, use ‘0’ as it consumes the least bandwidth.

2.3. Set ‘subscribe’ or ‘unsubscribe’ to TRUE to subscribe to or unsubscribe from the topic.

2.4. These bits detect for rising edge, so you can reset them immediately.

2.5 Notice that the resultData_Out from RA_MQTT_CONNECT_v2 is also copied to respondData_In.

Note:

It is recommended to use only 1 instance of each UDFB.

Step 2 - screenshot
Step 2 - screenshot
Workflow step by step icon

Step 3:

Publishing a Topic

When a topic with data is published to an MQTT broker, the broker then forwards this topic data to all the clients subscribed to it. The client that publishes the message does not know if any remote nodes receive the topic, as that responsibility lies with the broker, depending on the QoS level. Topics can be published or subscribed to at any QoS level, but they will only be delivered at the lowest QoS level.

3.1. Enter the topic to publish into ‘pubTopic_In’.

3.2. Enter the data for the topic into ‘pubData_In’.

3.3. Set the quality of service into ‘pubQoS’. By default, use ‘0’ as it consumes the least bandwidth.

3.4. Set ‘publish’ to TRUE to publish the topic with its data. It will automatically will be set back to FALSE when ‘publishDN’ becomes TRUE.

3.5. Notice that the resultData_Out from RA_MQTT_CONNECT_v2 is also copied to respondData_In.

Step 3 - screenshot
Step 3 - screenshot
Workflow step by step icon

Step 4

Getting Messages from Subscribe Topics

The MQTT broker handles all topic subscriptions. It sends the data of any published topic to the clients that are subscribed to it. When a topic is received by the Micro800 MQTT client, it populates the 'TopicName' and 'TopicData' array variables in the RA_MQTT_CONNECT_v2 UDFB. The data is stored in a First In/First Out order, so it is crucial to process the data before it gets overwritten.

Step 4 - screenshot
Step 4 - screenshot
Workflow step by step icon

Step 5

Subscribing to an Array of Topics

MQTT_Subscriptions is an optional Structured Text program that works in conjunction with the MQTT_Client program. It enables you to subscribe to a 'Subscriptions' array of preconfigured topics. Adjust the array dimension of the global variable 'Subscriptions' to the desired size and modify the initial value of the local variable 'maxSubscriptions' to match the array size (default=10). 'Subscriptions' is a User-Defined Data Type (UDT) array that comprises the MQTT topic 'Name', the latest topic 'Data', a timestamp based on the RTC value when the latest topic 'Data' was received, and a 'Subscribed' indicator. Enter the desired topic names to subscribe to as initial values for Subscriptions[i].Name before downloading the project to the controller.

Local variable 'enableSubcriptions' must be TRUE in order to enable this functionality.

  • Step 5 - screenshot

    Step 5 - Image 1

  • Step 5 - screenshot

    Step 5 - Image 2

Step 5 - screenshot
Step 5 - screenshot
Workflow step by step icon

Step 6

Automatically Publishing an Array of Topics

MQTT_Publications is an optional Structured Text program that works in conjunction with the MQTT_Client program. It allows you to publish an entire 'Publications' array of preconfigured topics. Adjust the array dimension of the global variable 'Publications' to the desired size and modify the initial value of the local variable 'maxPublications' to match the size of the array (default=10). 'Publications' is a User-Defined Data Type (UDT) array that comprises the MQTT topic 'Name', the latest topic 'Value', the previous topic value 'Valueprev', and a timestamp based on the RTC value when the latest topic 'Value' was published. Enter the desired topic names to publish as initial values for Publications[i].Name before downloading the project to the controller.

Set the local variable 'ChangeOfState' to TRUE to publish any value that changes on an exception basis. Set the local variable 'Interval' to TRUE and 'intervalTime' to a non-zero value to publish all of the current values that aren't null ('') on a timed interval basis. Typically, one would choose either 'ChangeOfState' or 'Interval' as the method for publishing topic updates. For a one-time update, set the local variable 'OnDemand' to TRUE to publish all current values that aren't null (''). 'OnDemand' is set to FALSE once the entire 'Publications' array has been published. The local variable 'enablePublications' must be set to TRUE to enable this program functionality.

  • Step 6 - screenshot

    Step 6 - Image 1

  • Step 6 - screenshot

    Step 6 - Image 2

Step 6 - screenshot
Step 6 - screenshot
Have a general inquiry?

Rockwell Automation and our partners offer exceptional industry knowledge to help design, implement, and support your automation investment.

Contact Rockwell Automation
  • Sales
  • Customer Care
  • TechConnect Support
  • General Questions
  1. Chevron LeftChevron Left Rockwell Automation Home Chevron RightChevron Right
  2. Chevron LeftChevron Left Sup... Chevron RightChevron Right
  3. Chevron LeftChevron Left Pro... Chevron RightChevron Right
  4. Chevron LeftChevron Left Downloads Chevron RightChevron Right
  5. Chevron LeftChevron Left Innovation Center Chevron RightChevron Right
  6. Chevron LeftChevron Left MicroLink Remote Control, MicroLink MQTT Remote Control Chevron RightChevron Right