From OpenSCADAWiki
Jump to: navigation, search

Other languages:
Module Name Version License Source Languages Platforms Type Author Description
GPIO GPIO 2.1 GPL2 daq_GPIO.so en,uk,ru,de x86,x86_64,ARM DAQ Roman Savochenko GPIO different single board PCs: Broadcom BCM 2835 and more (Raspberry Pi, ...), SUNXI AllWinner H2 and more (Orange Pi Zero, ...).

The module provides OpenSCADA support for General Purpose Inputs/Outputs (GPIOs) based on single-board PCs:

GPIO on BCM2835 and higher of Raspberry Pi counts 32 pins in maximum, some of them can also performs alternative functions like to: I2C, UART, SPIO. For access to the GPIO there is used the GPIO part of the library libBCM2835, which are included and building with the module.

GPIO on SUNXI AllWinner H2 and higher of Orange Pi can have 9 main and 6 additional banks with 32 pins for each one, some of them can also performs alternative functions like to: I2C, UART, SPIO. For access to the GPIO there is used the GPIO part of the library orangepi_PC_gpio_pyH3, which are included and building with the module.

1 Controller object

GPIO in OpenSCADA is configured by creating a new controller object (Fig.1) and the controller parameter — one GPIO parameter for one card.

Fig.1. Configuration tab of a controller object.

From this tab you can set:

  • The state of the controller object, as follows: status, "Enabled", "Running" and the database name containing the configuration.
  • Identifier, name and description of the controller.
  • The state "Enabled" and "Running", in which the controller object must be switched at boot.
  • Name of the table to store the controller parameters configuration.

2 Parameters (BCM2835, SUNXI)

The parameter is the direct representative-reflection of the GPIO, which contains a list of attributes of a discrete type in an amount that corresponds to this GPIO type. The parameter configuration tab is shown in Figure 2. The data collection is performed only in synchronous mode since the GPIO should be fast.

Fig.2. Configuration tab of a parameter.

With the parameter configuration tab you can set:

  • The state of the parameter: type (BCM2835, SUNXI), "Enabled" and static functions list.
  • Identifier, name and description of the parameter.
  • The state "Enabled", in which the parameter must be translated at start up.

The tab "Attributes" of GPIO is shown in Figure 3 for BCM2835, and Figure 4 for SUNXI. For the GPIO, the "Configuration" tab (Fig. 5) is also available with the IO mode and the inversion state.

Fig.3. Tab "Attributes" of a parameter of the "BCM2835".
Fig.4. Tab "Attributes" of a parameter of the "SUNXI".
Fig.5. Tab "Configuration" of a parameter.

For the fastest access to the GPIO, the parameter provides three static functions: "mode", "get" and "put". These functions can be used in the OpenSCADA programming environment for extraordinary interaction algorithms organization. To address the function, you can use the static call of the address GPIO.{cntr}.{prm}.{Func}() or the dynamic SYS.DAQ.GPIO.{cntr}.{prm}["{Func}"].call(). Where:

  • {cntr} — identifier the controller object;
  • {prm} — identifier the parameter object;
  • {Func} — identifier the function.

At the moment, it is also possible to dynamically connect the static functions as the fastest and simultaneously flexible solution, for example:

function put = addr+".fnc_put";
if(put) {
  put(D4, vl&0x10);
  put(D5, vl&0x20);
  put(D6, vl&0x40);
  put(D7, vl&0x80);
}

And in this configurable way there for now have implemented next templates of the low-level devices:

2.1 Function GPIO: Mode (mode)

Description: GPIO mode, input or output.
Parameters:

ID Parameter Type Mode By defaults
rez Result Integer Return
pin Pin Integer Input
set Setting the input mode: 1-Input, 2-Input (pull up), 3-Input (pull down), 4-Output Integer Input 0

2.2 Function GPIO: Get (get)

Description: GPIO get pin level.
Parameters:

ID Parameter Type Mode By defaults
rez Result Bool Return
pin Pin Integer Input

2.3 Function GPIO: Put (put)

Description: GPIO put pin level.
Parameters:

ID Parameter Type Mode By defaults
pin Pin Integer Input
val Value Bool Input

3 Notes

The module was tested on the boards Raspberry Pi 2,3 models B and Orange Pi Zero.

Access time to the static functions was measured comparing to the different methods which you can see here and the overall performance measurement is given in the following table:

GPIO type get(), us put(), us
Raspberry Pi 3 0.36 0.27
Orange Pi Zero 1.2 1.2