# FanAnalog

## `FanAnalog` (FB)

FUNCTION\_BLOCK FanAnalog

### Short description

> Control of a variable-speed fan\
> Additional functions: manual overrides, repair switch, operating hours counter, air shortage\
> Typical application: control of a fan with a frequency converter

### Representation

<figure><img src="https://2592874069-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQR4vCFzt6ixgsqlR3pdR%2Fuploads%2Fgit-blob-ee5ba2a030b87f6c11622a9c7e3a6ed563735077%2FFanAnalog_FB.png?alt=media" alt=""><figcaption></figcaption></figure>

### Interfaces

#### Inputs

| Name       | Data type         | Value range                                                               | Initial value          | Function                                                                                 |
| ---------- | ----------------- | ------------------------------------------------------------------------- | ---------------------- | ---------------------------------------------------------------------------------------- |
| *xEn*      | BOOL              |                                                                           |                        | Demand for the fan ( FALSE = Off, TRUE = On )                                            |
| *rY*       | REAL              |                                                                           |                        | Control signal - speed 0.0 - 100.0 %                                                     |
| *xForce*   | BOOL              |                                                                           | FALSE                  | Forced lockout of the fan after manual override ( FALSE = Off, TRUE = On )               |
| *xFb*      | BOOL              |                                                                           |                        | Operating indication of the fan ( FALSE = Off, TRUE = On )                               |
| *xPFb*     | BOOL              |                                                                           |                        | Feedback of the air shortage monitoring ( FALSE = air shortage, TRUE = no air shortage ) |
| *xMSwitch* | BOOL              |                                                                           | TRUE                   | Feedback of the repair switch ( FALSE = switch Off, TRUE = switch On )                   |
| *xAlarmIn* | BOOL              |                                                                           |                        | Fault indication of the fan ( FALSE = Off, TRUE = On )                                   |
| *eAOO*     | HVACTYPES.eManBin | HVACTYPES.eManBin.Auto, HVACTYPES.eManBin.ManOff, HVACTYPES.eManBin.ManOn | HVACTYPES.eManBin.Auto | Operating mode of the manual override - hardware for the enable                          |
| *eAO*      | HVACTYPES.eManNum | HVACTYPES.eManNum.Auto, HVACTYPES.eManNum.Man                             | HVACTYPES.eManNum.Auto | Operating mode of the manual override - hardware for the control signal                  |
| *rPoti*    | REAL              |                                                                           |                        | Manual value - manual override - hardware for the control signal                         |
| *rU*       | REAL              |                                                                           |                        | Feedback signal from the fan in %                                                        |
| *xQuit*    | BOOL              |                                                                           | FALSE                  | Reset of fault messages (monitorings) ( FALSE = Off, TRUE = On )                         |

#### Outputs

| Name                | Data type       | Value range | Initial value | Function                                                                                                   |
| ------------------- | --------------- | ----------- | ------------- | ---------------------------------------------------------------------------------------------------------- |
| *xHB*               | BOOL            |             |               | Enable - fan after manual override ( FALSE = Off, TRUE = On )                                              |
| *xAB*               | BOOL            |             |               | Enable - fan before manual override ( FALSE = Off, TRUE = On )                                             |
| *rHA*               | REAL            |             |               | Control signal - fan after manual override in %                                                            |
| *rAA*               | REAL            |             |               | Control signal - fan before manual override in %                                                           |
| *xAlarmFb*          | BOOL            |             |               | Fault message of the operational monitoring ( FALSE = Off, TRUE = On )                                     |
| *xAlarmPFb*         | BOOL            |             |               | Fault message of the air shortage monitoring ( FALSE = Off, TRUE = On )                                    |
| *dtLastFb*          | DATE\_AND\_TIME |             |               | Date/time of the fan’s last operation                                                                      |
| *udiOperatingHours* | UDINT           |             |               | Operating hours of the fan                                                                                 |
| *udiCountFb*        | UDINT           |             |               | Number of switch-ons of the fan                                                                            |
| *xAlarm*            | BOOL            |             |               | Collective fault indication ( FALSE = Off, TRUE = On )                                                     |
| *xAuto*             | BOOL            |             |               | Collective indication - automatic operation ( FALSE = no automatic operation, TRUE = automatic operation ) |

#### Setpoints / parameters

| Name                  | Data type | Value range                                 | Initial value | Function                                                                             |
| --------------------- | --------- | ------------------------------------------- | ------------- | ------------------------------------------------------------------------------------ |
| **udiPFbControlTime** | UDINT     | 0 … 3600s                                   | 60s           | Reporting delay of the air shortage monitoring in s                                  |
| **xPFbControl**       | BOOL      |                                             | TRUE          | Enable / disable of the air shortage monitoring ( FALSE = disabled, TRUE = enabled ) |
| **xAlarmControl**     | BOOL      |                                             | TRUE          | Influence of *xAlarm* on *xAB* ( FALSE = no influence, TRUE = lockout )              |
| **udiFbControlTime**  | UDINT     | 0 … 300s                                    | 60s           | Reporting delay of the operational monitoring in s                                   |
| **xFbControl**        | BOOL      |                                             | TRUE          | Enable / disable of the operational monitoring ( FALSE = disabled, TRUE = enabled )  |
| **rManValue**         | REAL      |                                             |               | Control signal in manual mode in %                                                   |
| **eManModeN**         | eManNum   | eManNum.Auto, eManNum.man                   | eManNum.Auto  | Operating mode of the manual override for the control signal *rHA*                   |
| **eManModeB**         | eMANBIN   | eMANBIN.Auto, eMANBIN.ManOff, eMANBIN.ManOn | eMANBIN.Auto  | Operating mode of the manual override for the digital output *xHB*                   |

### Function description

#### General

This function block controls a variable-speed fan by means of a continuous control signal *rHA*, which in automatic operation ( **eManModeN** = eManNum.Auto ) is taken unchanged from the input *rY* is adopted.\
The general enable of the fan is effected via the demand *xEn* and the enable signal *xHB*.\
Essentially the following function blocks are used:

ManBin

ManNum

AirShortage

CTime

OperatingHours

#### Enable - fan before manual override *xAB*

The enable - fan before manual override *xAB* is activated ( = TRUE ) if the following conditions are met at the same time:\
\
Case 1:\
\
\&#xNAN;*xEn* = TRUE\
\&#xNAN;*xMSwitch* = TRUE\
**xAlarmControl** = FALSE\
\
Case 2:\
\
\&#xNAN;*xEn* = TRUE\
\&#xNAN;*xMSwitch* = TRUE\
**xAlarmControl** = TRUE\
\&#xNAN;*xAlarm* = FALSE\
\
In all other situations the enable - fan before manual override is *xAB* is not activated ( = FALSE ).

#### Enable - fan after manual override *xHB*

The enable - fan after manual override *xHB* corresponds to the enable - fan before manual override *xAB*, additionally extended by a manual override module.\
The enable can generally only occur if the forced lockout of the fan after manual override is not active ( *xForce* = FALSE )\
and the collective fault indication is not active ( *xAlarm* = FALSE ).

| *xAB* | **eManModeB**  | *xHB* | Notes                                          |
| ----- | -------------- | ----- | ---------------------------------------------- |
| FALSE | eMANBIN.Auto   | FALSE | Manual override module in automatic            |
| TRUE  | eMANBIN.Auto   | TRUE  | Manual override module in automatic            |
| X     | eMANBIN.ManOn  | TRUE  | Manual override module in manual operation On  |
| X     | eMANBIN.ManOff | FALSE | Manual override module in manual operation Off |

Legend: X = don't care

#### Repair switch indication *xMSwitch*

*xMSwitch* = TRUE: repair switch not tripped (normal condition)\
\&#xNAN;*xMSwitch* = FALSE: repair switch tripped (fault condition)

#### Forced lockout of the fan after manual override *xForce*

*xForce* = FALSE: no forced lockout ( normal state )\
\&#xNAN;*xForce* = TRUE: forced lockout ( exceptional state )

#### Operating hours and switching operations

The number of operating hours and the switching operations are recorded (= counting process active) if the fan operating indication *xFb* is active and at the same time the general fault indication *xAlarm* is not active (= FALSE).\
The results are available at the counter outputs **udiOperatingHours** and **udiCountFb** available.

> **Write access to the counters**
>
> Via the path ‘InstanceName.\_OperatingHours.udiOperatingHours’ or ‘InstanceName.\_OperatingHours.udiCountFb’ a write access to both counter values is possible.\\
>
> **Prerequisite for the use of the FanAnalog function block**
>
> The use of the TimeRead2 function block is required for correct operation.

#### Date/time of the fan’s last operation *dtLastFb*

At the output *dtLastFb* the current date/time is available during the counting process.\
At the output *dtLastFb* the date/time at the end of the last counting process is available outside the counting process.\
At the output *dtLastFb* before the first counting process, the initialization value DT#1970-1-1-0.0.0 is output.

#### Operating monitoring

Operation monitoring can be enabled/disabled via the setpoint/parameter **xFbControl** enabled (= TRUE) or disabled (= FALSE).\
\
When monitoring is disabled, the operation monitoring fault indication *xAlarmFb* is always disabled (= FALSE).\
When monitoring is enabled, the operation monitoring fault indication *xAlarmFb* is activated (= TRUE) if simultaneously during a minimum time period **udiFbControlTime** the following states are present:\
\
\&#xNAN;*xHB* and *xFb* = unequal (enable state and operating state do not match)\
\&#xNAN;*eAOO* = HVACTYPES.eManBin.Auto ( manual override - hardware for the enable in automatic )\
**xFbControl** = TRUE (operation monitoring is enabled)\
\
The operation monitoring fault indication *xAlarmFb* is reset (= FALSE) if at least one of the following conditions is met:\
\
\&#xNAN;*eAOO* = HVACTYPES.eManBin.Auto (switching back to automatic operation of the manual override hardware)\
\&#xNAN;*xQuit* = TRUE ( reset of the monitorings is active )\
**xFbControl** = FALSE (operation monitoring disabled)

#### Air shortage monitoring

The air shortage monitoring is carried out by evaluating the states at the inputs *xPFb* or *xFb*.\
\
The fault message of the air shortage monitoring *xAlarmPFb* is activated ( = TRUE ) if with monitoring enabled ( **xPFbControl** = TRUE ) during the reporting delay of the air shortage monitoring **udiPFbControlTime** permanently the input *xPFb* is not active ( = FALSE ) and the\
input *xFb* is active ( = TRUE ).\
\
The fault message of the air shortage monitoring *xAlarmPFb* is deactivated ( = FALSE ) if the conditions for activation are no longer given and at the same time the monitoring is disabled ( **xPFbControl** = FALSE ) and / or the reset of the fault messages (monitorings) is active ( *xQuit* = TRUE ).

#### General fault indication *xAlarm*

The general fault indication is activated (= TRUE) if at least one of the conditions described below is met.\
\
\&#xNAN;*xAlarmIn* = TRUE (fan fault indication is active)\
\&#xNAN;*xAlarmFB* = TRUE (fault from operation monitoring)\
\&#xNAN;*xAlarmPFB* = TRUE (fault from air shortage monitoring)\
\&#xNAN;*xMSwitch* = FALSE ( repair switch in Off position )\
\
In all other cases the collective fault is not active ( = FALSE ).

#### Control signal fan before manual override *rAA*

The control signal of the fan before manual override *rAA* is taken unchanged from the input Control signal - speed *rY* if either the output *xHB* and / or the input *xFb* are active.\
In all other situations the control signal *rAA* is fixed to the value 0.0 %.

#### Control signal fan after manual override *rHA*

The control signal of the damper actuator after manual override *rHA* corresponds to the control signal of the fan before manual override *rAA* additionally extended by a manual override module.

| *rAA* | **eManModeN** | *rHA*         | Notes                                      |
| ----- | ------------- | ------------- | ------------------------------------------ |
| X     | eMANNUM.Auto  | *rAA*         | Manual override module in automatic        |
| X     | eMANNUM.Man   | **rManValue** | Manual override module in manual operation |

Legend: X = don't care

#### Collective automatic mode message *xAuto*

The collective automatic mode message *xAuto* is set active ( = TRUE ) if the following conditions are met simultaneously:\\

* Input *eAOO* = HVACTYPES.eManBin.Auto
* Input *eAO* = HVACTYPES.eManNum.Auto
* Setpoint / parameter **eManModeB** = eMANBIN.Auto
* Setpoint / parameter **eManModeN** = eMANNUM.Auto

### CODESYS

InOut:

| Scope       | Name                | Type    | Initial      |
| ----------- | ------------------- | ------- | ------------ |
| Input       | `xEn`               | `BOOL`  |              |
| Input       | `rY`                | `REAL`  |              |
| Input       | `xForce`            | `BOOL`  | FALSE        |
| Input       | `xFb`               | `BOOL`  |              |
| Input       | `xPFb`              | `BOOL`  |              |
| Input       | `xMSwitch`          | `BOOL`  | TRUE         |
| Input       | `xAlarmIn`          | `BOOL`  |              |
| Input       | `eAOO`              | eManBin | eManBin.Auto |
| Input       | `eAO`               | eManNum | eManNum.Auto |
| Input       | `rPoti`             | `REAL`  |              |
| Input       | `rU`                | `REAL`  |              |
| Input       | `xQuit`             | `BOOL`  | FALSE        |
| Output      | `xHB`               | `BOOL`  |              |
| Output      | `xAB`               | `BOOL`  |              |
| Output      | `rHA`               | `REAL`  |              |
| Output      | `rAA`               | `REAL`  |              |
| Output      | `xAlarmFb`          | `BOOL`  |              |
| Output      | `xAlarmPFb`         | `BOOL`  |              |
| Output      | `dtLastFb`          | `DT`    |              |
| Output      | `udiOperatingHours` | `UDINT` |              |
| Output      | `udiCountFb`        | `UDINT` |              |
| Output      | `xAlarm`            | `BOOL`  |              |
| Output      | `xAuto`             | `BOOL`  |              |
| Input Const | `udiPFbControlTime` | `UDINT` | 60           |
| Input Const | `xPFbControl`       | `BOOL`  | TRUE         |
| Input Const | `xAlarmControl`     | `BOOL`  | TRUE         |
| Input Const | `udiFbControlTime`  | `UDINT` | 60           |
| Input Const | `xFbControl`        | `BOOL`  | TRUE         |
| Input Const | `rManValue`         | `REAL`  |              |
| Input Const | `eManModeN`         | eMANNUM | eMANNUM.Auto |
| Input Const | `eManModeB`         | eMANBIN | eMANBIN.Auto |

Methods:

> mQuit

> mResetOperatingHours

Structure:

* mQuit (Method)
* mResetOperatingHours (Method)
