Setting up a MachineMetrics Custom IO Adapter Script appears a daunting task at first, however with a bit of knowledge and a few examples you’ll be able to take advantage of this powerful feature that enables MachineMetrics customers to transform machine data.
What is an Adapter Script, and what does it do?
The adapter script allows you to do a few things. You can bring in other data items from a sensor, or transform data items coming off the data stream from the machine.
What are the two different versions of adapter scripts?
V1 Adapter Scripts
There are a few differences between V1 and V2 adapter scripts, Please see the V1 overview here.
A V1 script will only work with a Labjack as it is oriented around pin inputs and how they are turned into an analog or digital signal.
V2 Adapter Scripts
The V2 script applies to Labjack, and also can handle data from protocols such as: ethernet/ip, modbus, OPC-UA, and MTConnect. Changes to a V2 adapter script immediately cascade when any variables are updated. Further, the way the script manages data transformation is also different: there is no longer the concept of device pins (since we’re not limited to just a LabJack), so the concept is called a data-store. A data-store could be a pin, a tag, or a register depending on the communication protocol used. Below we outline the protocol and associated data-store:
pin - labjack
tag - OPC-UA ethernet/IP
registers & coils - modbus (address space)
keys - MTConnect
Major components of a V2 adapter script
The major components of a V2 adapter script are
We’ll start with an OPC-UA adapter script and highlight that there are differences in the components depending on which communication protocol the machine connection uses. We’ll talk about those differences later.
The below examples are meant to give you an idea of the pieces that make up an adapter script rather than a detailed step by step of what you need to do.
To learn more about
address-space tale a look at the Modbus specific article here. Depending on the communication protocol, this might not be a required component.
p1: # speed sensor
# range 1-30000
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
- source: p1
- threshold: 60
- source: p1
- threshold: 39
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.
ACTIVE: not (p1_fast or p1_slow)
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
- code: speed_fast
message: Fast Alert
WARNING: p1 > 60
- code: speed_slow
message: Slow Alert
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.
Visit the V2 Configuration Script, Getting Started Guide to learn more about using this information.