Skip to content

Digital inputs

The Pigeon computer has 8 opto-isolated digital inputs and 4 dry contact inputs.

Digital optoisolated inputs

The 8 opto-isolated digital inputs are divided into two sections. See the diagram below.

opto-inputs

Fig. 1. Digital opto-isolated inputs connection

The following table shows the mapping between the opto-isolated inputs and the corresponding gpiochip GPIO lines.

Table 1. Digital opto-isolated inputs

SIGNAL BIT Trixie gpiochip Bookworm gpiochip
I1 8 gpiochip14 gpiochip2
I2 9 gpiochip14 gpiochip2
I3 10 gpiochip14 gpiochip2
I4 11 gpiochip14 gpiochip2
I5 12 gpiochip14 gpiochip2
I6 13 gpiochip14 gpiochip2
I7 14 gpiochip14 gpiochip2
I8 15 gpiochip14 gpiochip2

When the input voltage is between 0V and 5V, the GPIO logic state is high (negative logic). When the input voltage is between 10V and 28V, the GPIO state is low.

Table 2. Digital opto-isolated inputs parameters

PARAMETER VALUE
Quantity of inputs 8
Low-level input voltage 0 ... +5 V DC
High-level input voltage +10 ... +28V DC
Isolation voltage 5 kV RMS
Input resistance >=10kOhm

Dry contact inputs

The following table shows the mapping between the dry contact inputs and the corresponding gpiochip GPIO lines.

Table 3. Dry contact inputs

INPUTS GPIOD
ID1 gpiochip0 12
ID2 gpiochip0 13
ID3 gpiochip0 16
ID4 gpiochip0 17

When the input is shorted to GND, the GPIO logic state is high. Otherwise, the GPIO state is low.

dry-contact-inputs

Fig. 2. Dry contact inputs connection

Linux kernel GPIO user space interface

gpiod

Install gpiod tools:

$ apt install gpiod 

Read input I1 state:

$ gpioget -c gpiochip14 8

Read input ID1 state:

$ gpioget -c gpiochip0 12

Note on gpiochip numbering. The gpiochip numbering may vary between different Linux kernel versions. The binary outputs and opto-isolated binary inputs are provided by the MCP23017 I/O expander and are identified by the gpiochip corresponding to this device. If the gpiochip number is unknown or differs between systems, the recommended approach is to use the gpiodetect command, which lists all available GPIO controllers along with their identifiers.

$ gpiodetect
...
gpiochip14 [mcp23017]

Direct control via the I2C interface

To control the opto-isolated inputs directly via the I2C interface, comment out the following line in the /boot/firmware/config.txt file (or /boot/config.txt in older distributions):

dtoverlay=mcp23017,addr=0x20,gpiopin=23 

Otherwise, you will receive the following message:

Unable to select I2C device: Device or resource busy

Reading input I1:

$ gpio -x mcp23017:100:0x20 read 108 

To read the next inputs, change the last argument accordingly: I2=109, I3=110, and so on.

Information for Codesys Users

If you want to use binary inputs/outputs in CODESYS, comment out the following line in the /boot/firmware/config.txt file (or /boot/config.txt in older distributions):

dtoverlay=mcp23017,addr=0x20,gpiopin=23