2.2 Connecting the inputs and outputs in the control algorithm
The inputs and outputs of the driver must be interconnected with the individual tasks (.mdl files). The individual tasks (QTASK or TASK blocks) are connected to the QTask, Level0,…, Level3 outputs of the main EXEC block.
2.2.1 GPIO pins of the Raspberry Pi
Necessary IODRV block configuration for Raspberry Pi GPIO:
- Block name – RPI
- module – RPiDrv
- classname – RPiDrv
The inputs and outputs of the RPiDrv driver can be accessed as shown in Fig. 2.2.
One block of the From type allowing the user to read one input has the Goto tag set to RPI__GPIO21U, while the other has this tag set to RPI__GPIO22U. The number in the flag corresponds with the GPIO pin number and the U letter activates the pull-up resistor. The block of Goto type allowing the user to set (write) one output has the Goto tag) set to RPI__GPIO23, the other output is accessed via the RPI__GPIO24 flag. The blocks always have the RPI prefix right at the beginning of the tag followed by two _ characters (underscore).
Similarly for other pins we can use e.g. the flags:
- Goto, RPI__GPIO22 – digital output 22
- Goto, RPI__GPIO23H – digital output 23, which is set to logical 1 (HIGH, ON) immediately upon initialization
- Goto, RPI__PWM18 – PWM output on pin 18
- From, RPI__GPIO7U – digital input 7 with internal pull-up resistor
- From, RPI__GPIO8D – digital input 8 with internal pull-down resistor
- From, RPI__GPIO21 – digital input 21 without any internal pull-up/down resistor
In general, the link to a particular GPIO pin consist of the driver name RPI, two underscores __, pin mode (GPIO or PWM), pin number and an optional symbol U for internal pull-up or D for internal pull-down in inputs and H or L for initial state in outputs. The pin numbering on Raspberry Pi is shown in Fig. 2.3.
All the input and output flags for the Raspberry Pi GPIO pins are prepared by default in
the folder
C:\Program Files (x86)\REX Controls\REX <_version>_\Examples\RaspberryPi_examples\00_IO_Flags.
Visit the http://elinux.org/RPi_Low-_level_peripherals webpage for detailed information about individual GPIO pins.
2.2.2 The PiFace Digital expansion board
Necessary IODRV block configuration for PiFace Digital:
- Block name – RPI
- module – RPiDrv
- classname – RPiDrv
Because the inputs and outputs of the board are strictly separated, the input flags contain PFI string and the output ones contain PFO string as shown in Fig. 2.5. Similarly to the GPIO pins, the pull-up resistors in inputs can be activated by the optional character U in the signal name. There are no pull-down resistors available on the PiFace Digital.
All the input and output flags for the PiFace Digital expansion board are prepared by
default in the folder
C:\Program Files (x86)\REX Controls\REX <_version>_\Examples\PiFaceDigital_examples\00_IO_Flags.
The numbering of the screw terminals of the PiFace Digital is depicted in Fig. 2.5.
It is also possible to read/write all eight inputs/outputs of PiFace Digital at once. This is faster than working with the individual signals. In that case the user must use the INOCT and OUTOCT blocks named RPI__PFI and RPI__PFO respectively.
Multiple PiFace Digital boards
It is assumed by default, that the PiFace Digital board is configured to have the address 0. If it is not the case, the address must be included in the input/output flag. E.g. RPI__PFO3C2 refers to the 4th output of the PiFace Digital card with address 2.
2.2.3 The UniPi expansion board
Necessary IODRV block configuration for UniPi expansion board:
- Block name – UNP
- module – RPiDrv
- classname – UnpDrv
The inputs and outputs of the UniPi expansion board can be accessed as shown in
Fig. 2.6. The link to a particular IO pin consist of driver name UNP, two underscores __, pin
number and an optional. The pin numbering of the UniPi expansion board is shown in
Fig. 2.7. All the input and output flags for the UniPi expansion board are by default prepared
in the folder
C:\Program Files (x86)\REX Controls\REX <_version>_\Examples\UniPi_examples\00_IO_Flags.
2.2.4 The Intellisys PIO expansion board
Necessary IODRV block configuration for Intellisys PIO expansion board:
- Block name – PIO
- module – RPiDrv
- classname – PioDrv
The inputs and outputs of the Intellisys PIO expansion board can be accessed as shown in
Fig. 2.8. The link to a particular IO pin consist of driver name PIO, two underscores __, pin
number and an optional. The pin numbering of the Intellisys PIO expansion board is shown in
Fig. 2.9. All the input and output flags for the Intellisys PIO expansion board are by default
prepared in the folder
C:\Program Files (x86)\REX Controls\REX <_version>_\Examples\PIO_examples\00_IO_Flags.
[Previous] [Back to top] [Up]