Object ‘Unit conversion’¶
Symbol
A Unit conversion object is used to define a conversion rule. The following table lists all defined conversion rules. You can edit a conversion rule in the input fields listed below the table.
Table of conversion rules
Name | <name> : <name>_Impl is the name of the conversion rule. CODESYS automatically implements the entry as a function block <name>_Impl and instances it as <name> . |
Type | Type of conversion rule
|
Setting | Displays the configured conversion rule. |
Condition |
|
Condition setting | If you select TRUE as the Condition, then the field is hidden. If you configure Language as the Condition, then the field shows the current configuration, for example If you select Variable as the Condition, then the field shows the current configuration, for example You can edit the current condition setting below the table in the input fields for Condition setting. |
Input field ‘Single scaling (offset)’
The input variable is added with an offset.
Offset |
|
Input field ‘Single scaling (factor)’
The input variable is multiplied by the factor.
Factor |
|
Input field ‘Linear scaling 1 (factor and offset)’
The input variable is converted with the linear equation defined below.
Factor |
|
Offset |
|
Input field ‘Linear scaling 2 (Base and target range)’
The input variable is converted to be within a target range. CODESYS internally creates a linear equation from the following input values.
Base start value | Lowest possible value for the input variable.
|
Base end value | Highest possible value for the input variable.
|
Target start value | Lowest possible value for the output variable.
|
Target end value | Highest possible value for the output variable.
|
Example
Conversion of electric current from a 10-bit input signal to an amperage range of 4-20 mA
Base start value | 0 |
Base end value | 1024 |
Target start value | 4.0 |
Target end value | 20.0 |
Input field ‘User defined conversion’
Convert := | Conversion rule as mathematical function of rValue The input variable is rValue . |
Reverse := | Reverse function of the function defined in Convert |
Input field ‘Switchable conversion’
Use this conversion rule when you want to apply a conversion that is language-specific or variable-dependent.
Switchable conversion name | Selected from a list of predefined conversion rules. Double-click directly into the field for editing. |
Bedingungseinstellung | Configured condition. Click into the input fields in Condition setting to edit the condition. |
Example
The Conv_A_LanguageDependent
conversion rule that defines which conversion rule is executed for the English or German language.
Name | Type | Setting | Condition | Condition setting |
---|---|---|---|---|
Conv_A_LanguageDependent |
Switchable conversion | Conv_AInInch, Conv_AInMM |
Language |
Switchable conversion name | Condition setting |
---|---|
Conv_AInInch |
en |
Conv_AInMM |
de |
See also