Skip to content

Digital outputs

Pigeon computer RB700 has 8 open drain digital outputs. Fig. 1 shows the recommended connection of an LED (a) and relays (b, c) to open-drain outputs. The internal diodes protect the output transistors from transient voltage spikes (b). In the case of long cables to the relay, using an external diode (c) is recommended.

digital-outputs

Fig. 1. Example of digital output connections

Table 1. Digital outputs parameters

PARAMETER VALUE
Quantity of outputs 8
Maximum current 500 mA
Maximum voltage 28 V DC

Linux kernel GPIO user space interface

gpiod

Installation of the gpiod tools:

$ apt install gpiod 

Change the state of output O1:

$ gpioset gpiochip2 0=1 
$ gpioset gpiochip2 0=0 

Change state of output O8:

$ gpioset gpiochip2 7=1 
$ gpioset gpiochip2 7=0 

Table 2. Digital outputs - gpiod

SIGNAL GPIOD
O1 gpiochip2 0
O2 gpiochip2 1
O3 gpiochip2 2
O4 gpiochip2 3
O5 gpiochip2 4
O6 gpiochip2 5
O7 gpiochip2 6
O8 gpiochip2 7

GPIO Sysfs Interface for Userspace

The Sysfs ABI is deprecated. This old Sysfs ABI will no longer be developed (no new features) and will only be maintained.

Change state of output O1:

$ echo "578" > /sys/class/gpio/export 
$ echo "out" > /sys/class/gpio/gpio578/direction 
$ echo "1" > /sys/class/gpio/gpio578/value 
$ echo "0" > /sys/class/gpio/gpio578/value 
$ echo "578" > /sys/class/gpio/unexport

Table 3. Digital outputs - Sysfs

SIGNAL GPIO SYSFS GPIO SYSFS kernel below 6.6
O1 GPIO578 GPIO488
O2 GPIO579 GPIO489
O3 GPIO580 GPIO490
O4 GPIO581 GPIO491
O5 GPIO582 GPIO492
O6 GPIO583 GPIO493
O7 GPIO584 GPIO494
O8 GPIO585 GPIO495

Direct control via the I2C interface

If you want to control the outputs directly via the I2C interface, you need to 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 get the following message:

Error: Could not set address to 0x20: Device or resource busy. 

Setting ports to output mode:

$ i2cset -y 1 0x20 0x00 0x00 

Setting output O1 to high:

$ gpio -x mcp23017:100:0x20 write 100 1 

Setting output O1 to low:

$ gpio -x mcp23017:100:0x20 write 100 0 

Setting output O2 to high:

$ gpio -x mcp23017:100:0x20 write 101 1 

Setting output O2 to low:

$ gpio -x mcp23017:100:0x20 write 101 0 

To control subsequent outputs, you need to adjust the second-to-last argument accordingly: O3=102, O4=103, and so on.

Information for Codesys Users

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

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