IO-Link Module
IO-Link is a standardized communication protocol used in industrial automation to connect sensors and actuators to a control system. It provides a point-to-point serial communication protocol that allows the exchange of data between IO-Link-enabled devices and an IO-Link master module. This technology enables devices to transmit not only process data but also diagnostics and parameters, facilitating improved control, configuration, and monitoring of the automation system.
Within the realm of industrial automation, the concept of an edge gateway plays a pivotal role. This gateway serves as a crucial intermediary, facilitating communication between the Edge device and various networked devices. The IO-Link system, integral to this setup, is primarily designed for connecting sensors and actuators—essentially serving as the nervous system of industrial machinery. This technology is not only essential for modern installations but also proves to be a valuable tool for retrofitting older equipment, thereby enhancing their capabilities and extending their operational life.
In a typical IO-Link setup, numerous sensors communicate with an IO-Link master. This master unit acts as a central hub, collecting data and control signals from the connected sensors and actuators. It is, in turn, linked to the local network, usually through a standard Ethernet connection, allowing integration with the Edge device for real-time monitoring and control of industrial processes.
A notable feature of the IO-Link masters is their unique IP addresses, which enable the IO module to efficiently locate and communicate with all the masters present in the network.
Prerequisites
Before deploying the IO-Link module, ensure the following prerequisites are met:
- Connect a physical IO-Link Master to your edge device.
- Update the firmware and ensure all IO-Link devices use version 1.1 of the IO-Link protocol. Use LR Device for updates and checks.
- Configure network settings (IP address, subnet mask, default gateway) using the Ethernet Device Configurator.
IO-Link manifest
Creating a manifest for an IO-Link module and configuring a template for it in Azure IoT Central involves defining the IO-Link module in the manifest, setting up its Docker image and settings, and routing its messages. Then, in IoT Central, a template reflecting the IO-Link module's capabilities is created and linked with the IoT Edge device. Finally, the manifest is applied to start deployment.
Step 1: Create a IO-Link Module Manifest
The manifest is a JSON document that describes which modules to deploy to your IoT Edge device and how to configure them. Here is a sample manifest that deploys an IO-Link module:
{
"$schema-template": "2.0.0",
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"schemaVersion": "1.1",
"runtime": {
"type": "docker",
"settings": {
"minDockerVersion": "v1.25",
"loggingOptions": "",
"registryCredentials": {}
}
},
"systemModules": {
"edgeAgent": {
"type": "docker",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-agent:1.4",
"createOptions": {}
}
},
"edgeHub": {
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:1.4",
"createOptions": {
"HostConfig": {
"PortBindings": {
"5671/tcp": [
{
"HostPort": "5671"
}
],
"8883/tcp": [
{
"HostPort": "8883"
}
],
"443/tcp": [
{
"HostPort": "443"
}
]
}
}
}
}
}
},
"modules": {
"IOLinkModule": {
"version": "1.0.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "facts.azurecr.io/iotedge/iolink:latest-amd64",
"createOptions": {
"Env": [
"IOLinkSettings__HostIpAddress=<your edge device host address>",
"IOLinkSettings__HostMqttPort=<exposed port for MQTT traffic>",
"IOLinkSettings__MasterDevicesIpRange=<IP range for IO-Link masters>"
],
"HostConfig": {
"PortBindings": {
"1883/tcp": [
{
"HostPort": "<exposed port for MQTT traffic>"
}
]
},
"Mounts": [
{
"Target": "/home/moduleuser/io-link/iodd",
"Source": "<edge device folder path for IO-Link definition files>",
"Type": "bind",
"ReadOnly": false
}
]
}
}
}
}
}
}
},
"$edgeHub": {
"properties.desired": {
"schemaVersion": "1.2",
"routes": {
"IOLinkModuleToIoTHub": "FROM /messages/modules/IOLinkModule/outputs/* INTO $upstream"
},
"storeAndForwardConfiguration": {
"timeToLiveSecs": 7200
}
}
}
}
}
-
<your edge device host address>
: This is the specific IP address assigned to your edge device within your network. An edge device is typically a physical device that processes data at the 'edge' of your network, closer to the data source, like sensors.- Example:
192.168.0.100
indicates that your edge device has a static IP address within the private IP range commonly used in LANs.
- Example:
-
<exposed port for MQTT traffic>
: This specifies the network port on the edge device that is dedicated to MQTT (Message Queuing Telemetry Transport) traffic. MQTT is a lightweight messaging protocol used in IoT for device-to-device communication.- Example:
1883
is the standard port for MQTT.
- Example:
-
<IP range for IO-Link masters>
: This parameter defines the range of IP addresses within which all your IO-Link masters are located, using CIDR (Classless Inter-Domain Routing) notation.- Example:
192.168.0.0/24
denotes a range of IP addresses from192.168.0.0
to192.168.0.255
, where all the IO-Link masters in your network are expected to be.
- Example:
-
<edge device folder path for IO-Link definition files>
: This is the path to the folder on your edge device where IO-Link definition files are stored.- Example:
/home/your-user-name/io-link
indicates the directory path in the edge device's file system where the IO-Link definition files reside.
- Example:
This path is crucial for the operation of applications like an IO-Link module in an IoT setup. Correct Permissions are essential for the folder storing the configuration files. Permissions define who can read, write, or execute the files. To set this up:
- Create the directory:
mkdir folder_name
. - Set full access permissions:
sudo chmod 777 folder_name
.
Step 2: Upload the Manifest to Azure IoT Central
Now you can upload this manifest to Azure IoT Central:
- In your Azure IoT Central application, go to Device Templates, and select the appropriate template for your IoT Edge device.
- Go to Edge Manifests.
- Click + New to add a new manifest.
- Enter a name for the manifest, and paste the manifest JSON in the Manifest field.
- Click Create.
Step 3: Deploy the IO-Link Module
Finally, you can deploy your IO-Link module to your IoT Edge device:
- In your Azure IoT Central application, go to Devices, and select your IoT Edge device.
- Go to Configuration.
- In the Configuration Manifests section, select the manifest you created in the previous step.
- Click Save.
An Azure IoT Edge device can host multiple modules, each serving a distinct function or process. It's important to understand that we don't deploy these modules individually; rather, we deploy a complete manifest. This manifest is a comprehensive description of all the modules to be installed, their configurations, and the inter-module communication routes. When the manifest is deployed, all of the outlined modules are deployed and configured together on the IoT Edge device.
Your IoT Edge device will now start deploying the IO-Link module according to the manifest. This might take a few minutes. After the deployment is complete, the ModIO-Linkbus module will start running on your IoT Edge device, and you can start interacting with it through Azure IoT Central.
Testing
Check Messages Sent to IoT Hub/Device Telemetry
-
Open the IoT Hub or device telemetry interface in Azure IoT Central. This can typically be done through the Azure Portal web interface or using the Azure IoT Hub CLI tool.
-
Look for messages sent from the IO-Link module. The module sends decoded data from all IO-Link masters, with each message representing data from a single device. Check for message structure similar to the following example:
{
"body": {
"MessageId": "6208a27b-8f8b-4433-b8aa-26ba12953dc8",
"MessageType": "ua-data",
"PublisherId": "IOLinkModule",
"Messages": {
"DataSetWriterId": "IPAddress: 192.168.0.234, ProductCode: AL1352, SerialNumber: 000223017616",
"MetaDataVersion": {
"MajorVersion": 1,
"MinorVersion": 1
},
"Timestamp": "2023-02-27T08:37:25.8180818Z",
"Status": null,
"Payload": {
"Distance": {
"Value": {
"Type": 9,
"Body": "121"
},
"SourceTimestamp": "2023-02-27T08:37:25.8180818Z"
},
"Switch state [OUT1]": {
"Value": {
"Type": 1,
"Body": false
},
"SourceTimestamp": "2023-02-27T08:37:25.8180818Z"
}
}
}
},
"enqueuedTime": "Mon Feb 27 2023 10:37:20 GMT+0200 (Eastern European Standard Time)",
"properties": {}
}
Manage Device-to-Cloud Messages
- Use the module twin's desired properties to turn d2c messages on or off, or to change the reading rate.
- Review the module twin's reported properties to verify the connected devices.
Establish Two-Way Communication
You can establish a full two-way communication with the IO-Link master by running IoT Core requests, using the direct method
.
- Go to Devices > IoLinkGateway > Modules > Command.
- Set up the command by adding the method name, which should always be
IoTCoreDirectMethod
, the module name and the payload as per the specification required for your setup.