Supported platforms: CODESYS 2.3
This function block controls current controlled proportional valves. PVC_AdaptiveController is a more versatile alternative for standard PI-controller PVC_PI_Controller (which is used by PVC_CurrentValvePairController and PVC_SingleCurrentValveController). PVC_AdaptiveController gives more possibilities to adjust the behavior of output PWM ratio which in turn effects the electric current in valve coil. The usage of adaptive controller is recommended especially when a quick response for current request is required.
PVC_CurrentValvePair or PVC_SingleCurrentValve can be used together with PVC_AdaptiveController to get ramp or end attenuation functionalities. See the code example below. |
See the following chapters for more information about function block's normal operation and adjusting controller parameters.
PVC_AdaptiveController is in normal operation mode if:
• The control is enabled, i.e. i_Enable is TRUE AND
• The input parameters are valid and the inputs are inside in allowed limits AND
• Overcurrent or wire broken situation is not detected AND
In normal operation the function block adjusts the output o_PWMRatio so that the measured current i_CurrentMeasured achieves the requested current i_CurrentRequest. The measured current should achieve the request current as fast as possible.
The output PWM ratio is calculated from equation 1 (Ohm’s law)
, where RBasis is the base value for resistance
, where
CorrectionFactorArr[index] is the correction factor from array defined in application,
index = i_CurrentRequest / i_ParStep, and
CORRECTION_SCALING = 1000
, RPI is the PI-controller
, where
CurrentError = OldCurrentRequest-i_MeasuredCurrent, and
Integrator = PI-controller integrator term
, RImp is the startup impulse
Positive direction:
Negative direction:
, where
TargetCurrentChange = i_CurrentRequest-OldCurrentRequest,
ImpulseFactor[Index] = Impulse up/down factor from array defined in application,
CurrentErrorPosImp = i_CurrentRequest-i_CurrentMeasured and
CurrentErrorNegImp = i_CurrentMeasured-i_CurrentRequest
, Feedforward term RFF
, where fffactor= 0.018
The following figure shows the current request, measured current and PWM ratio as a function of time.
The function block includes a startup impulse feature for faster achievement of the target current. The startup impulse has two different modes: automatic and manual mode. Depending on the selected mode, PWM output is momentarily bigger until either the given time is exceeded (manual mode) or the measured current rises enough (automatic mode). The used mode is defined by an input i_AutomaticStartImpulse.
Manual mode:
In manual mode the input parameter i_StartImpulseTime defines the startup pulse length.
Automatic mode:
In automatic mode the startup pulse is stopped when the measured current is increased enough.
If the current request changes from 0 mA to some current (more than i_ParStep) then the measured current needs to be half (library internal constant) of the target current until the pulse is stopped. In figure above, the request current changes from 0 mA to 700 mA so the measured current needs to be 350 mA until the pulse is stopped.
If the current request changes from positive current to some other bigger current (more than i_ParStep) then the measured current needs to increase 1/8 (library internal constant) from the difference of the new current request and the measured current in start point.
For example, if the request current changes from 200 mA to 600 mA and the measured current is 190 mA when the request current change occurs --> the measured current needs to be 251 mA ((600mA-190mA)/8) until the pulse is stopped.
The PI controller is activated when current error is small (≤ i_ParStep/2) or if the target current is not reached quick enough.
The input parameter i_CurrentChangeSpeed [mA/ms] defines how quick the measured current should change. For example,
if the target current changes from 0 mA to 700 mA and i_CurrentChangeSpeed = 5 then
the PI controller is activated if current error > i_ParStep/2 when 140 ms is elapsed since target current change
The PI controller is deactivated when a new start-up pulse is started.
The output o_PWMRatio is set to 0 and corresponding error bit is set on:
• i_CurrentRequest > 5000 OR
• i_SupplyVoltMeasured ≤ 0 OR
• Output wire broken or overcurrent situation detected OR
• The input parameters are invalid OR
The output wire broken situation is detected when current request is active (i_WireBrokenLimit ≤ i_CurrentRequest) and the measured current is below i_WireBrokenLimit over diagnostic delay time i_DiagnosticDelay.
The overcurrent situation is detected when the measured current is above i_OverCurrentLimit during diagnostic delay time i_DiagnosticDelay.
The output o_PWMRatio is set to 0 immediately if:
• i_Enable is FALSE
The error bits are not reset before the rising edge of i_Enable input.
For accurate parameter adjusting it is recommended to utilize some CAN bus diagnostic tool, which gives the possibility to monitor graphically CAN signals. The monitored signals are
o_PWMRatio
These signals should be transmitted to CAN bus as short transmission period as possible (for example, 10 ms) to get a good understanding how the different parameters affect to o_PWMRatio and i_CurrentMeasured.
The examples in following sections assumes that
i_ParameterCount = 20
meaning that i_pCorrectionParameters, i_pImpulseUpParameters and i_pImpulseDownParameters arrays has 20 indexes
i_ParStep = 50
meaning that the first index value in arrays corresponds the current value 50 mA, the second value corresponds the current value 100 mA, ..., the last index value corresponds the current value 1000 mA
Rough instructions for adjusting PI controller's P and I terms:
Set i_PI_I = 1
Increase i_PI_P value (and test with different current requests) until current starts to oscillate. After that decrease i_PI_P value a few digits
Increase i_PI_I value (and test with different current requests) until current starts to oscillate. After that decrease i_PI_I value a few digits
The correction parameters i_pCorrectionParameters are used to calculate the basis value to o_PWMRatio. The idea is that with correction parameters the o_PWMRatio value is set immediately close to the "correct" value and the PI controller is only used to fix the minor residual current error.
The following example graph shows how to adjust the correction factor value to correspond to current request 400 mA.
Set i_CurrentChangeSpeed = 0 in order PI controller is not activated
Set i_UseImpulse = FALSE in order start impulse is not in use
Set i_CurrentRequest = 400 mA
Analyze graph to decide if correction factor value should be modified
In many applications it is enough adjust just the correction parameter which corresponds the minimum current and copy that value to all indexes in correction parameter array.
|
The input i_CurrentChangeSpeed is used to define the time delay before PI controller is activated. i_CurrentChangeSpeed affects always when the change of i_CurrentRequest is more than i_ParStep between 2 consecutive PVC_AdaptiveController function block instance calls. Typically this situation occurs only in the beginning of movement when current request changes from 0 mA to minimum current.
The following graph shows how to adjust the current change speed. The current request i_CurrentRequest changes from 0 mA to 400 mA. i_CurrentChangeSpeed value 20 mA /ms is too big so PI controller is activated too quickly.
The input i_pImpulseUpParameters is used to define the startup impulse to o_PWMRatio which will cause that current increases more quickly. i_pImpulseUpParameters affects always when the change of i_CurrentRequest is more than i_ParStep between 2 consecutive PVC_AdaptiveController FB instance calls. Typically this situation occurs only in the beginning of movement when current request changes from 0 mA to minimum current. Note that i_UseImpulse needs to be true that startup impulse is used.
The following graph shows how to adjust impulse up parameters. i_CurrentRequest changes from 0 mA to 400 mA.
Set i_UseImpulse = TRUE in order start impulse is in use
Set i_AutomaticStartImpulse = TRUE in order startup impulse length is automatically defined
In many applications it is enough adjust just the impulse up parameter which corresponds the minimum current and the rest of indexes in impulse up parameter array can be ignored.
|
The input i_pImpulseDownParameters is used to define the downward impulse to o_PWMRatio which will cause that current decreases more quickly. i_pImpulseDownParameters affects always when the change (decrease) of i_CurrentRequest is more than i_ParStep between 2 consecutive PVC_AdaptiveController FB instance calls. In many typical applications this do not occur ever so impulse down parameters can be ignored. Note that i_UseImpulse needs to be true that downward impulse is used.
The following graph shows how to adjust impulse down parameters. i_CurrentRequest changes from 700 mA to 500 mA.
Set i_UseImpulse = TRUE in order start impulse is in use
Set i_AutomaticStartImpulse = TRUE in order startup impulse length is automatically defined
In many applications the values in impulse down parameter array can be ignored. However, the impulse down array needs always to be defined and given to the PVC_AdaptiveController as a input.
|
A parameter error is diagnosed if:
|
Parameter automatic learning (i_LearnOn) is not supported. |
Input variable name |
Data type |
Unit |
Range |
Description |
i_Enable |
BOOL |
- |
- |
Enable POU operation. |
i_CurrentRequest |
UINT |
mA |
0 - 5000 |
Requested current value. |
i_CurrentMeasured |
DWORD |
mA |
0 - i_OverCurrentLimit |
Measured current value. |
i_SupplyVoltMeasured |
UINT |
Hardware specific |
> 0 |
Measured supply voltage with two decimals, 2400=24,00V |
i_CoilResistance |
UDINT |
mΩ |
> 0 |
Coil resistance. |
i_OverCurrentLimit |
UINT |
mA |
> i_Wire BrokenLimit and <= 5000 |
Over current error limit. |
i_WireBrokenLimit |
UINT |
mA |
0-5000 |
Wire broken error limit. |
i_DiagnosticDelay |
UINT |
ms |
- |
Diagnostic delay for overcurrent/wire broken errors. |
i_pCorrectionParameters |
POINTER TO UINT |
- |
≠ 0 |
Pointer to array which contains correction factor parameters. |
i_pImpulseUpParameters |
POINTER TO UINT |
- |
≠ 0 |
Pointer to array which contains impulse up parameters. |
i_pImpulseDownParameters |
POINTER TO UINT |
- |
≠ 0 |
Pointer to array which contains impulse down parameters. |
i_ParameterCount |
UINT |
- |
- |
Correction parameters array length. Impulse up and down arrays should be same size. |
i_ParStep |
UINT |
mA |
- |
Difference between adjacent points in correction factor array (and also impulse arrays). |
i_CurrentChangeSpeed |
UINT |
mA/ms |
- |
Current change speed. |
i_UseImpulse |
BOOL |
- |
- |
Startup impulse in use. |
i_PI_P |
UDINT |
- |
- |
PI controller P-value. |
i_PI_I |
UDINT |
- |
- |
PI controller I-value with two decimals, 1=0,01 |
i_LearnOn |
BOOL |
- |
- |
Learning is active. Note! NOT SUPPORTED |
i_StartImpulseTime |
UINT |
ms |
- |
How long start impulse is active. Parameter affects only if i_AutomaticStartImpulse is FALSE and i_UseImpulse is TRUE. |
i_AutomaticStartImpulse |
BOOL |
- |
-
|
TRUE: startup pulse length is automatically defined. FALSE: Parameter i_StartImpulseTime defines startup pulse length. Parameter affects only if i_UseImpulse is TRUE. |
Output variable name |
Data type |
Range |
Description |
o_PWMRatio |
DWORD |
0 - HW specific |
Control value to PWM output. |
o_ParameterError |
BOOL |
- |
Parameter error |
o_OverCurrentError |
BOOL |
- |
Overcurrent error is detected |
o_WireBrokenError |
BOOL |
- |
Wire broken error is detected |
o_PI_I_TermError |
BOOL |
- |
PI-controller I-term has reached it's limits |
Conditions |
o_PWMRatio |
o_Parameter Error |
o_OverCurrent Error |
o_WireBroken Error |
o_PI_I_TermError |
i_Enable = TRUE AND parameters ok AND i_CurrentMeasured within given error limits |
PWM ratio |
FALSE |
FALSE |
FALSE |
FALSE |
i_Enable TRUE AND i_SupplyVoltMeasured = 0 |
0 |
TRUE |
FALSE |
FALSE |
FALSE |
i_Enable TRUE AND i_CurrentRequest > 5000 |
0 |
TRUE |
FALSE |
FALSE |
FALSE |
i_Enable TRUE AND parameters ok AND i_CurrentMeasured > i_OverCurrentLimit |
0 (After diagnostic delay) |
FALSE |
TRUE (After diagnostic delay) |
FALSE |
FALSE |
i_Enable TRUE AND parameters ok AND i_CurrentRequest > 0 AND i_CurrentMeasured < i_WireBrokenLimit |
0 (After diagnostic delay) |
FALSE |
FALSE |
TRUE (After diagnostic delay) |
FALSE |
i_Enable TRUE AND parameters ok AND PI controller internal integrator term out of limits (-50000 - 50000) (Integrator term value is limited) |
PWM ratio |
FALSE |
FALSE |
FALSE |
TRUE (Output is set true when the POU's internal integrator term limit is reached. The input i_DiagnosticDelay do not have an effect on this output) |
Parker valve 22 Ω
(*Parker valve default values to code*)
(*Correction factors*)
(*50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 mA*)
ccParams:ARRAY [1..20] OF UINT := [ 1359,1307,1231,1172,1137,1113,1103,1093,1088,1076,1075,1075,1075,1078,1076,1075,1034,1014,1014,1014];
(*Impulse up factors*)
(*50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 mA*)
ccParamsImpUp: ARRAY [1..20] OF UINT := [ 1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,950,950,950,950,950,950,950,950,950,950];
*Impulse down factors*)
(*50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 850 900 950 1000 mA*)
ccParamsImpDown:ARRAY [1..20] OF UINT:= [ 1200,1200,1100,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000];
Hydraforce 29 Ω
(*Correction factors*)
(*50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 mA*)
ccParams:ARRAY [1..16] OF UINT := [ 1230,1230,1190,1080,1070,1010,1010,1010,1010,1010,1010,1010,1010,1010,1010,1010];
(*Impulse up factors*)
(*50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 mA*)
ccParamsImpUp: ARRAY [1..16] OF UINT := [ 1000,1000,1000, 950, 950,950,950,950, 950,950, 950,950,950,950,950, 950];
*Impulse down factors*)
(*50 100 150 200 250 300 350 400 450 500 550 600 650 700 750 800 mA*)
ccParamsImpDown:ARRAY [1..16] OF UINT:= [ 1200,1200,1100,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000,1000];
Parameters:
VAR_GLOBAL
PAR_BoomAdaptiveCntr: BoomAdaptiveCntr;
PAR_CorrectionFactors: ARRAY[1..20] OF UINT:= 1359, 1307, 1231, 1172, 1137, 1113, 1103, 1093, 1088, 1076, 3(1075), 1078, 1076, 1075, 1034, 3(1014);
PAR_ImpulseUpFactors: ARRAY[1..20] OF UINT:= 10(1000), 10(950);
PAR_ImpulseDownFactors:ARRAY[1..20] OF UINT:= 20(1000);
END_VAR
Local variables:
VAR
boomControlEnabled: BOOL;
boomValvePair: PVC_CurrentValvePair;
boomUpController: PVC_AdaptiveController;
END_VAR
Source file topic100532.htm
Last updated 21-Feb-2025