• No results found

Chapter 2 Project Information

2.4 Running the Application Example

Project Information

Hardware Configuration

Section 2.1

Hardware Configuration

Overview of the Hardware Configuration

Overview

To run the application example, the following hardware installation was tested:

1 Modicon M262 Logic/Motion Controller 2 PC with EcoStruxure Machine Expert 3 Internet Router

4 EcoStruxure Machine Advisor (cloud server)

For further information about the EcoStruxure Machine Advisor cloud application, refer to https://machine-advisor.schneider-electric.com.

Project Information

Application

Section 2.2

Application

What Is in This Section?

This section contains the following topics:

Topic Page

Overview of the Application 20

Libraries 20

Program Organization Units (POUs) 22

Project Information

Overview of the Application

Overview

The example application implements an HTTP client and an MQTT client. Each of these clients can be used to connect to the registered machine twin in EcoStruxure Machine Advisor. Via this connection the data is sent to the EcoStruxure Machine Advisor. Before the data is sent, it is converted into the specified format using the FB_CreateJsonFormattedString function block from the FileFormatUtility library.

In addition, the example includes a visualization for the configuration, control, and monitoring of the communication.

The following features are supported:

Establishing a connection to the EcoStruxure Machine Advisor either via

Secured MQTT (MQTTS), or

Secured HTTP (HTTPS)

Simulating process and OEE (Overall Equipment Effectiveness) data of the machine

Creation of the JSON formatted string containing the OEE data in the format required by EcoStruxure Machine Advisor

Transmission of the data through the connection to the EcoStruxure Machine Advisor

Provides a DNS client to resolve a given domain name to an IPv4 address.

Dynamic configuration of the controller firewall from the application program during runtime.

Libraries

Overview

The following libraries have been added to the Library Manager of the application:

Library Company Function

FileFormatUtility Schneider Electric Provides utility functions to access text files of certain formats.

HttpHandling Schneider Electric Provides the HTTP client functionality to connect to an HTTP server and to sent data to or to retrieve data from it.

MqttHandling Schneider Electric Provides the MQTT client functionality to exchange data with other devices over the network.

StringUtil System Provides tool functions for processing of variables of data type STRING.

SysMem System Provides components to access the dynamic memory management of the runtime system.

SysSem System Provides access to operating system semaphores for data

Project Information

The libraries MqttHandling, HttpHandling, and FileFormatUtility provide global parameters to configure the supported functions. You can access these parameters in the global parameter list (GPL) available in the Library Manager of the application. These parameters are editable constant variables. In consequence, they must be defined before the application is downloaded to the controller.

The table lists the parameter that has been modified in this application example:

Global Variable List (GVL)

Util System Provides function blocks and functions for the following use cases:

Analog monitors, BCD (binary coded decimal) conversions, bit/byte functions, controller, function manipulators, mathematical functions, and signals.

CAA File CAA Technical

Workgroup Provides function blocks for accessing the system file directory and its files.

Library Company Function

Library Parameter Default value Applied value

MqttHandling GPL.Gc_uiMaxLengthOfClientID 23 255

Global variable list Description

GVL Contains variable declarations for general variables used globally in the application.

GVL_Visu Contains variable declarations for variables linked to the visualization. Variables linked to the visualization are declared exclusively in this list.

Project Information

Program Organization Units (POUs)

SR_DnsClient

The program implements the DNS client functionality.

SR_MachineAdvisorLink

The program implements the program code to control the communication to the EcoStruxure Machine Advisor.

The program code has been split into single logical functions. The single program parts are processed in subroutines, referred to as actions.

The actions called from the program are listed in the following table:

Name of the subroutine (action) Description

ACT_InputMapping In this logic, the input variables, mainly coming from the visualization, are verified and assigned to local variables for further processing.

ACT_StateMachineMqttClient This logic implements the state machine for the operation of the instance of the function block FB_MqttClient and the associated FB_MqttPublish.

The general states are:

Initialization of the function blocks

Establishing the connection to the EcoStruxure Machine Advisor

Monitoring the status of the connection

Publishing of a message

Monitoring the execution of the data transmission

Disconnecting

Error handling

ACT_StateMachineHttpClient This logic implements the state machine for the operation of the instance of the function block FB_HttpClient.

The general states are:

Establishing the connection to the EcoStruxure Machine Advisor

Monitor the status of the connection

Sending the HTTP request

Processing the response from the server

Disconnecting

Error handling

ACT_CreateDataString This logic implements the conversion of the process data into required JSON format to be transmitted to the EcoStruxure Machine Advisor.

ACT_VerifyNexttransmission This logic implements the verification if there is a request for transmission of data is active.

ACT_ResultDataTransmission This logic implements the verification of the result of the data transmission.

Project Information

SR_VisControl

The program SR_VisControl implements additional program code to control the displayed information on the visualization in the Logic Builder within the EcoStruxure Machine Expert software.

SR_SimulatedMachineData

The program SR_SimulatedMachineData implements the simulation of process values which are converted into the JSON formatted string and then transmitted to the EcoStruxure Machine Advisor.

SR_FirewallConfig

The program implements the dynamic configuration of the controller firewall.

After a warmstart of the application, the firewall of the controller is configured as follows:

Protocol Ethernet1 Ethernet2

Modbus Server Rejected Rejected

SNMP Rejected Rejected

Web Server (HTTP) Rejected Rejected

WebVisualization (HTTP) Rejected Rejected

Project Information

Visualization

Section 2.3

Visualization

Visualization Screens

Overview

The application example implements a visualization in the Logic Builder within the EcoStruxure Machine Expert software which can be used to control and monitor the application. Three visualization screens are provided which can be switched from the Visu_Main.

The visualization also exists as web visualization.

With the web visualization, you have access to machine control functions over the network. To prevent unauthorized access to your machine control, perform the following technical and organizational measures for the system on which your application is running.

Project Information

Login Page Visu_Login

WARNING

UNAUTHENTICATED, UNAUTHORIZED ACCESS

Do not expose controllers and controller networks to public networks and the Internet as much as possible.

Use additional security layers, such as VPN, for remote access and install firewall mechanisms.

Restrict access to authorized personnel by activation and deployment of the user management of the controller and the visualization.

Change default passwords at start-up and modify them frequently.

Validate the effectiveness of these measurements regularly and frequently.

Failure to follow these instructions can result in death, serious injury, or equipment damage.

Project Information Machine Advisor HTTPs

Visu_Main → Machine Advisor HTTPs

Project Information Machine Advisor MQTTs

Visu_Main → Machine Advisor MQTTs

Project Information DNS Client

Visu_Main → DNS Client

Project Information

Running the Application Example

Section 2.4

Running the Application Example

What Is in This Section?

This section contains the following topics:

Topic Page

Preconditions for Running the Application Example 30

Creating a User Management for the Visualization 30

Downloading the Application 31

Operating the Application 31

Project Information

Preconditions for Running the Application Example

Overview

To run the application example, the following preconditions must be fulfilled:

User management for EcoStruxure Machine Expert visualization is created.

The application is downloaded and is running on the associated Modicon M262 Logic/Motion Controller.

A PC, laptop, or mobile device with a compatible web browser is connected to the same network as the controller so that the web visualization can be accessed.

An account on the EcoStruxure Machine Advisor exists and a machine is registered and configured for either HTTPs or MQTTs connection.

Creating a User Management for the Visualization

Overview

To create a user management for the visualization, perform these steps:

Step Action Comment

1 Double-click the Visualization Manager node in the

Tools tree.

2 Open the tab User management.

3 Click the Create empty user management or Create user management with default groups and users button to create the user management for the visualization in your application.

4 Configure the users and groups according to your

requirements. NOTE: Some objects in the visualization are

configured to grant access exclusively to users belonging to the default user groups Admin, Service and/or Operator.

Project Information

Downloading the Application

Overview

To set the communication parameter of the controller, and to download the applications, perform these steps:

For more information on downloading an application and the communication settings, refer to the EcoStruxure Machine Expert Programming Guide (see EcoStruxure Machine Expert,

Programming Guide).

Operating the Application

General

The application example implements a web visualization for monitoring and control purposes.

This section provides a brief description of each function. In addition, refer to the visualization screen (see page 24).

Open the Web Visualization

To open the web visualization, enter the following address in the address bar of your web browser:

Step Action Comment

1 Connect your PC to the controller via Ethernet. The controller and the PC must be connected to the same Ethernet network.

2 Open the application example in EcoStruxure Machine

Expert.

3 Double-click the MyController node in the Devices

tree. Result: A network scan is performed. Available

controllers are provided in the Controller selection view of the device editor.

4 Select the target controller from the list. 5 Right-click the controller entry and execute the

command Process communication settings... from the contextual menu.

6 Enter the Communication parameter.

7 Activate the option Save settings permanently and

click the OK button. Result: The communication parameters are

stored on the controller. They are retained if it is restarted. These parameters override the application settings.

8 Execute the Multiple Download... command from the

Online menu.

9 In the Multiple Download dialog box, select the

application, and click the OK button. Result: The application is downloaded to the previously selected controller.

Project Information

https://<IP address of the controller>:8089/webvisu.htm

When you are connecting to the controller web visualization, two login prompts are displayed:

Login to gain general access to the web visualization: Only users with access rights to the runtime object WEB can connect to the web visualization. Refer to the user management of the controller.

Login to the start page (Visu_Login (see page 25)) of the web visualization to get access to the main page. Depending on the rights granted to the user that is logging in, access to objects on the visualization screens can be limited. Refer to the user management of the visualization manager.

Register a New Machine in EcoStruxure Machine Advisor

Before you can send data from your controller to the EcoStruxure Machine Advisor a machine must be registered in your account, to this you can connect to.

Once the machine is registered, navigate to Monitor → Config and configure the connection:

Obtain the IPv4 Address Using the DNS Client

For the connection to the EcoStruxure Machine Advisor, the corresponding client requires the IPv4 address of the EcoStruxure Machine Advisor. The IPv4 address can be obtained by using the

Step Action

1 Activate the radio button M262 as gateway.

2 Select the format Charlie.

3 Use either HTTPs or MQTTs as transport protocol.

Result: The generated configuration is provided. The provided parameter must be transferred into the application as connection parameter of the corresponding client.

Project Information

Establish a Connection to the EcoStruxure Machine Advisor Using the MQTT Client

Before you can establish a connection, you must specify the corresponding parameters.

Enter the IPv4 address of the EcoStruxure Machine Advisor (also refer to the DNS client visualization)

The port number corresponds to the standard MQTTS port and must be set to 8883.

Enter the corresponding parameters Client ID, Username, and Password, which are provided on the EcoStruxure Machine Advisor configuration page.

The TopicName is filled automatically when entering the Client ID, the format is devices/<client id>/messages/events/

To establish the connection, click Connect. The progress and the result of the operation is displayed in the display Status on the visualization screen. After the connection is successfully established, the connection status changes to Connected. The button Connect changes to Disconnect and can be used to close the connection (refer to Considerations for TLS Certificates (see page 34)).

The application example implements an auto reconnect function which can be activated / deactivated at any time.

Establish a Connection to the EcoStruxure Machine Advisor Using the HTTP Client

Before you can establish a connection, you must specify the corresponding parameters.

Enter the IPv4 address of the EcoStruxure Machine Advisor, in case there is an http proxy server between your controller and the Internet, enter the IPv4 address of the proxy server.

The port number corresponds to the standard HTTPS port and must be set to 443.

Enter the corresponding parameters Hostname, Resource, Custom Header 1, and Custom Header 2, which are provided on the EcoStruxure Machine Advisor configuration page.

NOTE: If you have the server URL available for the registered machine twin, you can also enter this into the field Server URL. Doing so, the required fields Hostname and Resource are filled automatically.

To establish the connection, click Connect. The progress and the result of the operation is displayed in the display Status on the visualization screen. After the connection is successfully established, the connection status changes to Connected. The button Connect changes to Disconnect and can be used to close the connection (refer to Considerations for TLS Certificates (see page 34)).

The application example implements an auto reconnect function which can be activated / deactivated at any time.

Project Information

Transmit Data

The application implements four different sample data assets which can be sent to the EcoStruxure Machine Advisor. Therefore, the visualizations for the HTTP client and the MQTT client provided the dedicated displays:

Data OEE - asset 1

Data Motor1 - asset 2

Data Motor2 - asset 3

Test - asset 4

Each of the four data assets can be edited from the visualization by clicking Edit data.

To request the transmission of the data asset, click Transmit. If the button Transmit is green, the request for the transmission is stored it switches back to grey when the transmission request has been processed.

The request is processed when the following preconditions are fulfilled:

The corresponding client is in state Connected.

No other data transmission is in progress.

The result of the data transmission is provided in the associated display. Depending on the used client, the detailed status of the latest data transmission is provided on the corresponding visualization screen.

For the HTTP client, the http status code, the header, and the content of the received server response are provided.

For the MQTT client, the status and the result of the function block FB_MqttPublish are provided.

Considerations for TLS Certificates

The clients in the application are configured that only connections to servers which provide a trusted certificate are accepted. This requires that you must declare the server certificate as trusted on your controller. For more information about certificate management on the controller, refer to How to Manage Certificates on the Controller - User Guide (see How To Manage Certificates on the Controller, User Guide).

EcoStruxure Machine Expert Index EIO0000003867 04/2020

Index

A

application examples, 15

E

examples

Machine Advisor Communication Exam-ple, 9

M

Machine Advisor Communication Example example guide, 9

Related documents