Introduction
Node-RED is a powerful programming tool for the open-source industry and industrial control, and this is why the Industrial Shields® team loves developing all kinds of applications with it.
In this post, we are going to learn how to set analog outputs to our industrial Raspberry Pi PLC controller using Node-RED.
Related Links
Requirements
- Raspberry PL​​​​​​C
- Power Supp​​​​​​ly​​
- Either Ethernet or HDMI cable with an external screen to connect to your Raspberry PLC
- Raspberry PLC Industrial Shields C++ library configuration (Installation 1-7 steps)
Industrial Shields Nodes
Once the nodes are successfully installed, you will be able to see the four nodes in the nodes section.
Analog Write Node
In this post, we will focus on the analog write node, which is an output node for writing the industrial Raspberry PLC analog output pins.
So, drag and drop the node to the flow, double-click and add a new open source PLC Raspberry Pi configuration by clicking on the pen.
Then:
- Select the model of the Raspberry PLC
- Click on Add
- Select an output
- Add a value between 0 and 4095
Optionally, write an inject node with a numeric msg.payload to the analog write node, to inject the msg.payload instead of writing it in the analog output node value field.
Node-RED flow
Now, it is your turn. Get the flow and start playing!
[{"id":"e96f1640.f0f8a8","type":"rpiplc-analog-write","z":"bd29c16a.ab096","rpiplc":"4d45e51a.5424fc","pin":"A0.0","value":"4095","name":"Analog Write node","x":430,"y":100,"wires":[]},{"id":"912ca990.962458","type":"inject","z":"bd29c16a.ab096","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":170,"y":80,"wires":[["e96f1640.f0f8a8"]]},{"id":"d956e346.656b8","type":"inject","z":"bd29c16a.ab096","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4095","payloadType":"num","x":170,"y":120,"wires":[["e96f1640.f0f8a8"]]},{"id":"4d45e51a.5424fc","type":"rpiplc-config","model":"RPIPLC_57R","name":""}]
Node-RED Tutorial: How to set analog outputs to Raspberry PLC