Jump to content

Component: Map Function (Calculation): Difference between revisions

From Flowcode Help
No edit summary
m Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead""
 
(11 intermediate revisions by 3 users not shown)
Line 14: Line 14:
==Map Function component==
==Map Function component==
The map function is intended to change one range of values into another range of values.  For example. Output from a temperature sensor is in centigrade. you can map it to give the result in Fahrenheit. To do that set: InMin to 0, InMax 100, OutMin to 32 & OutMax to 212
The map function is intended to change one range of values into another range of values.  For example. Output from a temperature sensor is in centigrade. you can map it to give the result in Fahrenheit. To do that set: InMin to 0, InMax 100, OutMin to 32 & OutMax to 212
==Component Source Code==
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_Map-Function.fcfx FC_Comp_Source_Map-Function.fcfx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Map-Function.fcfx FC_Comp_Source_Map-Function.fcfx]


==Detailed description==
==Detailed description==
Line 37: Line 31:
==Examples==
==Examples==


A simple example showing how to take a value from an adc input with the range 0-255 and mapping this to a predetermined range of 50-150 to drive a PWM output.


 
{{Fcfile|MappingADCtoPWM.fcfx|Mapping ADC to PWM}}
 
 
 
 
 
 
 
 
''<span style="color:red;">No additional examples</span>''
 
 


==Macro reference==
==Macro reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===MapByte===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapUlong'''
| width="90%" class="mtx-class-macrohead" | '''MapByte'''
|-
|-
| colspan="2" | Map function for unsigned long type variables&nbsp;
| colspan="2" | Map function for byte type variables&nbsp;
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Value
| width="90%" | Value
|-
|-
| colspan="2" | Main variable used for map function&nbsp;
| colspan="2" | Main variable used for map function&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | InMin
| width="90%" | InMin
|-
|-
| colspan="2" | Lowest input value&nbsp;
| colspan="2" | Lowest input value&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | InMax
| width="90%" | InMax
|-
|-
| colspan="2" | Highest value input&nbsp;
| colspan="2" | Highest value input&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | OutMin
| width="90%" | OutMin
|-
|-
| colspan="2" | Lowest value after conversion&nbsp;
| colspan="2" | Lowest value after conversion&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | OutMax
| width="90%" | OutMax
|-
|-
Line 91: Line 76:
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===MapFloat===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapInt'''
| width="90%" class="mtx-class-macrohead" | '''MapFloat'''
|-
|-
| colspan="2" | Map function for signed int type variables&nbsp;
| colspan="2" | Map function for floating point type variables&nbsp;
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="90%" | Value
| width="90%" | Value
|-
|-
| colspan="2" | Main variable used for map function&nbsp;
| colspan="2" | Main variable used for map function&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="90%" | InMin
| width="90%" | InMin
|-
|-
| colspan="2" | Lowest input value&nbsp;
| colspan="2" | Lowest input value&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="90%" | InMax
| width="90%" | InMax
|-
|-
| colspan="2" | Highest value input&nbsp;
| colspan="2" | Highest value input&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="90%" | OutMin
| width="90%" | OutMin
|-
|-
| colspan="2" | Lowest value after conversion&nbsp;
| colspan="2" | Lowest value after conversion&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="90%" | OutMax
| width="90%" | OutMax
|-
|-
Line 134: Line 120:
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===MapInt===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapFloat'''
| width="90%" class="mtx-class-macrohead" | '''MapInt'''
|-
|-
| colspan="2" | Map function for floating point type variables&nbsp;
| colspan="2" | Map function for signed int type variables&nbsp;
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" | Value
| width="90%" | Value
|-
|-
| colspan="2" | Main variable used for map function&nbsp;
| colspan="2" | Main variable used for map function&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" | InMin
| width="90%" | InMin
|-
|-
| colspan="2" | Lowest input value&nbsp;
| colspan="2" | Lowest input value&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" | InMax
| width="90%" | InMax
|-
|-
| colspan="2" | Highest value input&nbsp;
| colspan="2" | Highest value input&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" | OutMin
| width="90%" | OutMin
|-
|-
| colspan="2" | Lowest value after conversion&nbsp;
| colspan="2" | Lowest value after conversion&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="10%" align="center" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" | OutMax
| width="90%" | OutMax
|-
|-
Line 177: Line 164:
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-f32-icon.png]] - FLOAT
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===MapLong===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapLong'''
| width="90%" class="mtx-class-macrohead" | '''MapLong'''
|-
|-
| colspan="2" | Map function for signed long type variables&nbsp;
| colspan="2" | Map function for signed long type variables&nbsp;
Line 225: Line 213:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===MapUInt===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapUInt'''
| width="90%" class="mtx-class-macrohead" | '''MapUInt'''
|-
|-
| colspan="2" | Map function for unsigned int type variables&nbsp;
| colspan="2" | Map function for unsigned int type variables&nbsp;
Line 268: Line 257:




{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
===MapUlong===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''MapByte'''
| width="90%" class="mtx-class-macrohead" | '''MapUlong'''
|-
|-
| colspan="2" | Map function for byte type variables&nbsp;
| colspan="2" | Map function for unsigned long type variables&nbsp;
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | Value
| width="90%" | Value
|-
|-
| colspan="2" | Main variable used for map function&nbsp;
| colspan="2" | Main variable used for map function&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | InMin
| width="90%" | InMin
|-
|-
| colspan="2" | Lowest input value&nbsp;
| colspan="2" | Lowest input value&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | InMax
| width="90%" | InMax
|-
|-
| colspan="2" | Highest value input&nbsp;
| colspan="2" | Highest value input&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | OutMin
| width="90%" | OutMin
|-
|-
| colspan="2" | Lowest value after conversion&nbsp;
| colspan="2" | Lowest value after conversion&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" | OutMax
| width="90%" | OutMax
|-
|-
Line 306: Line 296:
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
| colspan="2" | Clamp min & max so result does not go above or below set values. 0=No, 1=Yes&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




==Property reference==
==Property reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
|-
|-
|}
|}
==Component Source Code==
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_Map-Function.fcfx FC_Comp_Source_Map-Function.fcfx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_Map-Function.fcfx FC_Comp_Source_Map-Function.fcfx]

Latest revision as of 14:23, 13 July 2026

Author medelec35
Version 2.0
Category Calculation


Map Function component

The map function is intended to change one range of values into another range of values. For example. Output from a temperature sensor is in centigrade. you can map it to give the result in Fahrenheit. To do that set: InMin to 0, InMax 100, OutMin to 32 & OutMax to 212

Detailed description

No detailed description exists yet for this component

Examples

A simple example showing how to take a value from an adc input with the range 0-255 and mapping this to a predetermined range of 50-150 to drive a PWM output.

Mapping ADC to PWM

Macro reference

MapByte

MapByte
Map function for byte type variables 
- BYTE Value
Main variable used for map function 
- BYTE InMin
Lowest input value 
- BYTE InMax
Highest value input 
- BYTE OutMin
Lowest value after conversion 
- BYTE OutMax
highest value after conversion 
- BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
- BYTE Return


MapFloat

MapFloat
Map function for floating point type variables 
- FLOAT Value
Main variable used for map function 
- FLOAT InMin
Lowest input value 
- FLOAT InMax
Highest value input 
- FLOAT OutMin
Lowest value after conversion 
- FLOAT OutMax
highest value after conversion 
- BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
- FLOAT Return


MapInt

MapInt
Map function for signed int type variables 
- INT Value
Main variable used for map function 
- INT InMin
Lowest input value 
- INT InMax
Highest value input 
- INT OutMin
Lowest value after conversion 
- INT OutMax
highest value after conversion 
- BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
- INT Return


MapLong

MapLong
Map function for signed long type variables 
- LONG Value
Main variable used for map function 
- LONG InMin
Lowest input value 
- LONG InMax
Highest value input 
- LONG OutMin
Lowest value after conversion 
- LONG OutMax
highest value after conversion 
- BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
- LONG Return


MapUInt

MapUInt
Map function for unsigned int type variables 
- UINT Value
Main variable used for map function 
- UINT InMin
Lowest input value 
- UINT InMax
Highest value input 
- UINT OutMin
Lowest value after conversion 
- UINT OutMax
highest value after conversion 
- BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
- UINT Return


MapUlong

MapUlong
Map function for unsigned long type variables 
- ULONG Value
Main variable used for map function 
- ULONG InMin
Lowest input value 
- ULONG InMax
Highest value input 
- ULONG OutMin
Lowest value after conversion 
- ULONG OutMax
highest value after conversion 
- BOOL ClampMinMax
Clamp min & max so result does not go above or below set values. 0=No, 1=Yes 
- ULONG Return


Property reference

Properties

Component Source Code

Please click here to download the component source project: FC_Comp_Source_Map-Function.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_Map-Function.fcfx