Jump to content

Component: Map Function (Calculation)

From Flowcode Help
Revision as of 14:23, 13 July 2026 by SteveT (talk | contribs) (Text replacement - "width="90%" style="background-color:#D8C9D8; color:#4B008D;"" to "width="90%" class="mtx-class-macrohead"")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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