Difference between revisions of "Transclusion: IOT-GATE-iMX8: Industrial I/O add-on"

From Compulab Mediawiki
Jump to: navigation, search
imported>Igor.vaisbein
(Analog Input)
(Digital I/O)
Line 93: Line 93:
  
 
== Digital I/O ==
 
== Digital I/O ==
The digital I/O module can be installed in I/O module C. The module implements 4 digital input and 4 digital output signals.<br>
+
The digital I/O module can be installed in industrial I/O add-on slot C. The module implements 4 digital input and 4 digital output signals.</br>
These signals are controlled using the following GPIOs:
+
Make sure that the digital I/O module is present in your device.
* IN0: GPIO3_0, pin number 64
+
{{Note|in order to operate digital output or input signals, it is mandatory to connect external voltage source between pin 19 (24V_IN) and pin 20 (ISO_GND_C) of the industrial I/O add-on connector.}}
* IN1: GPIO3_1, pin number 65
+
=== Read Digital Input ===
* IN2: GPIO3_6, pin number 70
+
Use the following commands to read the value of the input signals.</br>
* IN3: GPIO3_7, pin number 71
+
Command format:
* OUT0: GPIO3_8, pin number 72
 
* OUT1: GPIO3_9, pin number 73
 
* OUT2: external GPIO (PCA9555) 9, pin number 505
 
* OUT3: external GPIO (PCA9555) 10, pin number 506
 
=== Read Digital input ===
 
Use the following command to read the value of IN0:
 
 
<pre>
 
<pre>
 
root@iot-gate-imx8:~# gpioget 2 0
 
root@iot-gate-imx8:~# gpioget 2 0
 
</pre>
 
</pre>
=== Set Digital output ===
+
{| width="40%" cellspacing="1" cellpadding="1" border="1"
Use the following command to set the value of OUT0:
+
|-
 +
| align="center" | '''Signal Name'''
 +
| align="center" | '''Pin number on the</br>I/O add-on connector'''
 +
| align="center" | '''Read input'''
 +
|- valign="top"
 +
| align="center" |IN0
 +
| align="center" |15
 +
| align="center" |gpioget 2 0
 +
|-
 +
| align="center" |IN2
 +
| align="center" |16
 +
| align="center" |gpioget 2 6
 +
|-
 +
| align="center" |IN1
 +
| align="center" |17
 +
| align="center" |gpioget 2 1
 +
|-
 +
| align="center" |IN3
 +
| align="center" |18
 +
| align="center" |gpioget 2 7
 +
|-
 +
|}
 +
=== Set Digital Output ===
 +
Use the following commands to set the value of the output signals.</br>
 +
Command format:
 
<pre>
 
<pre>
 
root@iot-gate-imx8:~# gpioset 2 8=1
 
root@iot-gate-imx8:~# gpioset 2 8=1
 
</pre>
 
</pre>
 +
{| width="40%" cellspacing="1" cellpadding="1" border="1"
 +
|-
 +
| align="center" | '''Signal Name'''
 +
| align="center" | '''Pin number on the</br>I/O add-on connector'''
 +
| align="center" | '''Set HIGH'''
 +
| align="center" | '''Set LOW'''
 +
|- valign="top"
 +
| align="center" |OUT0
 +
| align="center" |11
 +
| align="center" |gpioset 2 8=1
 +
| align="center" |gpioget 2 8=0
 +
|-
 +
| align="center" |OUT2
 +
| align="center" |12
 +
| align="center" |gpioset 5 9=1
 +
| align="center" |gpioset 5 9=0
 +
|-
 +
| align="center" |OUT1
 +
| align="center" |13
 +
| align="center" |gpioset 2 9=1
 +
| align="center" |gpioset 2 9=0
 +
|-
 +
| align="center" |OUT3
 +
| align="center" |14
 +
| align="center" |gpioset 5 10=1
 +
| align="center" |gpioset 5 10=0
 +
|-
 +
|}
  
 
== Analog Input ==
 
== Analog Input ==

Revision as of 13:14, 24 January 2023

IOT-GATE-iMX8 / SBC-IOT-iMX8 can be optionally assembled with the industrial I/O add-on board.
The industrial I/O add-on features up-to three separate I/O modules which allow to implement different combinations of isolated CAN, RS485, RS232, digital outputs and inputs.

CAN

CAN bus modules can be installed in I/O add-on slots A or B.
CAN bus modules support both CAN 2.0B and CAN FD standards. Maximum supported data rate is 8Mbps (in CAN FD mode).

CAN interface configuration

  • Configure the CAN interface bit-rate to 1 Mbits/sec:
root@iot-gate-imx8:~# ip link set can0 type can bitrate 1000000
  • Enable the CAN interface:
root@iot-gate-imx8:~# ip link set can0 up

Send/Receive packets

Use cansend and candump utilities to send and receive packets via CAN interface.

  • Send standard CAN frame (on the first device):
root@iot-gate-imx8:~# cansend can0 111#1122334455667788
  • Send extended CAN frame (on the first device):
root@iot-gate-imx8:~# cansend can0 11111111#1122334455667788
  • CAN frames (extended mode) generator, random payload, interval between two successive flames 50 msec:
root@iot-gate-imx8:~# cangen -g 50 -e -D r -v can0
can: raw protocol (rev 20170425)
...
  can0  03FF0983#D7.61.FF.03.C1.F7.C1.34
  can0  19C34D32#F7.5A.C2.73.AD.0E.3F.0B
  can0  0675E391#2B.2D.D3.49
  can0  13091C55#99.32.EC.77.27.81.49.0B
  can0  098D67CF#22.50.AB.48.AD.7F.F4.26
  can0  05263FEC#1B.4C.02.45.6E
  can0  12B30E20#
  can0  1F193DF9#C5
  can0  1EB0B18F#3E.3F.DA.57.C2.FE.73.58
  can0  1E5C64D9#6F.0D.B3.63.6A
  can0  1E1DE3F9#96.48.AC.79.4E.00.27.71
  can0  0E1A11B7#75.81.70.7C.86.79.A7.77
  can0  05F8FD8B#33.F9.9B.1E.77.3D.1F
  can0  1E155FCD#E6.BA.F8.58.ED.6D.C8.10
  can0  1D91DF9E#5D.29.82.7B.97.1D.AB.5C
  can0  11FB3CDA#14.65.C3
  can0  091352C0#2C.ED
...
  • Dump all received data frames as well as error frames (on the second device):
root@iot-gate-imx8:~# candump any,0:0,#FFFFFFFF
  can0  111   [8]  11 22 33 44 55 66 77 88
  can0  11111111   [8]  11 22 33 44 55 66 77 88
...
  can0  03FF0983   [8]  D7 61 FF 03 C1 F7 C1 34
  can0  19C34D32   [8]  F7 5A C2 73 AD 0E 3F 0B
  can0  0675E391   [4]  2B 2D D3 49
  can0  13091C55   [8]  99 32 EC 77 27 81 49 0B
  can0  098D67CF   [8]  22 50 AB 48 AD 7F F4 26
  can0  05263FEC   [5]  1B 4C 02 45 6E
  can0  12B30E20   [0] 
  can0  1F193DF9   [1]  C5
  can0  1EB0B18F   [8]  3E 3F DA 57 C2 FE 73 58
  can0  1E5C64D9   [5]  6F 0D B3 63 6A
  can0  1E1DE3F9   [8]  96 48 AC 79 4E 00 27 71
  can0  0E1A11B7   [8]  75 81 70 7C 86 79 A7 77
  can0  05F8FD8B   [7]  33 F9 9B 1E 77 3D 1F
  can0  1E155FCD   [8]  E6 BA F8 58 ED 6D C8 10
  can0  1D91DF9E   [8]  5D 29 82 7B 97 1D AB 5C
  can0  11FB3CDA   [3]  14 65 C3
  can0  091352C0   [2]  2C ED
...

RS232

RS232 modules can be installed in I/O slots A or B.
The module implements RS232 interface without hardware flow control.
The interface device in Linux:

  • I/O module A: /dev/ttymxc1
  • I/O module B: /dev/ttymxc3

RS485

RS485 modules can be installed in I/O module A or B.
The module implements a half-duplex RS485 interface.
The interface device in Linux:

  • I/O module A: /dev/ttymxc1
  • I/O module B: /dev/ttymxc3

Digital I/O

The digital I/O module can be installed in industrial I/O add-on slot C. The module implements 4 digital input and 4 digital output signals.
Make sure that the digital I/O module is present in your device.

Admolition note.png in order to operate digital output or input signals, it is mandatory to connect external voltage source between pin 19 (24V_IN) and pin 20 (ISO_GND_C) of the industrial I/O add-on connector.

Read Digital Input

Use the following commands to read the value of the input signals.
Command format:

root@iot-gate-imx8:~# gpioget 2 0
Signal Name Pin number on the
I/O add-on connector
Read input
IN0 15 gpioget 2 0
IN2 16 gpioget 2 6
IN1 17 gpioget 2 1
IN3 18 gpioget 2 7

Set Digital Output

Use the following commands to set the value of the output signals.
Command format:

root@iot-gate-imx8:~# gpioset 2 8=1
Signal Name Pin number on the
I/O add-on connector
Set HIGH Set LOW
OUT0 11 gpioset 2 8=1 gpioget 2 8=0
OUT2 12 gpioset 5 9=1 gpioset 5 9=0
OUT1 13 gpioset 2 9=1 gpioset 2 9=0
OUT3 14 gpioset 5 10=1 gpioset 5 10=0

Analog Input

Analog 4–20mA input modules can be installed in I/O slots A or B.
The module detect the current level between 4 to 20 mA.

Use the following command to load the kernel object:

root@iot-gate-imx8:~# modprobe max11108

Read the Detected Value

Use the following command to read the current detected value:

root@iot-gate-imx8:~# cat /sys/bus/iio/devices/iio:device0/in_voltage_raw

Values range:

  • 4mA: 786
  • 20mA: 3931