- Print
Creating a Counter using Node-RED
Basic example of using Node-RED in Tulip
Before reading this article, please make sure you've followed the instructions in Using Node-RED with Edge MC
Using Node-RED
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.
Counter Overview
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
Initialize Counter
- 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:
- Connect the nodes. Your flow should look like the following:
Increment Counter
Now it's time to increment the counter that we just initialized.
- Insert an Inject node, Count:
Insert a tulip-machine-api node. For information on how to authenticate this node please see this article.
Insert a Change node, Increment Count:
Insert a Debug node:
Connect the nodes like the following:
- 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!