Digital outputs
Pigeon computers are equipped with 8 open drain digital outputs. Two of them (O6 and O7) can function as PWM outputs. Table 1 outlines the assignment of outputs to the GPIO. Each output is activated when its corresponding GPIO is set HIGH. The ENABLE signal is active-low. When ENABLE is set HIGH, all digital outputs are disabled.
Figure 1 shows recommended wiring for an LED (a) and relays (b, c) with open-drain outputs. Built-in diodes protect output transistors from transient voltage spikes (b). For long relay wiring, an external diode (c) is recommended.
Fig. 1. Example digital outputs connections
Table 1. Digital outputs - GPIO
SIGNAL | GPIO |
---|---|
ENABLE | GPIO34 |
O1 | GPIO35 |
O2 | GPIO36 |
O3 | GPIO37 |
O4 | GPIO38 |
O5 | GPIO39 |
O6 | GPIO40 |
O7 | GPIO41 |
O8 | GPIO42 |
Table 2. Digital outputs parameters
PARAMETER | VALUE |
---|---|
Quantity of outputs | 8 |
Maximum current | 500 mA |
Maximum voltage | 28 V DC |
Software
Bash
Change state of output O1:
$ echo "34" > /sys/class/gpio/export #export GPIOs to userspace
$ echo "35" > /sys/class/gpio/export
#Set GPIOs as an output
$ echo "out" > /sys/class/gpio/gpio34/direction
$ echo "out" > /sys/class/gpio/gpio35/direction
#ENABLE active
$ echo "0" > /sys/class/gpio/gpio34/value
#Turn on O1
$ echo "1" > /sys/class/gpio/gpio35/value
#Turn off O1
$ echo "0" > /sys/class/gpio/gpio35/value
#unexports GPIOs
$ echo "34" > /sys/class/gpio/unexport
$ echo "35" > /sys/class/gpio/unexport
The WiringPi library is pre-installed and provides tools for GPIO management. Below are some examples:
#Set GPIOs as an output
$ gpio mode 34 out
$ gpio mode 35 out
#ENABLE active
$ gpio write 34 0
#Turn on O1
$ gpio write 35 1
#Turn off O1
$ gpio write 35 0
#Set O6 mode to PWM
$ gpio mode 40 pwm
#Set PWM value for O6 to 500 (range: 0-1023)
$ gpio pwm 40 500
Python
To change the state of output O1, you can use the following commands:
$ python
>>> import RPi.GPIO as GPIO
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.setup(34, GPIO.OUT)
>>> GPIO.setup(35, GPIO.OUT)
>>> GPIO.output(34, False) # Activate outputs (ENABLE active-low)
>>> GPIO.output(35, True) #Turn on O1
>>> GPIO.output(35, False) #Turn off O1