# Procedural function block programming with node red (like PLC FBD)

**URL:** https://discourse.nodered.org/t/procedural-function-block-programming-with-node-red-like-plc-fbd/49329
**Category:** Share Your Projects
**Created:** [4 August 2021 14:59 UTC](https://discourse.nodered.org/t/procedural-function-block-programming-with-node-red-like-plc-fbd/49329 "2021-08-04T14:59:31Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mdkrieg](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mdkrieg/32/39091_2.png) [@mdkrieg](https://discourse.nodered.org/u/mdkrieg)
#### Post date: [4 August 2021 14:59 UTC](https://discourse.nodered.org/t/procedural-function-block-programming-with-node-red-like-plc-fbd/49329/1 "2021-08-04T14:59:31Z")

</div>

When I first discovered Node-RED I was excited because it seemed very similar to [Function Block Diagrams](https://en.wikipedia.org/wiki/Function_block_diagram) that I'd used in PLC programming. They are both visual programming but that's about where the similarities end. It took me a while to grasp the asynchronous nature of Node-RED and similarly why there are never multiple inputs to a node. I thought for a while about creating some nodes that would close these differences but ultimately concluded that it would be better to start from a blank slate.

So, that's what I've done. I used a block-diagramming front-end \<[http://rete.js.org](http://rete.js.org)\> and wrapped it around a back-end that's designed to act like a PLC with a determined scan-rate and scan-order. The package (GitHub link below) consists of a few http files that get stored in your node-red's "httpStatic" folder and a flow that handles the data input / output and resolves the logic that's been defined on the frontend. Ultimately I think this could be a good way to code a raspberry pi / beaglebone microcontroller.

Below screenshot shows example logic simulating a stop light sequence

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/2/6291d369cf388d974b5099162003a84629699c48.png)

And here is the GitHub repo. There's instructions in the readme on how to set this thing up along with a flow that has the sample program embedded (it loads the above example automatically when you first deploy)

> **[GitHub - mdkrieg/f-block-programming](https://github.com/mdkrieg/f-block-programming)**
>
> Contribute to mdkrieg/f-block-programming development by creating an account on GitHub.

This is a work in progress which I likely won't have much time to work on in the near future, so let me know what you think and certainly let me know if you want to contribute.

Regards,  
-Matt
