The inject node is used just to trigger the flow. The function code, start address(sa) and the number of address will vary. The function code is used to create the read command and the code will be similar to the code below: var fc=3 The video below gives a quick overview of the nodes and also read examples using both the modbus getter and modbus flex getter nodes.Īll of the examples use a flow like that shown below: If the data represents a float or 32 bit integer you will need to use the buffer. The node assumes that the register contains a 16 bit integer and if that is the case then you can use the value field to get the data. If you pass the output to a debug node and display the complete msg object you will see that you get an output like the one shown below. The nodes support function codes 1,2,3 and 4 as shown below:īoth nodes have two outputs which are essentially the same. The modbus flex getter expects you to pass the configuration data in from a preceding node and is recommended when you are doing multiple reads of different values. The modbus getter node has all of the configuration done in the node itself, and is used when doing a fixed read. The read mode is configured in the server properties as shown below: These are the modbus getter and modbus flex getter.īoth nodes can be used for reading data using Modbus TCP/IP,TCP RTU and also serial. However in a failed read/write the function node sees the msg from path 2 but none form path1 and so it knows it has failed and triggers another read. The message should also come in from path 2 and this is used to reset the function node. To work it relies on the fact that each message has an ID and we can check this id.Ī normal read/write the function node sees the msg coming first from path1 and so it knows it is ok. The solution I’ve used in my flows is the send the read signal in two paths and check which one gets received. Unfortunately the node doesn’t send any error messages on any outputs so it isn’t easy to detect. Once it has reinitialized you can then read or write normally. This means that a read or write attempt fails and the node reinitializes. When using the getter or write nodes you will notice that if there is long delay between reading or writing (about 2mins) the node appears to go to sleep. See Using the status node for flow control Sleeping NodesĪlthough the status node can be useful it doesn’t detect what I call sleeping nodes. The status is also available to the status node and you can use the status in your flow to ensure successful read and write. You can see that the green active status means that we are connected to the modbus server.Īs you read or write data you will see the status change. The getter and write nodes display the server status under the node as shown below: You can also access this tab from the configuration nodes menu. The important settings are IP address,port, TCP type and unit id. The settings for this server are stored in the server configuration and are available to all nodes in the workspace.įor a TCP/IP server you will need to configure the IP address and the port number. The modus getter and write nodes all require that you configure a server to connect to. The nodes that we are mainly interested in are the read and write nodes. There are 11 nodes in the package and they are grouped together in the Modbus section. Go the the menu and select manage Pallete and search for the node-red-contrib-modbus package. There are a collection of modbus nodes available for node-red which you will need to install.
0 Comments
Leave a Reply. |