# FanControl

## `FanControl` (FB)

FUNCTION\_BLOCK FanControl

### Short description

> Control of a variable-speed fan (control variables e.g. absolute pressure, differential pressure)\
> Additional functions: manual overrides, repair switch, operating hours counter, operation monitoring, air shortage monitoring, limit value monitoring\
> Typical application: control of a fan with a frequency converter

### Representation

<figure><img src="/files/a640379d2382000cce5e6ecc2a5e1b0333923678" alt=""><figcaption></figcaption></figure>

### Function description

#### General

This function block controls a variable-speed fan using a continuous control signal *rHA*.\
The general enable of the fan is via the request *xEn* and the enable signal *xHB*.\
The speed control is performed using a freely parameterizable PI controller, to which the setpoint *rSetPoint* and the actual value *rActValue* are supplied and from which the controller's control signal is generated.\
\
The following function blocks are essentially used:

* ControlPI
* ManBin
* ManNum
* TwoPointFun
* Ramp
* CTime
* AirShortage
* OperatingHours

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

The release - 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).

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

The enable - fan after manual override *xHB* corresponds to the release - 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 aggregate fault message 2 is not active (= 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 = any

#### Maintenance switch indication *xMSwitch*

*xMSwitch* = TRUE: service switch was not triggered (normal condition)\
\&#xNAN;*xMSwitch* = FALSE: maintenance switch has been triggered (fault state)

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

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

#### Operating hours and switching cycles *udiOperatingHours* and *udiCountFb*

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

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

#### Date / time of the last operation of the fan *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* the initialization value DT#1970-1-1-0.0.0 is output before the first counting process.

#### Operating monitoring *xAlarmFb*

The operating monitoring can be enabled (= TRUE) or disabled (= FALSE) by the setpoint / parameter **xFbControl** When monitoring is disabled the operating monitoring fault indication *xAlarmFb* is always disabled (= FALSE).\
When monitoring is enabled the operating monitoring fault indication *xAlarmFb* is activated (= TRUE) if the following conditions are present simultaneously for a minimum duration **udiFbControlTime** the following conditions are given:\
\
\&#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 (operating monitoring is enabled)\
\
The operating monitoring fault indication *xAlarmFb* is reset (= FALSE) if at least one of the following conditions is met:\
\
\&#xNAN;*eAOO* = HVACTYPES.eManBin.Auto (reversion to automatic operation of the manual override - hardware)\
\&#xNAN;*xQuit* = TRUE (reset of the monitorings is active)\
**xFbControl** = FALSE (operating monitoring disabled)

#### Air shortage monitoring *xAlarmPFb*

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

#### Aggregate fault message 1 - output *xAlarm*

The collective fault indication is activated (= TRUE) if at least one of the following described conditions is fulfilled.\
\
\&#xNAN;*xAlarmIn* = TRUE (fault indication of the fan is active)\
\&#xNAN;*xAlarmFB* = TRUE (error from the operational monitoring)\
\&#xNAN;*xAlarmPFB* = TRUE (error from the air shortage monitoring)\
\&#xNAN;*xMSwitch* = FALSE (repair switch in Off position)\
\&#xNAN;*xAlarmMaxValue* = TRUE (maximum value exceeded)\
\&#xNAN;*xAlarmMinValue* = TRUE (minimum value undershot)\
\
In all other cases the aggregate fault is not active (= FALSE).

#### Aggregate fault message 2

The collective fault indication is activated (= TRUE) if at least one of the following described conditions is fulfilled.\
\
\&#xNAN;*xAlarmIn* = TRUE (fault indication of the fan is active)\
\&#xNAN;*xAlarmFB* = TRUE (error from the operational monitoring)\
\&#xNAN;*xAlarmPFB* = TRUE (error from the air shortage monitoring)\
\&#xNAN;*xMSwitch* = FALSE (repair switch in Off position)\
\&#xNAN;*xAlarmMaxValue* = TRUE (maximum value exceeded)\
\
In all other cases the aggregate fault is not active (= FALSE).

#### Resetting the fault messages *xQuit*

Any rising edge (FALSE > TRUE) at the input *xQuit* clears any existing fault messages of the following monitoring devices:\
\
Air shortage monitoring\
Operation monitoring\
Minimum value monitoring\
Maximum value monitoring

#### Control process

General\
\
The actual value rActValue is scaled by a linear characteristic and fed to the PI controller.\
The setpoint rSetPoint is filtered by a signal ramp, scaled by a linear characteristic defined by two points and fed to the PI controller.\
The output signal of the PI controller is filtered by another signal ramp and fed to the output for the control signal rHA.\
\
\
Enable\
\
The enable of the control process occurs with a time delay of udiWaitControl after the active operation indication of the fan (xFb = TRUE).\
The disabling of the control process occurs without time delay after the inactive operation indication of the fan (xFb = FALSE).\
\
\
Setpoint\
\
The setpoint is fixed to value 0.0 if the fan enable is not active (xHB = FALSE).\
The setpoint is taken from the input rSetPoint, filtered by a signal ramp and scaled by a linear function defined by 2 points (Prerequisite: xHB = TRUE).\
The relevant parameters of the signal ramp are individually configurable (Maximum variation = (rMaxValue / 5) per 10s).\
The relevant parameters of the linear function are individually configurable (input range in Pa: 0.0 - rMaxValue, output range in %: 0.0 - 100.0).\
\
\
Actual value\
\
The actual value is taken from the input rActValue and scaled by a linear function defined by 2 points.\
The relevant parameters of the linear function are individually configurable (input range in Pa: 0.0 - rMaxValue, output range in %: 0.0 - 100.0).\
\
\
Limitation of the PI controller control signal rYMin and rYMax\
\
The controller's control signal (PI controller) is limited by the adjustable limits rYMin and rYMax (minimum value monitoring not active) or rSubstitueHA (minimum value monitoring active).\
\
\
Signal ramp of the control signal from the PI controller\
\
The control signal from the PI controller is filtered by a signal ramp.\
The relevant parameters of the signal ramp are individually configurable (Maximum variation = rYRampVariation per rYRampTime).\
\
\
Parameters of the PI controller\
\
The parameters essential for control behavior can be specified from outside. They must be adapted depending on the control loop.\
A sensible basic parameterization has already been made, which is sufficient in many application cases.\
\
rYMin = lower absolute limit of the controller output signal\
rYMax = upper absolute limit of the controller output signal\
rOffset = setpoint offset - controller\
rKp = gain factor - controller\
rTn = reset time - controller in s\
eAction = action direction of the controller (Inverted, Direct)\
rInitValue = initialization value for the control signal\
rYDisabled = control signal when controller is inactive\
\
\
Signals of the PI controller\
\
The signals calculated during the control process (before the signal ramp) are available for monitoring the control process.\
\
rPiDiff = control deviation at the controller\
rPiPartP = proportional part of the control signal\
rPiPartI = integral part of the control signal\
xPiLimitActiv = status - limit exceeded - control signal (FALSE = Off, TRUE = On)\
\
\
Controller control signal\
\
If the controller is not enabled, the shutdown value rYDisabled is transferred to the controller control signal output (Prerequisite: ePiManModeN = eMANNUM.Auto) and limited by the absolute limits.\
The integral part is set to 0.0.\
\
If the controller is enabled, the controller control signal is calculated (Prerequisite: ePiManModeN = eMANNUM.Auto) and limited by the absolute limits.\
\
With the default setting of the action direction eAction (= eControlMode.Inverted), a too low actual value (actual value < setpoint) causes a continuous increase of the controller control signal value.

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

The control signal of the fan before manual override *rAA* is primarily taken from the controller output signal after the signal ramp.\
However, this output signal is additionally limited downward during the fan request (*xHB = TRUE) by the lower absolute limit rYMin* downwards.\
In the event of a minimum value undershoot (*xAlarmMinValue* = TRUE) the control signal before manual override *rAA* is replaced by the fixed value **rSubstitueHA** .

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

The fan control signal 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   | **eManValue** | Manual override module in manual operation |

Legend: X = any

#### Operating mode for the controller output signal **ePIManModeN**

The parameter **ePiManModeN** allows switching the controller output signal from automatic to manual mode and vice versa.\
In manual mode the controller output signal takes over the manual mode output signal **ePiManValue**.

| **ePiManModeN** | output signal                                | Function                       |
| --------------- | -------------------------------------------- | ------------------------------ |
| eMANNUM.Auto    | signal according to formula / disabled value | Automatic mode - output signal |
| eMANNUM.Man     | **ePiManValue**                              | Manual mode - output signal    |

#### Maximum pressure monitoring *xAlarmMaxValue*

The output *xAlarmMaxValue* is activated (= TRUE) if the current actual value *rActValue* exceeds the adjustable maximum value **rMaxValue** .\
The output *xAlarmMaxValue* is deactivated (= FALSE) if the current actual value *rActValue* exceeds the adjustable maximum value **rMaxValue** falls below and at the same time a rising edge (FALSE > TRUE) is detected at the input *xQuit* .

#### Minimum pressure monitoring *xAlarmMinValue*

The output *xAlarmMinValue* is activated (= TRUE) if for a minimum duration **udiWaitMinValue** (1.0 - 600.0 s) the following conditions are permanently met at the same time:\
\
\&#xNAN;*xFb* = TRUE (fan is in operation)\
\&#xNAN;*eAO* = HVACTYPES.eManNum.Auto (mode of the manual override - hardware for the control signal in automatic mode)\
\&#xNAN;*rHA* > **rMinHAValue** (control signal is greater than the minimum value)\
\&#xNAN;*rActValue* < **rMinValue** (actual value is smaller than the minimum value)\
No rising edge (FALSE > TRUE) was detected at the input *xQuit* recognized\
The output *xAlarmMinValue* is deactivated (= FALSE) if the conditions for activation are no longer met and at the same time at the input *xQuit* .

#### Collective automatic-mode message *xAuto*

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

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

### CODESYS

InOut:

| Scope       | Name                | Type         | Initial               |
| ----------- | ------------------- | ------------ | --------------------- |
| Input       | `xEn`               | `BOOL`       |                       |
| 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                 |
| Input       | `rActValue`         | `REAL`       |                       |
| Input       | `rSetPoint`         | `REAL`       |                       |
| Output      | `xHB`               | `BOOL`       |                       |
| Output      | `xAB`               | `BOOL`       |                       |
| Output      | `rHA`               | `REAL`       |                       |
| Output      | `rAA`               | `REAL`       |                       |
| Output      | `xAlarmFb`          | `BOOL`       |                       |
| Output      | `xAlarmPFb`         | `BOOL`       |                       |
| Output      | `xAlarmMinValue`    | `BOOL`       |                       |
| Output      | `xAlarmMaxValue`    | `BOOL`       |                       |
| Output      | `dtLastFb`          | `DT`         |                       |
| Output      | `udiOperatingHours` | `UDINT`      |                       |
| Output      | `udiCountFb`        | `UDINT`      |                       |
| Output      | `xAlarm`            | `BOOL`       |                       |
| Output      | `xAuto`             | `BOOL`       |                       |
| Output      | `rPiDiff`           | `REAL`       |                       |
| Output      | `rPiPartP`          | `REAL`       |                       |
| Output      | `rPiPartI`          | `REAL`       |                       |
| Output      | `xPiLimitActiv`     | `BOOL`       |                       |
| Input Const | `rMaxValue`         | `REAL`       | 490                   |
| Input Const | `rSubstituteHA`     | `REAL`       | 30                    |
| Input Const | `udiWaitMinValue`   | `UDINT`      | 60                    |
| Input Const | `rMinHAValue`       | `REAL`       | 20                    |
| Input Const | `rMinValue`         | `REAL`       | 20                    |
| Input Const | `tYRampTime`        | `TIME`       | TIME#1m0s0ms          |
| Input Const | `rYRampVariation`   | `REAL`       | 30                    |
| Input Const | `udiWaitControl`    | `UDINT`      | 30                    |
| Input Const | `rYMax`             | `REAL`       | 100                   |
| Input Const | `rYMin`             | `REAL`       | 20                    |
| Input Const | `rTn`               | `REAL`       | 60                    |
| Input Const | `rKp`               | `REAL`       | 1                     |
| Input Const | `rOffset`           | `REAL`       | 0                     |
| Input Const | `rInitValue`        | `REAL`       | 20                    |
| Input Const | `rYDisabled`        | `REAL`       | 0                     |
| Input Const | `eAction`           | eControlMode | eControlMode.Inverted |
| Input Const | `ePiManValue`       | `REAL`       |                       |
| Input Const | `ePiManModeN`       | eMANNUM      | eMANNUM.Auto          |
| 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.powerio.com/hub/codesys-hvac/en/hvac-library/functionblocks/components/fancontrol.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
