Before reading this article, please make sure you've followed the instructions in Using Node-RED with Edge MC
With your Edge MC, Node-RED can be leveraged to build out many different powerful applications. Most notably, you can use Node-RED to convert protocols that Tulip does no currently support natively, allowing you preform further analysis (E.g. MQTT, S7). With Node-RED you can effectively replace the need for third party software, like Kepware, with this open source programming language.
The following article will walk through a basic how to create a basic counter. Here is an overview of what the flow will look like:
The following flow will initialize this Machine Attribute to 0, and increase it's count by 1 every 5 seconds:
First, open your Node-RED Editor through your Edge MC Portal.
Building the Flow
- Add an Inject node, Initialize Count. This node should be blank, and be set to only repeat once.
- Add a Change node: This is where you want to define your count, setting it to 1:
3. Connect the nodes. Your flow should look like the following:
Now it's time to increment the counter that we just initialized.
- Insert an Inject node, Count:
2. Insert a tulip-machine-api node. For information on how to authenticate this node please see this article.
3. Insert a Change node, Increment Count:
4. Insert a Debug node:
5. Connect the nodes like the following:
6. Click Deploy in the top right of your screen to deploy the flow to your Edge MC.
To see you counter in action, navigate back to your Machine in Tulip. You should see the counter has initialized, and has begun incrementing by 1 every 5 seconds:
Here is Node-RED's documentation for further reading.
Have a powerful Node-RED use case? Share your development on Tulip Community!