en-us_products:mpino_studio2:box_functions:arithmetic:scale
Table of Contents
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 |
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
Raddress as the destination. If the destination is an integer address such asD, the decimal part is discarded when the value is stored.
Box Functions in the Same Category
- ADD View details — Add
- SUB View details — Subtract
- MUL View details — Multiply
- DIV View details — Divide
- MOD View details — Modulo
- INC View details — Increment
- DEC View details — Decrement
- FLOOR View details — Floor
- SQRT View details — Square Root
en-us_products/mpino_studio2/box_functions/arithmetic/scale.txt · Last modified: by 127.0.0.1
