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 an integer from an input range to an integer output range. Values outside the input range are limited to the nearest boundary; equal IN_MIN and IN_MAX 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.
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
