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,
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. As the V2 script is a more powerful tool we recommend that all newly added machines use the updated format.
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 address-space
, registers
, variables
, data-items
, and conditions
.
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.
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?
Visit the V2 Configuration Script, Getting Started Guide to learn more about using this information.
Comments
0 comments
Please sign in to leave a comment.