npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@industrial-shields/librpiplc

v3.0.0

Published

Industrial Shields librpiplc bindings for NodeJS

Downloads

104

Readme

node-librpiplc

by Industrial Shields

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

  • Analog reads and write
  • Digital reads and writes
  • Relay controlling

Licensing

This library is dual-licensed under the EUPL-1.2 (for backwards compatibility) and 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

  1. Go to the directory where you want to install the NPM package.

  2. Assuming you have a full NodeJS environment working, call npm to install the package:

npm install @industrial-shields/librpiplc@<tagname>

Where <tagname> is the version 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 our PLCs regardless of it's version. You can check the available versions in here: https://github.com/Industrial-Shields/node-librpiplc/tags

API

To start using the library, you need to import it with the following statement:

const rpiplc = require("@industrial-shields/librpiplc")("VERSION_NAME", "MODEL_NAME");


// Or, in ESM modules:
import rpiplc from '../lib/addon.js';

const rpiplc = rpiplc("VERSION_NAME", "MODEL_NAME");

Finally, it is a good practice to initialize the pins you want to use as INPUTS or OUTPUTS. You can do so with the rpiplc.pinMode(pin_name, mode) function. For example, if you want to read from the I0.2 input:

rpiplc.pinMode("I0.2", rpiplc.INPUT)

The functions to read and write are the following:

digitalRead(): rpiplc.digitalRead(PIN_NAME) # It returns either rpiplc.HIGH (enabled) or rpiplc.LOW (disabled)

digitalWrite(): rpiplc.digitalWrite(PIN_NAME, VALUE) # Where value is either rpiplc.HIGH (enabled) or rpiplc.LOW (disabled)
# It can be used to control both digital outputs and relays.

analogRead(): rpiplc.analogRead(PIN_NAME) # It returns a 12-bit number that goes from 0 to 4095 (0 to 10V)

analogWrite(): rpiplc.analogWrite(PIN_NAME, VALUE) # Where value is a 12-bit number that goes from 0 to 4095 (0 to 10V)

delay(): rpiplc.delay(MS) # Where MS is the number of milliseconds to block the execution before continuing

References

  1. Available PLC versions
  2. Available PLC models

Available PLC versions

RPIPLC_V3 (deprecated)
RPIPLC_V4
RPIPLC_V6

Available PLC models

RPIPLC_19R
RPIPLC_21
RPIPLC_38AR
RPIPLC_38R
RPIPLC_42
RPIPLC_50RRA
RPIPLC_53ARR
RPIPLC_54ARA
RPIPLC_57AAR
RPIPLC_57R
RPIPLC_58