In this article, we'll explain the basics of the Labjack V2 adapter script and what makes it different from other integration protocols.
Labjack V2 adapter scripts are quite different from their predecessor. A variables section to define the inputs is all that is needed, as opposed to the prior analog and digital input sections.
Note: See the Configuration Script Overview-V2 for an overall look at the V2 adapter scripts.
Specify Version
The first line within your Labjack Adapter Script should be indicating which version of the Adapter Script you're using. To use a V2 adapter script, enter the following.
version: 2
Note: If there is no version set, version 1 will be assumed.
Data Transform
Next, we're going to want to tell our script where it should look for input data.
On the line after the version, we'll enter "variables:" with no indentation. We can use variables to pass through and transform data.
version: 2
variables:
After that, we'll declare our first variable and call it "execution". This variable should be indented at least once. All the following variables should use the same indentation. The exact amount isn't important, simply that all like items within an adapter script section have a matching indentation.
version: 2
variables:
execution:
Now we'll enter where our "execution" variable gets its value from.
version: 2
variables:
execution:
- source: AIN0
- threshold: 2.5
- state:
- ACTIVE: this
- READY: true
source - determines which sensor our variable will use. In this case, our sensor that is monitoring execution is plugged into AIN0 on our LabJack, so we enter "AIN0" as the source.
threshold - takes the values coming from the source and checks if they are above a given value, or in this case, 2.5. If the value coming off pin-0 is less than 2.5, exec-in will be false. If it is above 2.5, exec-in will be "true".
Now that our execution variable is set, we can move on to adding our part counting variable. It will follow exactly the same formula as our exec-in variable but with a few additional parameters.
version: 2
variables:
execution:
- source: AIN0
- threshold: 2.5
- state:
- ACTIVE: this
- READY: true
parts-in:
- source: AIN1
- threshold: 2.5
- rising-edge
- count
Our parts-in variable has two new parameters, "rising-edge" and "count". To learn more about them, see our variable documentation here.
The result will be that our parts-in variable will store a number that increases by 1 whenever the sensor attached to AIN1 reports a value above 2.5.
Important: Don't forget your indentation! Consistent indentation is crucial for YAML, the format Adapter Scripts are required to be written in.
Next Steps
After this beginning variables section is complete, the standard data-items section will be filled in like any other adapter script. For more information on data-items follow this link.
Visit our V2 Configuration Script Getting Started Guide to see how and where you will put this knowledge to work in the MachineMetrics app.
Have Questions?
Reach out to support@machinemetrics.com for additional help.
Comments
0 comments
Please sign in to leave a comment.