From OpenSCADAWiki
Jump to: navigation, search
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 9: Line 9:
 
| 2.1 || GPL2 || daq_GPIO.so || en,uk,ru,de || x86,x86_64,ARM
 
| 2.1 || GPL2 || daq_GPIO.so || en,uk,ru,de || x86,x86_64,ARM
 
<section end=info />
 
<section end=info />
| DAQ || Roman Savochenko || GPIO different boards: Broadcom BCM 2835 and more (Raspberry Pi, ...), SUNXI AllWinner H2 and more (Orange Pi Zero, ...).
+
| DAQ || Roman Savochenko || GPIO different single board PCs: Broadcom BCM 2835 and more (Raspberry Pi, ...), SUNXI AllWinner H2 and more (Orange Pi Zero, ...).
 
|}
 
|}
  
 
__TOC__
 
__TOC__
  
The module provides OpenSCADA with the support data sources of realtime, which based on different boards General Purpose Input/Output (GPIO) grounded on:
+
The module provides OpenSCADA support for General Purpose Inputs/Outputs (GPIOs) based on single-board PCs:
* BCM2835 chip and more — [https://www.raspberrypi.org Raspberry PI, PI2, PI3];
+
* BCM2835 and higher — [https://www.raspberrypi.org Raspberry PI, PI2, PI3];
* SUNXI AllWinner H2 and more — [http://www.orangepi.org Orange Pi, Zero, One, Plus].
+
* SUNXI AllWinner H2 and higher — [http://www.orangepi.org Orange Pi, Zero, One, Plus].
  
BCM2835 GPIO of Raspberry Pi counts 32 pins in maximum, some of them can also performs alternative functions like: I2C, UART, SPIO. For access to the GPIO in general functions there is used the GPIO part of the library [http://www.airspayce.com/mikem/bcm2835 libBCM2835], which are included and building with the module.
+
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 [http://www.airspayce.com/mikem/bcm2835 libBCM2835], which are included and building with the module.
  
SUNXI AllWinner H2 and more of Orange Pi can have 9 main and 6 additional banks with 32 IO for each one, some of them can also performs alternative functions like: I2C, UART, SPIO. For access to the GPIO in general functions there is used the GPIO part of the library [https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 orangepi_PC_gpio_pyH3], 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 [https://github.com/duxingkei33/orangepi_PC_gpio_pyH3 orangepi_PC_gpio_pyH3], which are included and building with the module.
  
 
== Controller object ==
 
== Controller object ==
GPIO into OpenSCADA configured with a new controller object creation (Fig.1) and the container parameters' objects — a single parameter of the board's GPIO.
+
GPIO in OpenSCADA is configured by creating a new controller object (Fig.1) and the controller parameter — one GPIO parameter for one card.
  
 
[[file:GPIO_obj_cntr.png|center|frame|Fig.1. Configuration tab of a controller object.]]
 
[[file:GPIO_obj_cntr.png|center|frame|Fig.1. Configuration tab of a controller object.]]
  
 
From this tab you can set:
 
From this tab you can set:
* The state of the controller, as follows: Status "Enable", "Run" and the name of the database containing the configuration.
+
* The state of the controller object, as follows: status, "Enabled", "Running" and the database name containing the configuration.
* Id, name and description of the controller.
+
* Identifier, name and description of the controller.
* The state, in which the controller must be switched at boot: "To enable" and "To start".
+
* The state "Enabled" and "Running", in which the controller object must be switched at boot.
* Name of table to store the configuration of the parameters of the controller.  
+
* Name of the table to store the controller parameters configuration.
  
== The controller's parameter object ==
+
== Parameters ==
The parameter object is a direct representative-reflection for the GPIO, which contains attributes set with Boolean types and it whole quantity 32. Parameter's object configuration tab is shown in Figure 2. The acquisition data is done only in synchronous mode but GPIO must be fast.
+
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.
  
 
[[file:GPIO_obj_prm.png|center|frame|Fig.2. Configuration tab of a parameter.]]
 
[[file:GPIO_obj_prm.png|center|frame|Fig.2. Configuration tab of a parameter.]]
  
With the parameter's object configuration tab you can set:
+
With the parameter configuration tab you can set:
* The state of the parameter: type, "Enable" and static functions list.
+
* The state of the parameter: type (BCM2835, SUNXI), "Enabled" and static functions list.
* Id, name and description of the parameter.
+
* Identifier, name and description of the parameter.
* The state, in which the parameter must be translated at boot: "To enable".
+
* The state "Enabled", in which the parameter must be translated at start up.
  
Tab "Attributes" for the GPIO is shown in Figure 3. For the GPIO there is accessed also "Configuration" tab (Fig.4) with IO mode and reverse state.
+
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.
  
[[file:GPIO_obj_prmAttr.png|center|frame|Fig.3. Tab "Attributes" of a parameter.]]
+
[[file:GPIO_obj_prmAttr.png|center|frame|Fig.3. Tab "Attributes" of a parameter of the "BCM2835".]]
  
[[file:GPIO_obj_prmCfg.png|center|frame|Fig.4. Tab "Configuration" of a parameter.]]
+
[[file:GPIO_obj_prmAttrSUNXI.png|center|frame|Fig.4. Tab "Attributes" of a parameter of the "SUNXI".]]
  
For maximum fast access to the GPIO the parameter object provides three static functions: "mode", "get" and "put". These functions can be used in an user programming area of OpenSCADA system for the organization of not ordinary interaction algorithms. To address the functions you can use static call address '''GPIO.{cntr}.{prm}.{Func}()''' or dynamic '''SYS.DAQ.GPIO.{cntr}.{prm}["{Func}"].call()'''. Where:
+
[[file:GPIO_obj_prmCfg.png|center|frame|Fig.5. Tab "Configuration" of a parameter.]]
* {cntr} — identifier of the controller's object;
+
* {prm} — identifier of the parameter's object;
+
* {Func} — identifier of the function.
+
  
== Function GPIO: Mode (mode) ==
+
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:
 +
<pre style="white-space: pre-wrap;">
 +
function put = addr+".fnc_put";
 +
if(put) {
 +
  put(D4, vl&0x10);
 +
  put(D5, vl&0x20);
 +
  put(D6, vl&0x40);
 +
  put(D7, vl&0x80);
 +
}</pre>
 +
 
 +
And in this configurable way there for now have implemented next templates of the low-level devices:
 +
* [[Special:MyLanguage/Libs/User_protocol_devices#DHT|GPIO: DHT11,22 (AM23XX)]]
 +
* [[Special:MyLanguage/Libs/User_protocol_devices#1602A|GPIO: 1602A(HD44780) (1602A)]]
 +
 
 +
=== Function GPIO: Mode (mode) ===
 
''Description'': GPIO mode, input or output.<br/>
 
''Description'': GPIO mode, input or output.<br/>
 
''Parameters'':
 
''Parameters'':
Line 65: Line 81:
 
| pin || Pin || Integer || Input ||  
 
| pin || Pin || Integer || Input ||  
 
|-
 
|-
| set || Force the input mode: 1-Input, 2-Input (pull up), 3-Input (pull down), 4-Output || Integer || Input || 0  
+
| set || Setting the input mode: 1-Input, 2-Input (pull up), 3-Input (pull down), 4-Output || Integer || Input || 0  
 
|}
 
|}
  
== Function GPIO: Get (get) ==
+
=== Function GPIO: Get (get) ===
 
''Description'': GPIO get pin level.<br/>
 
''Description'': GPIO get pin level.<br/>
 
''Parameters'':
 
''Parameters'':
Line 80: Line 96:
 
|}
 
|}
  
== Function GPIO: Put (put) ==
+
=== Function GPIO: Put (put) ===
 
''Description'': GPIO put pin level.<br/>
 
''Description'': GPIO put pin level.<br/>
 
''Parameters'':
 
''Parameters'':
Line 93: Line 109:
  
 
== Notes ==
 
== Notes ==
The module has been tested on boards Raspberry Pi 2, 3 model B and Orange Pi Zero. For details you can see to [[Special:MyLanguage/Using/Raspberry_Pi|the Raspberry Pi page]] and [[Special:MyLanguage/Using/Raspberry_Pi|the Orange_Pi page]].
+
The module was tested on the boards [[Special:MyLanguage/Using/Raspberry_Pi|Raspberry Pi 2,3 models B]] and [[Using/Orange_Pi|Orange Pi Zero]].
  
 
Access time to the static functions was measured comparing to the different methods which you can see [[Special:MyLanguage/Modules/JavaLikeCalc#Productivity|here]].
 
Access time to the static functions was measured comparing to the different methods which you can see [[Special:MyLanguage/Modules/JavaLikeCalc#Productivity|here]].
 
For derivative DAQ templates creation using the static functions you can use also dynamic linking to its, like this:
 
<pre style="white-space: pre-wrap;">
 
function put = addr+".fnc_put";
 
if(put) {
 
  put(D4, vl&0x10);
 
  put(D5, vl&0x20);
 
  put(D6, vl&0x40);
 
  put(D7, vl&0x80);
 
}</pre>
 
 
In this configurable way there for now have implemented next templates of the low-level devices:
 
* [[Special:MyLanguage/Libs/User_protocol_devices#DHT|GPIO: DHT11,22 (AM23XX)]]
 
* [[Special:MyLanguage/Libs/User_protocol_devices#1602A|GPIO: 1602A(HD44780) (1602A)]]
 

Revision as of 20:06, 29 April 2018

Other languages:
Constr.png The translation checking and actualizing
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

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.