Programming - First steps
P.
35 of 349
“One“ or “One percent“?
A little help: Predefined values
And back to the example
A comparison is
with „==“ programmed.
Therefore, a value of 1 is the binary data type or data type assigned to the percentage. When we
write 1
b01
, we are referring to the binary, when we write 1
%
, we mean the percentage data.
Similarly, we add the data type
'1/0/0'b01
' to the notation of the group address. This means we want
to transfer to this address an information of one bit.
The Enertex
®
EibStudio knows predefined constants to make the program more readable. The
constant
OFF
is equivalent to 0b01 and
ON
to 1b01.
Because 1
b01
and 1% are of different data types, you can not directly connect these to each other.
Thus, the allocation
error=1b01 + 1%
to form a variable is not possible and will be reported as an
error when compiling the program. We need the convert function to link different data types. We will
return to this later (on page 54 and page 208 you will find more).
An overview of the predefined variables is listed on page 339. A data type is always a letter and two
numerals. The only exception to this is the percentage and string types for TCP/IP telegramms.
Other data types can be found on page 153 or later in this step-by-step instructions.
The data type "%" is compatible with the data type "u08" and will be internally adjusted by scaling
(whereas the data type can be specified in tenths of a percent accuracy). 100% internally
corresponds to a value of 255.
Now we return to expression
: '1/0/0'b01
==
ON
The two equal signs
==
are responsible for the comparison. The result of a comparison of two
expressions (variables, group addresses etc.) can only take the following values:
0
b01
, if the two values are not equal,
1
b01
, if the two values are equal.
You can find further comparative links on page 172.
Now, if the value 1b01 (ON) is sent to the bus at address '1/0/0', the comparison should have the
value ON. Thus, the condition of the if statement is true (equal to the value 1b01 or ON) and the then
branch is executed. By the
write
-function (see page 164), a valid EIB-telegram with the specified
value is written to the bus at the given address.
The statement
write
(
'1/1/1'b01
,
ON
)
writes to the group address 1/1/0 the value 1 (data types 1b01).
Finally, you should have fully understood:
if
(
'1/0/0'b01
==
ON
)
then write
(
'1/1/1'b01
,
ON
);
write
(
'1/1/2'u08
,
80%
)
endif
If not, read through this example again before you attend to the next example.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]