5.2 Working with GPIO pins
5.2.1 Modifications in the project main file
Now we tell the compiler to use the Raspberry Pi I/O driver. This is what needs to be done:
- Rename the MODULE block to RPiDrv – CASE SENSITIVE!
Further link the IODRV block with the RPiDrv module by setting
- – CASE SENSITIVE!
For bare Raspberry Pi set the following:
- – CASE SENSITIVE!
- Leave the cfgname parameter blank.
- Leave the other parameters intact.
As the final step, rename the IODRV block to RPI, which will serve as a prefix for all I/O signals of this driver.
The executive of the REX Control System is configured, your project should look like this:
5.2.2 Modifications in the task
In the task double-click the input flag and set . Note the RPI prefix and two underscore characters. The first physical switch will be connected to GPIO#23.
The second physical switch will be connected to GPIO#24 (RPI__GPIO24) and GPIO#25 will serve as the output signal (RPI__GPIO25).
Similarly for other pins we could use the following flags:
- Goto, RPI__GPIO22 – digital output 22
- 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 pull up/down resistor
A detailed description of the I/O driver for Raspberry Pi is available in a separate manual [5].
The pin numbering on Raspberry Pi B+, 2 and 3 is shown in the following pictures:
Visit the http://elinux.org/RPi_Low-_level_peripherals webpage for detailed information about individual GPIO pins.
Your project should now look like this:
After compiling the project and downloading it to the Raspberry Pi the control algorithm interacts with the physical world. Again it is possible to switch to online mode and watch the signals in real-time or analyze the trends of signals. Flip the physical switches and watch the signals.
[Previous] [Back to top] [Up] [Next]