IOT-DIN-IMX8PLUS: Debian Linux: I/O Modules Guide

From Compulab Mediawiki
Jump to: navigation, search

Overview

IOT-DIN-IMX8PLUS supports up to eight I/O Expansion Modules that can be stacked with the main gateway in order to extend the feature set of the system. A gateway assembly includes one gateway (the left most unit) and multiple I/O Expansion modules. Module stacking is done from left to right. Up to 8 I/O Expansion Modules can be supported in one gateway assembly. The modules are interconnected using Compulab’s proprietary StackLink expansion connector that extends a series of the IOT-DIN-IMX8PLUS interfaces, creating a chain of peripherals.

I/O Expansion Modules Stacking Rules

  • There can be up-to 8 I/O Expansion Modules in one assembly
  • IFM-WB modules can only be installed in position A (next to main gateway)
  • There can be up-to 3 (in total) modules of types IFM-RS485, IFM-RS232, IFM-WB
  • There can be up-to 4 IFM-DI8O8 modules
  • There can be only 1 IFM-ADC8 module

I/O Modules Configuration

I/O expansion modules are managed as a front-plane of virtual slots that map device access files to physical I/O modules per their positions in the stack.
During O/S boot IOT-DIN-IMX8PLUS automatically runs the StackLink configurator script that detects I/O modules and configures the virtual device files used to address the hardware.
The script creates the IFM front-plane file directory that includes type and access files for all populated stack slots.

IFM Front-Plane

During O/S boot the StackLink configurator script creates the IFM front-plane file directory that includes type and access files for all populated stack slots (from A to last populated slot).

/run/iotdin-imx8p/stack/frontplane

Front-plane directory structure

Example I/O modules stack:


+----------+-------+-------+-------+-------+
|  Slot #  |   A   |   B   |   C   |   D   |
+----------+-------+-------+-------+-------+
| IFM Type | ADC8  | DI8O8 | RS485 | RS232 |
+----------+-------+-------+-------+-------+

Front-plane file directory:

/run/iotdin-imx8p/stack/frontplane
|-- A
|   |-- access
|   |   |-- adc0 -> /sys/bus/iio/devices/iio:device0
|   |   `-- adc1 -> /sys/bus/iio/devices/iio:device1
|   `-- type.ADC8
|-- B
|   |-- access
|   |   |-- di.map
|   |   |-- do.map
|   |   `-- gpiochip -> /dev/gpiochip6
|   `-- type.DI8O8
|-- C
|   |-- access
|   |   |-- tty0 -> /dev/ttyIFM_RSx_0_0
|   |   |-- tty1 -> /dev/ttyIFM_RSx_0_1
|   |   |-- tty2 -> /dev/ttyIFM_RSx_0_2
|   |   `-- tty3 -> /dev/ttyIFM_RSx_0_3
|   `-- type.RS485
`-- D
    |-- access
    |   |-- tty0 -> /dev/ttyIFM_RSx_1_0
    |   |-- tty1 -> /dev/ttyIFM_RSx_1_1
    |   |-- tty2 -> /dev/ttyIFM_RSx_1_2
    |   `-- tty3 -> /dev/ttyIFM_RSx_1_3
    `-- type.RS232

Stack Detection Status

StackLink configurator script provides indication of I/O modules stack detection status using IOT-DIN-IMX8PLUS power LED:

Power LED Status Remarks
Blinking Blue Recognized and valid configuration Normal operation
Blinking Amber Unrecognized I/O module or invalid configuration Check the log for details

Stack Detection Info

StackLink configurator script stores stack detection info log in the following designated location:

/run/iotdin-imx8p/log/iotdin-imx8p.stack.log.<YYYYMMDD_HHMMSS>

Stack Troubleshooting


Admolition warning.png DO NOT attach or detach I/O Expansion modules while the gateway is connected to DC power! Disconnect all power sources from the gateway before attaching or detaching I/O modules.

In case of invalid IFM stack status:

  1. Check the stack detection log
  2. Double check if a desired stack conforms the Stacking Rules
  3. Verify proper mechanical attachment of modules
  4. Contact technical support

IFM Backplane


/run/iotdin-imx8p/stack/backplane directory stores the system information about the physical hardware devices installed in the stack. These files should not be altered.

IFM-DI8O8

IFM-DI8O8 module provides an isolated block of eight digital inputs and a block of eight digital outputs.
During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed IFM-DI8O8 modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Use diodetect command to get an overview of all available Digital Inputs and Outputs:

compulab@compulab-imx8mp:~$ /opt/iotdin-imx8p/shell/diodetect
Main Gateway:   DI2O2   (2x DI; 2x DO)
Stack Slot B:   DI8O8   (8x DI; 8x DO)

Use dioget and dioset commands to access digital inputs and digital outputs.
It is recommended to set the following alias for more convenient work:

compulab@compulab-imx8mp:~$ dioget=/opt/iotdin-imx8p/shell/dioget
compulab@compulab-imx8mp:~$ dioset=/opt/iotdin-imx8p/shell/dioset

Reading Digital Inputs

Setup alias for more convenient work:

compulab@compulab-imx8mp:~$ dioget=/opt/iotdin-imx8p/shell/dioget
compulab@compulab-imx8mp:~$ sudo ${dioget} -h
Usage: dioget [options] <command>

Read digital input state from a Digital I/O (DIO) module

Command:
 -m <module> <offset>
        module: DIO module location:
            m|M - Main Gateway
            a|A - Virtual slot A
            ...
            h|H - Virtual slot H
        offset: input pin offset: <0..MaxOffset>
Options:
 -h:    display this help and exit

Example
Read state of input pin IN_4 on IFM-DI8O8 installed in slot B:

compulab@compulab-imx8mp:~$ sudo ${dioget} -m B 4

Setting Digital Outputs

Setup alias for more convenient work:

compulab@compulab-imx8mp:~$ dioset=/opt/iotdin-imx8p/shell/dioset
compulab@compulab-imx8mp:~$ sudo ${dioset} -h
Usage: dioset [options] <command>

Set the digital output state of a Digital I/O (DIO) module

Command:
 -m <module> <offset>  <state>
        module: DIO module location:
            m|M - Main Gateway
            a|A - Virtual slot A
            ...
            h|H - Virtual slot H
        offset: output pin offset: <0..MaxOffset>
        state:  output pin state to be set: <0|1>
Options:
 -h:    display this help and exit

Example
Setting output pin OUT_4 to HIGH state on IFM-DI8O8 installed in slot B:

compulab@compulab-imx8mp:~$ sudo ${dioset} -m B 4 1

IFM-ADC8

IFM-ADC8 provides eight single-ended analog input channels (0-7), divided into two blocks of 4. Inputs operate between 0-10V or 4-20mA ranges for use with industrial sensors. Each block can be set into current or voltage input mode via jumper.

During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed I/O modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Example
Рead a detected value of channel 5 of IFM-ADC8 module installed in slot A:

compulab@compulab-imx8mp:~$ X=5 ; slot=A
compulab@compulab-imx8mp:~$ sudo cat /run/iotdin-imx8p/stack/frontplane/${slot}/access/adc$((X/4))/in_voltage$((X%4))_raw

IFM-RS485

IFM-RS485 I/O module provides four half-duplex RS485 ports.
During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed I/O modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Example

For an IFM-RS485 module installed in slot C the configurator script will create the following access files:

/run/iotdin-imx8p/stack/frontplane/
|-- C
|   |-- access
|   |   |-- tty0
|   |   |-- tty1
|   |   |-- tty2
|   |   `-- tty3
|   `-- type.RS485

Use /run/iotdin-imx8p/stack/frontplane/C/access/ttyX to access port #X

IFM-RS232

IFM-RS232 I/O module provides four 2-wire RS232 ports.
During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed I/O modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Example

For an IFM-RS232 module installed in slot D the configurator script will create the following access files:

/run/iotdin-imx8p/stack/frontplane/
|-- D
|   |-- access
|   |   |-- tty0
|   |   |-- tty1
|   |   |-- tty2
|   |   `-- tty3
|   `-- type.RS232

Use /run/iotdin-imx8p/stack/frontplane/D/access/ttyX to access port #X

IFM-WB

IFM-WB I/O module features one 802.11ax WiFi and one Bluetooth 5.3 BLE interfaces.
During O/S boot IOT-DIN-IMX8PLUS will automatically detect installed I/O modules and create necessary access files in the front-plane directory. For additional details please refer to the Configuration chapter.

Admolition note.png IFM-WB module can only be installed in position A (next to main gateway)

For an IFM-WB module installed in slot A the configurator script will create the following access files:

/run/iotdin-imx8p/stack/frontplane/
|-- A
|   |-- access
|   |   |-- bluetooth -> /sys/class/bluetooth/hci0
|   |   `-- wlan -> /sys/class/net/wlan0
|   `-- type.WB

Example

  • Display WiFi network interface info
compulab@compulab-imx8mp:~$ wlan=$(basename $(readlink -f /run/iotdin-imx8p/stack/frontplane/A/access/wlan))
compulab@compulab-imx8mp:~$ sudo ifconfig ${wlan}
compulab@compulab-imx8mp:~$ sudo iwconfig ${wlan}
  • Display Bluetooth interface info
compulab@compulab-imx8mp:~$ bt=$(basename $(readlink -f /run/iotdin-imx8p/stack/frontplane/A/access/bluetooth))
compulab@compulab-imx8mp:~$ hciconfig ${bt}

WiFi

Enable/Disable WiFi Interface

  • To enable WiFi interface:
compulab@compulab-imx8mp:~$ sudo nmcli radio wifi on
  • To disable WiFi interface:
compulab@compulab-imx8mp:~$ sudo nmcli radio wifi off

Network Scanning

  • Sample WiFi scanning:
compulab@compulab-imx8mp:~$ nmcli dev wifi list
The output will show the list of Access Points and Ad-Hoc cells in range.

Connecting to Access Point

In the following example:

  • Replace <SSID> and <PASSWORD> with the actual access point parameters:
compulab@compulab-imx8mp:~$ sudo nmcli device wifi connect <SSID> password <PASSWORD> name WifiCon
  • Disconnect wireless network:
compulab@compulab-imx8mp:~$ sudo nmcli connection down WifiCon
  • Connect wireless network again:
compulab@compulab-imx8mp:~$ sudo nmcli connection up WifiCon

Creating Access Point

Admolition note.png Debian 12
ipv4 forwarding must be turned on manually
  • Enable port forwarding:
compulab@compulab-imx8mp:~$ sudo sed -i 's/^#\(net.ipv[4,6].*forward\)/\1/' /etc/sysctl.conf
  • Enable wireless AP (replace <SSID> and <PASSWORD> with desired access point parameters):
sudo nmcli device wifi hotspot ssid <SSID> password <PASSWORD> con-name HotspotCon
  • Disable wireless AP:
compulab@compulab-imx8mp:~$ sudo nmcli connection down HotspotCon
  • Enable wireless AP again:
compulab@compulab-imx8mp:~$ sudo nmcli connection up HotspotCon