Skip to main content

Welcome to the SM16inpind Documentation!

SM16inpind is a Python package that enables you to control the Sixteen LV Digital Inputs for Raspberry Pi.

This documentation provides detailed instructions on installation, usage, and troubleshooting.

If you experience any issues, please refer to the Troubleshooting section.

Note: On older systems, the pip command may default to Python 2.7, which is no longer supported. In these cases, use pip3 instead.

If you are working in an externally managed environment, we recommend creating a virtual environment to manage dependencies:

python3 -m venv .venv
source .venv/bin/activate

Installation

Install the SM16inpind package using one of the following commands:

sudo pip install SM16inpind

or

sudo pip3 install SM16inpind

Updating an Existing Installation

To update SM16inpind to the latest version, run:

sudo pip install SM16inpind -U

or

sudo pip3 install SM16inpind -U

Quick Start Example

Start using SM16inpind by launching a Python interpreter:

$ python
Python 3.11.8 (main, Feb 12 2024, 14:50:05) [GCC 13.2.1 20230801] on Linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lib16inpind
>>> lib16inpind.getLed(0, 1)
>>>

Full Documentation

For a comprehensive guide to the package’s functionality, please refer to the contents below:

readCh(stack, channel)

Read the value of a specific input channel on the 16-input industrial Raspberry Pi expansion card.

This function reads the state of a single input channel from the specified stack level of the expansion card. The inputs are optically isolated and pulled-up to 24V. A return value of 1 indicates the input is active (connected to ground), while 0 indicates inactive (floating or connected to 24V).

  • Parameters:
    • stack (int) – Stack level of the card (0-7). Each card in the stack must have a unique address set via the jumpers.
    • channel (int) – Input channel number to read (1-16).
  • Returns: The state of the input channel: : - 1: Input is active (connected to ground)
    • 0: Input is inactive (floating or connected to 24V)
  • Return type: int
  • Raises:
    • ValueError – If stack level is not 0-7 or channel is not 1-16
    • Exception – If communication with the I2C bus fails

Example

>>> # Read input channel 5 on card at stack level 0
>>> import lib16inpind
>>> value = lib16inpind.readCh(0, 5)
>>> print(f"Channel 5 state: {'Active' if value else 'Inactive'}")

readAll(stack)

Read all input pins on the device.

  • Parameters: stack (int) – Stack level (0-7) of the card to read from
  • Returns: 16-bit value representing the state of all inputs (1 = active, 0 = inactive)
  • Return type: int
  • Raises:
    • ValueError – If stack level is invalid
    • Exception – If communication with device fails

Example

inputs = lib16inpind.readAll(0) # Read all inputs from card at stack level 0

getLed(stack: int, channel: int)

Get the state of an LED channel

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – LED channel number (1-16)
  • Returns: LED state (0=OFF, 1=ON)
  • Return type: int
  • Raises: ValueError – If invalid stack or channel

setLed(stack: int, channel: int, state: int)

Set the state of an LED channel

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – LED channel number (1-16)
    • state – LED state (0=OFF, 1=ON)
  • Raises: ValueError – If invalid stack, channel or state

getLedMode(stack: int, channel: int)

Get the mode of an LED channel

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – LED channel number (1-16)
  • Returns: LED mode (0=OFF, 1=ON, 2=BLINK)
  • Return type: int
  • Raises: ValueError – If invalid stack or channel

setLedMode(stack: int, channel: int, mode: int)

Set the mode of an LED channel

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – LED channel number (1-16)
    • mode – LED mode (0=OFF, 1=ON, 2=BLINK)
  • Raises: ValueError – If invalid stack, channel or mode

getPowerLedMode(stack: int)

Get the power LED mode

  • Parameters: stack – Board stack level (0-7)
  • Returns: Power LED mode (0=OFF, 1=ON, 2=BLINK)
  • Return type: int
  • Raises: ValueError – If invalid stack

setPowerLedMode(stack: int, mode: int)

Set the power LED mode

  • Parameters:
    • stack – Board stack level (0-7)
    • mode – LED mode (0=OFF, 1=ON, 2=BLINK)
  • Raises: ValueError – If invalid stack or mode

wdtReload(stack: int)

Reload watchdog timer

  • Parameters: stack – Board stack level (0-7)
  • Raises: ValueError – If invalid stack

getWdtPeriod(stack: int)

Get watchdog period in seconds

  • Parameters: stack – Board stack level (0-7)
  • Returns: Watchdog period in seconds
  • Return type: int
  • Raises: ValueError – If invalid stack

setWdtPeriod(stack: int, period: int)

Set watchdog period in seconds

  • Parameters:
    • stack – Board stack level (0-7)
    • period – Watchdog period in seconds (0-65535)
  • Raises: ValueError – If invalid stack or period

getWdtInitPeriod(stack: int)

Get watchdog initial period in seconds

  • Parameters: stack – Board stack level (0-7)
  • Returns: Watchdog initial period in seconds
  • Return type: int
  • Raises: ValueError – If invalid stack

setWdtInitPeriod(stack: int, period: int)

Set watchdog initial period in seconds

  • Parameters:
    • stack – Board stack level (0-7)
    • period – Initial period in seconds (0-65535)
  • Raises: ValueError – If invalid stack or period

getWdtOffPeriod(stack: int)

Get watchdog off period in seconds

  • Parameters: stack – Board stack level (0-7)
  • Returns: Watchdog off period in seconds
  • Return type: int
  • Raises: ValueError – If invalid stack

setWdtOffPeriod(stack: int, period: int)

Set watchdog off period in seconds

  • Parameters:
    • stack – Board stack level (0-7)
    • period – Off period in seconds (0-65535)
  • Raises: ValueError – If invalid stack or period

getWdtResetCount(stack: int)

Get watchdog reset counter value

  • Parameters: stack – Board stack level (0-7)
  • Returns: Number of watchdog resets
  • Return type: int
  • Raises: ValueError – If invalid stack

getOpto(stack: int, channel: int)

Get the state of an opto-isolated input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
  • Returns: Input state (0=OFF, 1=ON)
  • Return type: int
  • Raises: ValueError – If invalid stack or channel

getOptoAll(stack: int)

Get all opto-isolated input states

  • Parameters: stack – Board stack level (0-7)
  • Returns: 16-bit value with input states
  • Return type: int
  • Raises: ValueError – If invalid stack

getOptoEdge(stack: int, channel: int, edge: int)

Get edge detection state for an opto-isolated input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
    • edge – Edge type (0=falling, 1=rising)
  • Returns: Edge detection state (0=disabled, 1=enabled)
  • Return type: int
  • Raises: ValueError – If invalid stack, channel or edge

setOptoEdge(stack: int, channel: int, edge: int, state: int)

Set edge detection for an opto-isolated input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
    • edge – Edge type (0=falling, 1=rising)
    • state – Detection state (0=disabled, 1=enabled)
  • Raises: ValueError – If invalid stack, channel, edge or state

getOptoCount(stack: int, channel: int)

Get the counter value for an opto-isolated input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
  • Returns: Counter value (0-65535)
  • Return type: int
  • Raises: ValueError – If invalid stack or channel

resetOptoCount(stack: int, channel: int)

Reset the counter for an opto-isolated input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
  • Raises: ValueError – If invalid stack or channel

getOptoEncCount(stack: int, channel: int)

Get the counter value for an opto-isolated encoder input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
  • Returns: Counter value (0-65535)
  • Return type: int
  • Raises: ValueError – If invalid stack or channel

resetOptoEncCount(stack: int, channel: int)

Reset the counter for an opto-isolated encoder input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
  • Raises: ValueError – If invalid stack or channel

getOptoEncoder(stack: int, channel: int)

Get encoder mode for an opto-isolated input pair

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-8, must be odd)
  • Returns: Encoder mode (0=disabled, 1=enabled)
  • Return type: int
  • Raises: ValueError – If invalid stack or channel

setOptoEncoder(stack: int, channel: int, state: int)

Set encoder mode for an opto-isolated input pair

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-8, must be odd)
    • state – Encoder state (0=disabled, 1=enabled)
  • Raises: ValueError – If invalid stack, channel or state

getOptoFrequency(stack: int, channel: int)

Get frequency measurement for an opto-isolated input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
  • Returns: Frequency in Hz
  • Return type: int
  • Raises: ValueError – If invalid stack or channel

getOptoPWM(stack: int, channel: int)

Get PWM duty cycle measurement for an opto-isolated input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
  • Returns: PWM duty cycle (0-100%)
  • Return type: float
  • Raises: ValueError – If invalid stack or channel

setOptoInterrupt(stack: int, channel: int, enabled: bool)

Enable/disable interrupts for an opto-isolated input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
    • enabled – True to enable interrupts, False to disable
  • Raises: ValueError – If invalid parameters

getOptoInterrupt(stack: int, channel: int)

Get interrupt enable state for an opto-isolated input

  • Parameters:
    • stack – Board stack level (0-7)
    • channel – Input channel number (1-16)
  • Returns: True if interrupts enabled, False if disabled
  • Return type: bool
  • Raises: ValueError – If invalid parameters

setOptoInterruptMask(stack: int, mask: int)

Set interrupt enable mask for all opto-isolated inputs

  • Parameters:
    • stack – Board stack level (0-7)
    • mask – 16-bit mask (1=enabled, 0=disabled)
  • Raises: ValueError – If invalid parameters

getOptoInterruptMask(stack: int)

Get interrupt enable mask for all opto-isolated inputs

  • Parameters: stack – Board stack level (0-7)
  • Returns: 16-bit mask with interrupt enable states
  • Return type: int
  • Raises: ValueError – If invalid stack

Troubleshooting

If you encounter any problems, first verify that your package is up to date. To check the installed version, run:

pip freeze | grep -i SM16inpind

If you installed SM16inpind with pip3, use:

pip3 freeze | grep -i SM16inpind

Additionally, if you are using a virtual environment, ensure it is activated by checking the Python interpreter’s path:

which python

If the output does not show the path to your virtual environment, activate it with:

source /path/to/.venv/bin/activate

Metadata

Release files for sm16inpind 1.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sm16inpind 1.1.5
File Size Uploaded
sm16inpind-1.1.5.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sm16inpind 1.1.5
File Interpreter ABI Platform
sm16inpind-1.1.5-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 22.5 kB

Release files / sm16inpind-1.1.5.tar.gz

Download URL sm16inpind-1.1.5.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5af2575d3672935f389c13ec6dacfe8449edd4b5529ec79b7d4a2ac8d2bf82a3
BLAKE2b-256 checksum
How to use checksums
7ac7354575c8a47e0270a60670b6fb95751ba64ddb2e3c653d0996150df815b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.2

Release files / sm16inpind-1.1.5-py2.py3-none-any.whl

Download URL sm16inpind-1.1.5-py2.py3-none-any.whl
Size 12.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f5841df89ae2570401f2bf57ec6d0d0ad9cc47ed8cddc05662811c2342824ac9
BLAKE2b-256 checksum
How to use checksums
1b289501ed8f8f883f71320bc361c46a4580f87aec6e40ba3118efbda89abbb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.2

Release history Release notifications | RSS feed

This release

1.1.5 This release

2 release files

1.1.4

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page