Using Node-RED for IIoT
With the release of an interface board for Raspberry Pi to control the industrial models built with fischertechnik. The review of the board is available at Didacta Advance Pi-F5 interface board.
Sure, the Raspberry Pi runs on Linux and thus could not offer real-time deterministic monitoring or be considered as a PLC. However, Node-RED offers a nice graphic environment to develop the firmware that controls the industrial model. |
The initial flow
The initial flow wasn't very pretty nor easy to read, so I opted for implementing a solution based on finite-state machine.
This method relies on an abstract model that lists a finite number of states —hence the name. Inputs can change the machine from one state to another: such changes are called transitions. A last element is the initial state the machine starts with. I tried two nodes, node-red-contrib-finite-statemachine and node-red-contrib-fsm, later replaced by node-red-contrib-persistent-fsm. . |
Finite-state machine to the rescue
The node-red-contrib-finite-statemachine node requires to enter the states and transitions as a JSON sequence, but displays them with a nice graph.
|
|
So I opted for the node-red-contrib-fsm node where states and transitions are defined in a table.
The node-red-contrib-persistent-fsm node provides a similar table for input of the states and the transitions, displays them with a nice graph. |
Conclusion
Turning the initial flow into a finite-state machine was quick and easy. The major change is the split between the actions linked to a state and the inputs that trigger a transition.
This make the flow easier to read and maintain. |
|
Links
|
Posted: 06 Mar 2020 Updated: 10 Mar 2020, 21 Jun 2022, 29 Oct 2022 |