Variables andKNX™ group addresses
P.
162 of 349
Reading from and writing
to the KNX™ bus
Assigning variables and
group address – Reading
from the KNX™ bus
Default and systemstart()
The validation scheme
By means of a simple assignment, you can use the information sent by a sensor to a group address
in a variable or function, i.e. with the statement
variable = Group address
the information which is
sent to the
group address
is assigned to the
variable
in the Enertex
®
EibPC. As described above, the
group address
can be imported or "manually" defined in the Enertex
®
EibPC
Therefore, the use of variables and group addresses (imported or manual) is compatible, i.e. you
can, instead of variables, use group addresses as arguments of functions.
Example Assign a “manual“ KNX™ group address
a='1/0/0'u08
b='1/0/0'u08 + '1/0/1'u08
c= a+ '1/0/1'u08
In the example above, the contents of the group address 1/0/0 (more accurately: The contents of the
user data of the telegram with this group address), which has the type of an unsigned integer, is
assigned to the variable
a
. The variable
b
is the sum of the two values sent via the group addresses
1/0/0 and 1/0/1. The variable
c
is identical in content to the variable
b
, so you can use group
addresses as variables.
The Enertex
®
EibPC always saves the current state of the contents of the group address. If the
Enertex
®
EibPC is restarted, this must be taken into account. In this case, the Enertex
®
EibPC does
not know previously sent telegrams and initializes the state with 0 (0.0, etc depending on the types of
data.
With the function
systemstart
(), see page 213, variables, which are defined depending on group
addresses, can be preallocated with certain values at boot time.
A variable depending on a bus telegram in some way is only evaluated if the value which arrives in
the bus telegram changes.
Example
c= 1u08+ '1/0/1'u08
if systemstart() then c=2u08 endif
if (c==2u08) then write('3/3/3'b01,EIN) endif
if change(c) then write('3/3/2'b01,EIN) endif
The Enertex
®
EibPC initializes the evaluation of the telegram with the group address 1/0/1 to 0, thus
c
is initialized with 1u08. By the statement
if systemstart
()
c
is set to 2u08. When a new telegram
arrives on the bus to the group address 1/0/1, then
c
is re-evaluated.
Then the Enertex
®
EibPC verifies whether - due to the change of the variable
c
- further variables and
other statements depending on
c
must also be re-evaluated. In the example, this is the case. When
the value 1u08 is sent to the group address 1/0/1, the comparison in the if statement issues 1b01,
and thus the Enertex
®
EibPC writes a telegram with a value of 1b01 to the group address 3/3/3 on
the bus. The
change
function (page 208) checks whether a variable has changed in the last process
cycle. In this case, its return value is ON (1b01). Therefore, the last
if
statement is always executed
when the variable changes, and thus a telegram is written to group address 3/3/2 with the value ON
(1b01).
The Enertex
®
EibPC processes only changing terms and remembers the last state which was sent
via a group address. The mapping of states of the received telegrams and variables is called
validation scheme. It makes the operation and programming easy and intuitive, as long as one
avoids nesting of statements are avoided. As shown in the example, this is always possible to avoid
in a simple manner.
We advise beginners to avoid nested if statements.
Please, also refer to the example of the
read
function on page 165.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]