- Atomic functions catalog >
- core.cont.pid
core.cont.pid¶
Inputs¶
Name |
Type |
Title |
Mandatory |
Description |
---|---|---|---|---|
input |
core.type.f64 |
Input |
True |
None |
feedback |
core.type.f64 |
Feedback |
True |
None |
enable |
core.type.bool |
Enable |
False |
None |
preset |
core.type.f64 |
Preset source |
False |
Used to preset integral part at the moment of the PID enabling |
Outputs¶
Name |
Type |
Title |
Description |
---|---|---|---|
output |
core.type.f64 |
Output |
None |
enabled |
core.type.bool |
Enabled |
None |
Parameters¶
Name |
Type |
Title |
Mandatory |
Default value |
Description |
---|---|---|---|---|---|
Kp |
core.type.f64 |
Proportional coefficient |
False |
1 |
None |
Ki |
core.type.f64 |
Integral coefficient |
False |
0 |
None |
Kd |
core.type.f64 |
Derivative coefficient |
False |
0 |
None |
integral_min |
core.type.f64 |
Lower bound of integral part of error |
False |
0 |
None |
integral_max |
core.type.f64 |
Upper bound of integral part of error |
False |
1 |
None |
output_min |
core.type.f64 |
Lower bound of controller output |
False |
0 |
None |
output_max |
core.type.f64 |
Upper bound of controller output |
False |
1 |
None |
State variables¶
Name |
Type |
Title |
Description |
---|---|---|---|
integral |
core.type.f64 |
Accumulated Integral term |
None |
previous_error |
core.type.f64 |
Previous error |
None |
time_from_last_iteration |
core.type.f64 |
Time from last iteration |
None |
activated |
core.type.bool |
PID was activated before by enable signal |
None |
Usage XML code snippet¶
<f name="pid" by_spec="core.cont.pid">
<in alias="input">some_block_1/output</in>
<in alias="feedback">some_block_2/output</in>
<in alias="enable">some_block_3/output</in> <!-- optional -->
<in alias="preset">some_block_4/output</in> <!-- optional -->
<param alias="Kp">0.0</param> <!-- optional -->
<param alias="Ki">0.0</param> <!-- optional -->
<param alias="Kd">0.0</param> <!-- optional -->
<param alias="integral_min">0.0</param> <!-- optional -->
<param alias="integral_max">0.0</param> <!-- optional -->
<param alias="output_min">0.0</param> <!-- optional -->
<param alias="output_max">0.0</param> <!-- optional -->
</f>
Function’s artifacts¶
- Declaration for core_cont_pid
- Implementation for core_cont_pid
- Set parameters code for core_cont_pid
- Header of core_cont_pid
- Specification of core_cont_pid
- Other
from fspeclib import *
Function(
name='core.cont.pid',
title=LocalizedString(
en='PID controller'
),
parameters=[
Parameter(
name='Kp',
title='Proportional coefficient',
value_type='core.type.f64',
tunable=True,
default=1,
constraints=[
ThisValue() >= 0
]
),
Parameter(
name='Ki',
title='Integral coefficient',
value_type='core.type.f64',
tunable=True,
default=0,
constraints=[
ThisValue() >= 0
]
),
Parameter(
name='Kd',
title='Derivative coefficient',
value_type='core.type.f64',
tunable=True,
default=0,
constraints=[
ThisValue() >= 0
]
),
Parameter(
name='integral_min',
title='Lower bound of integral part of error',
value_type='core.type.f64',
tunable=True,
default=0,
constraints=[
ThisValue() <= 0
]
),
Parameter(
name='integral_max',
title='Upper bound of integral part of error',
value_type='core.type.f64',
tunable=True,
default=1,
constraints=[
ThisValue() >= 0
]
),
Parameter(
name='output_min',
title='Lower bound of controller output',
value_type='core.type.f64',
tunable=True,
default=0,
constraints=[
ThisValue() <= 0
]
),
Parameter(
name='output_max',
title='Upper bound of controller output',
value_type='core.type.f64',
tunable=True,
default=1,
constraints=[
ThisValue() >= 0,
]
),
],
inputs=[
Input(
name='input',
title='Input',
value_type='core.type.f64'
),
Input(
name='feedback',
title='Feedback',
value_type='core.type.f64'
),
Input(
name='enable',
title='Enable',
value_type='core.type.bool',
mandatory=False
),
Input(
name='preset',
title='Preset source',
description='Used to preset integral part at the moment of the PID enabling',
value_type='core.type.f64',
mandatory=False
),
],
outputs=[
Output(
name='output',
title='Output',
value_type='core.type.f64'
),
Output(
name='enabled',
title='Enabled',
value_type='core.type.bool',
)
],
state=[
Variable(
name='integral',
title='Accumulated Integral term',
value_type='core.type.f64'
),
Variable(
name='previous_error',
title='Previous error',
value_type='core.type.f64'
),
Variable(
name='time_from_last_iteration',
title='Time from last iteration',
value_type='core.type.f64'
),
Variable(
name='activated',
title='PID was activated before by enable signal',
value_type='core.type.bool'
)
],
parameter_constraints=[
ParameterValue('output_max') > ParameterValue('output_min'),
ParameterValue('integral_max') > ParameterValue('integral_min')
],
injection=Injection(
timedelta=True
)
)