Map

Classification Images
Name:
Map

Symbol:
MAP
Appearance:  

Appearance.
Group:
Converters

CannyLab version:
с 1.18
Icon:

Icon.
Inputs
Input Value
Value: Integer
Value from: Integer
Value to: Integer
Result from: Integer
Result to: Integer
Outputs
Output Value
Result: Integer

General description

Re-maps a number from one range to another using linear interpolation method. For the mathematically inclined, here’s the whole formula:

For the mathematically inclined, here’s the whole formula:

\[\ R= \frac{(R_t - R_f)*(V-V_f)}{(V_t-V_f)}+R_f\]

где:

  • R - result;
  • Rt - result to;
  • R~f ~ - result from;
  • V~t ~ - value to;
  • V~f ~ - value from.

The Map function block uses integer math so will not generate fractions. Fractional remainders are truncated, and are not rounded or averaged.

If the denominator of a fraction in above formula is zero, the Result is equal to 65535

Does not constrain values to within the range, because out-of-range values are sometimes intended and useful.

Features

You can use the Map function block to map an analog input value, which ranges from 0 to 4095 to a voltage value, which ranges from 0 - 5000 millivolts.

Examples

Map the value of a 12-bit 5V ADC to its corresponding voltage value in millivolts.

Example. ADC value to millivolts.

SEE ALSO