Computers for industrial control and automation systems

Digital outputs

Digital outputs

Pigeon computers have 8 open drain digital outputs. Two of them (O6 and O7) can work as PWM outputs. Table 1 shows the assignment outputs to the GPIO. The output is active when the state of the corresponding GPIO is high. ENABLE signal is active low. If ENABLE signal is high then all digital outputs are turned off. Fig. 1 shows recommended connection of LED (a) and relays (b,c) to open drain outputs. The internal diodes protect the output transistors from transient voltage peaks (b). In the case of long cables to relay, connection with an external diode (c) is recommended.

digital-outputs

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:

#export GPIOs to userspace
echo "34" > /sys/class/gpio/export
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

WiringPi library is installed by default. WiringPi comes with a separate program to help manage the GPIO. This program, called gpio. 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 O6 PWM value 500 (0-1023 is supported)
gpio pwm 40 500

Python

Change state of output O1:

python

>>> import RPi.GPIO as GPIO
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.setup(34, GPIO.OUT)
>>> GPIO.setup(35, GPIO.OUT)
>>> GPIO.output(34, False) #ENABLE active
>>> GPIO.output(35, True) #Turn on O1
>>> GPIO.output(35, False) #Turn off O1

 

Links

Back to Top