Setting up a MachineMetrics Custom Adapter Script may seem challenging at first, but with some knowledge and a few examples, you can harness this powerful feature to transform machine data effectively.
What is an Adapter Script, and What Does It Do?
An adapter script enables you to bring in additional data from sensors or transform data flowing from the machine. This capability allows for greater customization and control over the data your machine produces.
Overview of Adapter Scripts
MachineMetrics adapter scripts are versatile tools that can handle data from various communication protocols, such as Ethernet/IP, Modbus, OPC-UA, and MTConnect. The scripts allow for immediate updates to data transformations when any variables are changed. Instead of being limited to a single device type, like a LabJack, the script manages data through a concept called a "data-store." Depending on the protocol used, a data-store could represent a pin, tag, register, or key.
Here’s how different protocols correspond to data-stores:
- Pin - LabJack
- Tag - OPC-UA, Ethernet/IP
- Registers & Coils - Modbus TCP (address space)
- Keys - MTConnect
Major Components of an Adapter Script
The main components of an adapter script include address-space, registers, variables, data-items, and conditions. Below, we provide an overview of these components with an example adapter script.
Note that the components can vary depending on the communication protocol in use.
Address Space
version: 2
address-space: 3
To learn more about address-space
take a look at the Modbus specific article here. Depending on the communication protocol, this might not be a required component.
Registers
registers:
p1: # speed sensor
# range 1-30000
address: 1002
type: int16
The registers
describe where to obtain the data from the PLC. As with Address Space, some communication protocols don't require this component. See the protocol-specific article for further details
Variables
variables:
p1_fast:
- source: p1
- threshold: 60
p1_slow:
- source: p1
- threshold: 39
- invert
execution:
- source: p1
- ACTIVE: not (p1_fast or p1_slow)
- READY: true
p1_speed:
- source: p1
The variables
section is where data can be transformed by a sequence of operations. See the variables article for the full documentation of what can be done.
Data-Items
data-items:
- execution
- p1_speed
The data-items
are the specific elements that you wish to report in MachineMetrics for this machine. This is because sometimes you want to use a data point in your adapter script, but not output it to your machine. See the data items article for more information
Conditions
conditions:
speed_alarm:
- code: speed_fast
message: Fast Alert
value:
WARNING: p1 > 60
- code: speed_slow
message: Slow Alert
value:
WARNING: 39 > p1
Conditions allow you to set the code
variable and send alerts to the MachineMetrics app via Workflows based off various conditions. A common example would be sending an alert when your feedrate override is above 100. Learn more about conditions here.
What's next?
To dive deeper into setting up and using these scripts, check out the V2 Configuration Script Getting Started Guide. This resource will guide you through the process of using adapter scripts to their full potential.
Comments
0 comments
Please sign in to leave a comment.