@industrial-shields/node-red-librpiplc 4.0.2

Industrial Shields librpiplc bindings for Node-RED

npm install @industrial-shields/node-red-librpiplc

node-red-librpiplc

by Industrial Shields

node-red-librpiplc provides a Node-RED wrapper for the librpiplc C library, enabling applications to interface with the GPIOs of Raspberry Pi based Industrial Shields PLCs:

  • Analog reads and write
  • Digital reads and writes
  • Relay controlling
  • Other pins (like DE/RE)

Licensing

This library is licensed under the LGPL-3.0-or-later. The test programs are licensed under the GPL-3.0-or-later.

Prerequisites

One of our PLCs: https://www.industrialshields.com/

Installing librpiplc

You must first install the librpiplc, as this library depends on it.

Installing

To install the stable version use the Node-RED Menu -> Manage palette -> Install option, and search for @industrial-shields/node-red-librpiplc. Or you can also run the following command in your Node-RED user directory, typically ~/.node-red:

npm install @industrial-shields/node-red-librpiplc@<tag-version>

Where <tag-version> is the version number you wish to download. Before this unification, you had to choose between versions 1.X.X (for V3 PLCs) or 2.X.X (for V4 PLCs). As of 3.X.X, this library is compatible with all our Raspberry PLCs regardless of it's version. You can check the available versions in here: https://github.com/Industrial-Shields/node-red-librpiplc/tags

Usage

This library provides one node of configuration and five nodes:

  1. PLC config: Node to select both the version and the model of the PLC to use.
  2. Analog Read: Gets the value of an analog input.
  3. Analog Write: Sets a value of an analog output.
  4. Digital Read: Gets the value of a digital input.
  5. Digital Write: Sets a value of a digital output.
  6. PLC set config: If given a custom configuration, change the PLC version and model being used.

PLC config

Set both the version and model of the PLC in which Node-RED is running. Or, if you want to set the PLC configuration programatically, check Select through "plc set config" node and follow the documentation of the PLC set config node.

WARNING: You should only have ONE configuration node, because they can interfere with each other when configuring the C library.

rpiplc-config

Analog Read

Returns the analog read of a pin as a payload. It also returns a msg.rc attribute to check if the analog read was successful.

If the selected pin is Message passed or if the configuration node is custom, this node will read the msg.pin attribute to determine which pin to read from.

This node (as well as the C library) returns an integer in the range of 16 bits. However, the maximum reading value will depend on the PLC being used. For instance, the analog inputs of all Raspberry PLCs, from V3 to V6, operate up to 12 bits (i.e., 0 to 4095), and TouchBerry Pi analog inputs up to 11 bits (i.e., 0 to 2047).

analog-read

Analog Write

Writes an analog value in the specified pin. It returns a msg.rc attribute to check if the analog read was successful.

If the selected pin is Message passed or if the configuration node is custom, this node will read the msg.pin attribute to determine which pin to read from.

If the Value field is empty, this node will read the msg.payload attribute to determine which value will write to the pin. It must be an integer between 0 and 65535 (16-bit).

This node (as well as the C library) has an accepted range of 16 bits. However, the maximum value must be adjusted depending on the PLC being used. For instance, the analog outputs of all Raspberry PLCs, from V3 to V6, operate up to 12 bits (i.e., 0 to 4095).

analog-write

Digital Read

Returns the digital read of a pin as a payload. It also returns a msg.rc attribute to check if the digital read was successful.

If the selected pin is Message passed or if the configuration node is custom, this node will read the msg.pin attribute to determine which pin to read from.

digital-read

Digital Write

Writes a digital value in the specified pin. It returns a msg.rc attribute to check if the digital write was successful.

If the selected pin is Message passed or if the configuration node is custom, this node will read the msg.pin attribute to determine which pin to read from.

The Value field can take as possible values HIGH, LOW or Message passed. If Message passed, the payload can take the following values:

  • "HIGH" or "LOW" strings.
  • "1" or "0" strings.
  • A boolean (either true or false).
  • A number (either 1 or 0)

digital-write

PLC set configuration

This node allows programmers to change the version and model of the PLC being used while executing the Node-RED flows.

To change these settings, send a message with the attributes msg.version and msg.model. Check the following sections for a list of available versions and models. The node will return a payload containing a number whether the library was initialized successfully with the new configuration (0 if correctly initialized; otherwise, some error occurred).

WARNING: This node needs to be configured with a custom configuration node, that is, checking the Select through "plc set config" node box. Otherwise it will raise an exception every time a message is passed to it.

rpiplc-set-config

Available PLC versions

RPIPLC_V3 (deprecated)
RPIPLC_V4
RPIPLC_V6

UPSAFEPI_V6

GATEBERRY_V9

TOUCHBERRY_PI_V1

Available PLC models

RPIPLC_CPU
RPIPLC_19R
RPIPLC_21
RPIPLC_38AR
RPIPLC_38R
RPIPLC_42
RPIPLC_50RRA
RPIPLC_53ARR
RPIPLC_54ARA
RPIPLC_57AAR
RPIPLC_57R
RPIPLC_58

UPSAFEPI (for UPSafePis)

GATEBERRY (for GateBerries)

TOUCHBERRY_PI (for TouchBerry Pis)

Node Info

Version: 4.0.2
Updated 1 day ago
License: LGPL-3.0-or-later
Rating: not yet rated

Categories

Actions

Rate:

Downloads

133 in the last week

Nodes

  • rpiplc-config
  • rpiplc-set-config
  • rpiplc-analog-read
  • rpiplc-analog-write
  • rpiplc-digital-read
  • rpiplc-digital-write

Keywords

  • node-red
  • node-red-librpiplc
  • industrial
  • Industrial Shields
  • raspberry
  • Raspberry Pi

Maintainers