FB_BA_Weatherstation_Thies

FB_BA_Weatherstation_Thies 1:

This template prepares the data which are read from a Thies weather station via the function block FB_BA_ThiesWSC11 and makes them available in a globally declared variable structure stWeatherstation (see global variable list Site).

In addition, the hardware connection is established in this template via the variables stRawDataIn and stRawDataOut.

A detailed description of the integration of the weather station can be found here.

FB_BA_Weatherstation_Thies 2:

The initialization of the template takes place within the method FB_Init.

Syntax

FUNCTION_BLOCK FB_BA_WeatherStation_Thies EXTENDS FB_BA_View
VAR_INPUT CONSTANT
  SerialCommRst                : FB_BA_Bv_OP;
  WthStRst                     : FB_BA_Bv_OP;
  SerialCommErr                : FB_BA_BV;
  Dstb                         : FB_BA_BV;
  Rain                         : FB_BA_BI;
  WthT                         : FB_BA_AI;
  DewPtT                       : FB_BA_AI;
  PrssAbs                      : FB_BA_AI;
  PrssRel                      : FB_BA_AI;
  HumAbs                       : FB_BA_AI;
  HumRel                       : FB_BA_AI;
  Brightness_N                 : FB_BA_AI;
  Brightness_S                 : FB_BA_AI;
  Brightness_E                 : FB_BA_AI;
  Brightness_W                 : FB_BA_AI;
  Dawn                         : FB_BA_AI;
  GlobRadn                     : FB_BA_AI;
  WndDir                       : FB_BA_AI;
  WndSpd                       : FB_BA_AI;
  Latd                         : FB_BA_AI;
  Lngt                         : FB_BA_AI;
  SunAzm                       : FB_BA_AI;
  SunElv                       : FB_BA_AI;
END_VAR

VAR
  ThiesWSC11                   : FB_BA_ThiesWSC11;
  bResetWeatherStation         : BOOL;
  bResetSerialCommunication    : BOOL;
  DataConversion               : FB_BA_ThiesData;
  tonSerialCommErr             : TON;
  tonDstb                      : TON;

  stRawDataIn     AT %I*       : KL6InData22B;
  stRawDataOut    AT %Q*       : KL6OutData22B;
  fbSerialCtrl                 : SerialLineControl;
  fbKL6Configuration           : KL6configuration;
  stTxBuff                     : ComBuffer;
  stRxBuff                     : ComBuffer;

  bSerialConfigError           : BOOL;
  nSerialConfigErrorID         : UDINT;
  bSerialCommError             : BOOL;
  nSerialCommErrorID           : UDINT;
END_VAR
VAR_INPUT CONSTANT PERSISTENT
{attribute 'parameterUnit':= 's'}
  nSerialCommErrDelay          : UDINT := 10;
{attribute 'parameterUnit':= 's'}
  nDstbDelay                   : UDINT := 10;
END_VAR

FB_BA_Weatherstation_Thies 3: Inputs CONSTANT

Name

Type

Description

SerialCommRst

FB_BA_Bv_OP

Restart the serial communication if it is permanently faulty due to a configuration error or during operation.

WthStRst

FB_BA_Bv_OP

Restarting the weather station itself if it is permanently faulty.

Here the PLC routine is restarted starting with the configuration and subsequent cyclic query.

A hardware reset is not performed.

SerialCommErr

FB_BA_BV

Message requiring acknowledgement: Serial communication or configuration permanently faulty.

Dstb

FB_BA_BV

The weather station reports a malfunction.

Rain

FB_BA_BI

Rain sensor.

WthT

FB_BA_AI

Outside temperature [°C].

DewPtT

FB_BA_AI

Dew point temperature [°C].

PrssAbs

FB_BA_AI

Absolute air pressure [hPa].

PrssRel

FB_BA_AI

Relative air pressure [hPa].

HumAbs

FB_BA_AI

Absolute humidity [g/m3].

HumRel

FB_BA_AI

Relative Absolute Humidity [g/m3].

Brightness_N

FB_BA_AI

Directional light sensor north [Lux].

Brightness_S

FB_BA_AI

Directional light sensor south [Lux].

Brightness_E

FB_BA_AI

Directional light sensor east [Lux].

Brightness_W

FB_BA_AI

Directional light sensor west [Lux].

Dawn

FB_BA_AI

Dawn [Lux].

GlobRadn

FB_BA_AI

Global radiation [W/m²].

WndDir

FB_BA_AI

Wind direction [°].

WndSpd

FB_BA_AI

Wind speed [m/s]

Latd

FB_BA_AI

Latitude of the installation site [°].

Lngt

FB_BA_AI

Longitude of the installation site [°].

SunAzm

FB_BA_AI

Current position of the sun [°].

SunElv

FB_BA_AI

Current sun elevation [°].

Variables

Name

Type

Description

ThiesWSC11

FB_BA_ThiesWSC11

Function block for unloading the data from the Thies WSC11

bResetWeatherStation

BOOL

Reset weather station.

bResetSerialCommunication

BOOL

Reset serial communication.

DataConversion

FB_BA_ThiesData

Converts the Thies weather station data into project-specific data. Example brightness: conversion from kLux to Lux, because only this unit is supported by BACnet.

tonSerialCommErr

TON

Error delay communication error.

tonDstb

TON

Error delay weather station error

stRawDataIn

KL6InData22B

Input raw values from the serial terminal.

stRawDataOut

KL6InData22B

Output raw values to the serial terminal.

fbSerialCtrl

SerialLineControl

Communication block to the serial terminal. Runs in the fast task under the FastCycle method.

fbKL6Configuration

KL6configuration

Configuration block to the serial terminal. Runs in the fast task under the FastCycle method.

This is used to set the serial parameters (baud rate, etc), but not the process image (see Thies weather station).

stTxBuff

ComBuffer

Communication variable between the fbSerialCtrl of the fast task and the ThiesWSC11 of the normal PLC task.

stRxBuff

ComBuffer

Communication variable between the fbSerialCtrl of the fast task and the ThiesWSC11 of the normal PLC task.

bSerialConfigError

BOOL

Configuration error of the serial communication.

nSerialConfigErrorID

UDINT

Error number.

bSerialCommError

BOOL

Communication error of the serial communication.

nSerialCommErrorID

UDINT

Error number.

FB_BA_Weatherstation_Thies 4: Inputs CONSTANT PERSISTENT

Name

Type

Description

nSerialCommErrDelay

UDINT

Error delay communication error [s].

nDstbDelay

UDINT

Error delay weather station error [s].

Requirements

Development environment

Necessary function

TwinCAT from v3.1.4024.35

TF8040 | TwinCAT Building Automation from V5.0.0.0