User Tools

Site Tools


en-us_products:mpino_studio2:box_functions:arithmetic:scale

SCALE Box Function

Scale (Linear Interpolation)

Category: Arithmetic Box Functions

Behavior

Linearly maps a value from the input range to the output range and stores it in the destination. If any of the six arguments is real (an R address or a decimal constant such as 2.5), the calculation uses real numbers; if all are integers, it uses integers. Values outside the input range are limited to the nearest boundary. If IN_MIN equals IN_MAX, the function stores OUT_MIN.

Syntax and Arguments

Syntax: SCALE D0 0 1023 R0 0 100

  • 1st = input: address or constant to convert
  • 2nd = input minimum
  • 3rd = input maximum
  • 4th = destination: address that stores the output
  • 5th = output minimum
  • 6th = output maximum

Behavior Example

Run condition Before Command entered Expected result
Left condition ON D0=1023 SCALE D0 0 1023 R0 0 100 R0=100.0

Inputs and results for Arithmetic Box Functions

Cautions

  • Make sure the result stays within the value range of the destination memory.
  • If IN_MIN equals IN_MAX, OUT_MIN is stored. Check the minimum and maximum of the input range.
  • To keep the decimal part of the result, use an R address as the destination. If the destination is an integer address such as D, the decimal part is discarded when the value is stored.

Box Functions in the Same Category

en-us_products/mpino_studio2/box_functions/arithmetic/scale.txt · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki