Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY, CODESYS 3.5 SP19 SAFETY

 

S_PVGValveController (FB)

Description

This function block controls Danfoss PVG32 voltage controlled proportional valves.

 

Initialization

Init method is used to initialize the necessary static calculation parameters for the function block instance.

The method shall be called at least once before the actual function block can be called, i.e. at the application initialization phase.

The method checks the validity of input parameters. However, none of the function block outputs are affected by the initialization.

 

 

A parameter error is diagnosed if:

  • Init method is not called before the main FB call OR

  • i_pEventCode = 0 OR

  • i_pEventCodePVGError = 0 OR

  • S_i_PosDirMaxPWMLevel out of range OR

  • S_i_PosDirMinPWMLevel out of range OR

  • S_i_CenterPositionPWMLevel out of range OR

  • S_i_NegDirMinPWMLevel out of range OR

  • S_i_NegDirMaxPWMLevel out of range

 

 

Initialization parameters

Parameter

Type

Unit

Range

Description

S_i_PosDirMaxPWMLevel

SAFEUINT

0 - 1000

Defines PWM ratio when S_i_Control = 10000

S_i_PosDirMinPWMLevel

SAFEUINT

0 - S_i_PosDirMaxPWMLevel

Defines PWM ratio when S_i_Control = 1

S_i_CenterPositionPWMLevel

SAFEUINT

0 - S_i_PosDirMinPWMLevel

Defines PWM ratio when S_i_Control = 0

S_i_NegDirMinPWMLevel

SAFEUINT

0 - S_i_CenterPositionPWMLevel

Defines PWM ratio when S_i_Control = -1

S_i_NegDirMaxPWMLevel

SAFEUINT

0 - S_i_NegDirMinPWMLevel

Defines PWM ratio when S_i_Control = -10000

S_i_PosDirAscendRampTime

SAFEUINT

ms

-

Defines time how long it takes from ramped signal to change from center to max (0 to 10000).

S_i_PosDirDescendRampTime

SAFEUINT

ms

-

Defines time how long it takes from ramped signal to change from max to center (10000 to 0)

S_i_NegDirAscendRampTime

SAFEUINT

ms

-

Defines time how long it takes from ramped signal to change from center to negative max (0 to -10000 )

S_i_NegDirDescendRampTime

SAFEUINT

ms

-

Defines time how long it takes from ramped signal to change from negative max to center (-10000 to 0 )

S_i_PVGPullUpResistor

SAFEUDINT

Ω

-

PVG valve pull up resistor

S_i_PVGPullDownResistor

SAFEUDINT

Ω

-

PVG valve pull down resistor

S_i_PinPullUpResistor

SAFEUDINT

Ω

-

Control unit pin pull up resistor

S_i_PinPullDownResistor

SAFEUDINT

Ω

-

Control unit pin pull down resistor

S_i_DiagnosticDelay

SAFEUINT

ms

-

Diagnostic delay for PVG valve error signal.

i_pEventCode

POINTER TO EventCode

-

≠ 0

Pointer to application variable where event code is stored.

i_pEventCodePVGError

POINTER TO EventCode

-

≠ 0

Pointer to application variable where event code is stored.

 

Initialization method return value

TRUE: All initialization parameters ok.

FALSE: Error in initialization parameter(s).

 

Operation

POU is in normal operation mode if:

• The control is enabled, i.e. i_Enable is TRUE AND

• The input parameters are valid and the input S_i_Control is inside its allowed limits AND

• Startup error is not detected AND

• PVG valve error is not activated

 

In normal operation the POU first ramp the input control value based on the given acceleration and deceleration parameters and the measured application cycle time.

 

The ramped value is scaled to output PWM ratio by using compensated PWM level parameters.

When the ramped value is 0 then the output o_PWMRatio is set to compensated center position value.

When the ramped value > 0 then o_PWMRatio is scaled to between compensated positive direction minimum and maximum level values.

When the ramped value < 0 then o_PWMRatio is scaled to between Compensated negative direction minimum and maximum level values.

The PWM level parameters are given as per mil from PWM maximum value G_PWM_OUT_MAXVALUE.

The constant G_PWM_OUT_MAXVALUE is HW dependent and it is defined in HW specific int library.

 

In normal operation the output o_ValveSupply is also set TRUE.

 

Operation in fault situations

The output o_PWMRatioControl is set to 0, o_ValveSupply and o_Status.OutputValid are set false, corresponding error bit is set in o_Status and corresponding EventID value is set to EventCode if:

S_i_Control exceeds the allowed limits -10000- (+)10000 OR

• Input parameter i_pEventCode = 0 OR

• Input parameter i_pEventCodePVG = 0 OR

• PWM parameters exceeds the allowed limits or are not in consistent order OR

• compensated PWM level parameters exceed the allowed limits or are not in consistent order OR

• Startup error is detected i.e. S_i_Control ≠ 0 when i_Enable rises OR

• the PVG error signal is active for the diagnostic delay time

The output o_PWMRatioControl is set to 0, o_Status.OutputValid is set to false immediately if:

i_Enable is FALSE

• A parameter error occurred.

 

The o_Status error bits and EventCode error are not reset before the rising edge of i_Enable input.

 

Inputs

Input variable name

Data type

Unit

Range

Description

i_Enable

BOOL

-

-

Enable POU operation.

S_i_Control

SAFEINT

-

-10000 -

 (+) 10000

Control value.

S_i_PVGError

SAFEBOOL

-

-

Error signal from PVG valve

Outputs

Output variable name

Data type

Range

Description

o_ValveSupply

BOOL

-

Valve supply output

o_PWMRatio

DWORD

0 - G_PWM_OUT_MAX_VALUE

Control value to PWM output.

o_Status

Status

-

Status of output value. See Status structure.

Error diagnostic

See Diagnostic Interface library description of error status and event code functionality.

 

Conditions

o_PWM Ratio

o_Valve Supply

o_Status. OutputValid

o_Status error status

Event code FunctionID

Event code EventID

i_Enable TRUE

AND

init parameter error AND
i_pEventCode NULL

0

FALSE

FALSE

ParameterError

-

-

i_Enable TRUE &

Parameter error (i_pEventCode ≠ 0)

0

FALSE

FALSE

ParameterError

PVG_CONTROLLER

PARAMETER_ERROR

i_Enable TRUE AND

init parameters ok AND

S_i_Control in normal area (-10000- (+)10000)

PWM ratio

TRUE

TRUE

-

NO_FUNC  

NO_ERROR

i_Enable TRUE AND

init parameters ok AND

S_i_Control > 10000  

0

FALSE

FALSE

InputHigh

PVG_CONTROLLER

 INPUT_TOO_HIGH

i_Enable TRUE AND

init parameters ok AND

S_i_Control < -10000

0

FALSE

FALSE

InputLow

PVG_CONTROLLER

 INPUT_TOO_LOW

i_Enable TRUE AND

init parameters ok AND

S_i_Control in normal area (-10000- (+)10000)  AND

S_i_PVGError TRUE

0

FALSE

FALSE

PVGValveError

PVG_CONTROLLER

PVG_VALVE_ERROR

 

See also

 

 

 

 

Source file topic100402.htm

Last updated 21-Feb-2025