Type as, Is converted to ulint variable – Spectrum Controls 2080sc-BAC User Manual

Page 35

Advertising
background image

Chapter 3: Configuring the Module

3-17

User’s Manual Pub. 0300274-01 Rev. A.0

tmp2 :=

AND_MASK

(tmp2,

1

);

IF

tmp2 =

1

THEN

tmp_raw_var :=

1

;

ELSE

tmp_raw_var :=

0

;

END_IF

;

(*
if param_mode == 3
This is for Binary Input Table
*)

ELSIF

param_mode =

3

THEN

tmp_index := param_offset /

8

;

tmp1 :=

MOD

(param_offset,

8

);

tmp2 :=

1

;

tmp2 :=

SHL

(tmp2, tmp1);


tmp1 := ANY_TO_DINT(bac_raw_tbl[tmp_index]);

IF

param_var =

0

THEN

(* set 0 *)

tmp1 :=

NOT_MASK

(tmp1);

tmp1 :=

OR_MASK

(tmp1, tmp2);

tmp1 :=

NOT_MASK

(tmp1);

ELSE

(* set 1 *)

tmp1 :=

OR_MASK

(tmp1, tmp2);

END_IF

;

bac_raw_tbl[tmp_index] := ANY_TO_BYTE(tmp1);

ELSE

(* do nothing *)

(* tmp_index := param_offset / 8; *)

END_IF

;

In the Main function, you see a variable called

bacnet_convert_fn

type as

BACNET_Convert

is called. This is how the Main function calls the user-defined

function block.

Since CCW has many different types of data types, this function block is able to
convert all the different data types to a bytes array. When CCW reads from the
module, the module fills this bytes array first. Then CCW reads the array and
converts the data to different data types. When CCW writes to the module, CCW
converts a variable to this 8 bytes array, and writes it to the module. The
following examples shows how an analog output variable is read from module,
and an analog input variable is written to the module from CCW. Structured text
is generated by the module.

A variable called

tag1

is converted to ULINT variable

bacnet_convert_var

and then placed at offset 0 of the byte array table because you are writing
AnalogInput 0. If it is AnalogInput 1, the offset will be 8 as each BACNET
object instance takes 8 bytes. Variable

bacnet_convert_mode

is 1 means this

is a write operation. 0 indicates a read operation.

(* 0, AnalogInput, aiaaa *)

bacnet_convert_var := ANY_TO_ULINT(tag1);
bacnet_convert_offset := 0;
bacnet_convert_mode := 1;
bacnet_convert_fn(bacnet_convert_offset,
bacnet_convert_var, bacnet_convert_mode);

Advertising