User Tools

Site Tools


en-us_products:mpino_studio2:box_functions:arithmetic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en-us_products:mpino_studio2:box_functions:arithmetic [2026/09/09 17:54] – 만듦 - 바깥 편집 127.0.0.1en-us_products:mpino_studio2:box_functions:arithmetic [2026/09/10 01:05] (current) – 바깥 편집 127.0.0.1
Line 5: Line 5:
 {{ :en-us_products:mpino_studio2:arithmetic-flow.svg?1000 |These commands store arithmetic, increment, scaling, and floating-point results. }} {{ :en-us_products:mpino_studio2:arithmetic-flow.svg?1000 |These commands store arithmetic, increment, scaling, and floating-point results. }}
  
-This ladder screen adds two WORD values with ADD. +===== Common Rules =====
- +
-{{ :en-us_products:mpino_studio2:ladder-add-2x.png?1000 |This ladder screen adds two WORD values with ADD. }} +
- +
-===== 1. Common Rules =====+
  
 The first two values are sources and the final address stores the result. ''INC'' and ''DEC'' change the target itself by one. The data format and range follow the memory rules in Phase 2. The first two values are sources and the final address stores the result. ''INC'' and ''DEC'' change the target itself by one. The data format and range follow the memory rules in Phase 2.
  
-===== 2. ADD, SUB, MUL, DIV, and MOD ===== +===== Box Function List =====
- +
-==== ADD ==== +
- +
-**Add** +
- +
-Adds two values and stores the result in the destination. +
- +
-**Syntax:** ''ADD D0 D1 D2'' +
- +
-^ Run condition ^ Before ^ Command entered ^ Expected result ^ +
-| Left condition ON | D0=12, D1=5 | ''ADD D0 D1 D2'' | D2=17 | +
- +
-==== SUB ==== +
- +
-**Subtract** +
- +
-Subtracts the second value from the first and stores the result in the destination. +
- +
-**Syntax:** ''SUB D0 D1 D2'' +
- +
-^ Run condition ^ Before ^ Command entered ^ Expected result ^ +
-| Left condition ON | D0=12, D1=5 | ''SUB D0 D1 D2'' | D2=7 | +
- +
-==== MUL ==== +
- +
-**Multiply** +
- +
-Multiplies two values and stores the result in the destination. +
- +
-**Syntax:** ''MUL D0 D1 D2'' +
- +
-^ Run condition ^ Before ^ Command entered ^ Expected result ^ +
-| Left condition ON | D0=12, D1=5 | ''MUL D0 D1 D2'' | D2=60 | +
- +
-==== DIV ==== +
- +
-**Divide** +
- +
-Divides the first value by the second and stores the quotient. With integer operands, the fractional part is discarded. +
- +
-**Syntax:** ''DIV D0 D1 D2'' +
- +
-^ Run condition ^ Before ^ Command entered ^ Expected result ^ +
-| Left condition ON | D0=12, D1=5 | ''DIV D0 D1 D2'' | D2=2 | +
- +
-==== MOD ==== +
- +
-**Modulo** +
- +
-Divides the first value by the second and stores the remainder. +
- +
-**Syntax:** ''MOD D0 D1 D2'' +
- +
-^ Run condition ^ Before ^ Command entered ^ Expected result ^ +
-| Left condition ON | D0=12, D1=5 | ''MOD D0 D1 D2'' | D2=2 | +
- +
-===== 3. INC and DEC ===== +
- +
-==== INC ==== +
- +
-**Increment** +
- +
-Increments the destination by one and stores it back at the same address. +
- +
-**Syntax:** ''INC D0'' +
- +
-**Arguments** +
- +
-  * 1st = D: target address (stores the previous value +1 back to the same address) +
- +
-^ Run condition ^ Before ^ Command entered ^ Expected result ^ +
-| Left condition ON | D0=7 | ''INC D0'' | D0=8 | +
- +
-==== DEC ==== +
- +
-**Decrement** +
- +
-Decrements the destination by one and stores it back at the same address. +
- +
-**Syntax:** ''DEC D0'' +
- +
-**Arguments** +
- +
-  * 1st = D: target address (stores the previous value −1 back to the same address) +
- +
-^ Run condition ^ Before ^ Command entered ^ Expected result ^ +
-| Left condition ON | D0=7 | ''DEC D0'' | D0=6 | +
- +
-===== 4. SCALE ===== +
- +
-**Scale (Linear Interpolation)** +
- +
-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:** ''SCALE D0 0 1023 R0 0 100'' +
- +
-**Arguments** +
- +
-  * 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 +
- +
-^ Run condition ^ Before ^ Command entered ^ Expected result ^ +
-| Left condition ON | D0=1023 | ''SCALE D0 0 1023 R0 0 100'' | R0=100.0 | +
- +
-===== 5. FLOOR and SQRT ===== +
- +
-==== FLOOR ==== +
- +
-**Floor** +
- +
-Stores the greatest integer that is not larger than the source. For example, 12.8 becomes 12 and -1.2 becomes -2. +
- +
-**Syntax:** ''FLOOR R0 R1'' +
- +
-**Arguments** +
- +
-  * 1st = source: address or constant to round down +
-  * 2nd = destination: address that stores the result +
- +
-^ Run condition ^ Before ^ Command entered ^ Expected result ^ +
-| Left condition ON | R0=12.8 | ''FLOOR R0 R1'' | R1=12.0 | +
- +
-==== SQRT ==== +
- +
-**Square Root** +
- +
-Stores the square root of the source. Use R memory as the destination when the result must retain its fractional part. +
- +
-**Syntax:** ''SQRT D0 R0'' +
- +
-**Arguments** +
- +
-  * 1st = source: nonnegative address or constant +
-  * 2nd = destination: address that stores the result +
- +
-^ Run condition ^ Before ^ Command entered ^ Expected result ^ +
-| Left condition ON | D0=81 | ''SQRT D0 R0'' | R0=9.0 | +
- +
-===== 6. Troubleshooting =====+
  
-Symptom What to check +Command Meaning 
-DIV or MOD produces no result. | Check whether the second source value is zero. | +[[en-us_products:mpino_studio2:box_functions:arithmetic:add|ADD]] | Adds two values and stores the result in the destination. | 
-The SCALE result stays at one boundary. | Check the input value and the order and range of IN_MIN and IN_MAX. |+| [[en-us_products:mpino_studio2:box_functions:arithmetic:sub|SUB]] | Subtracts the second value from the first and stores the result in the destination. | 
 +[[en-us_products:mpino_studio2:box_functions:arithmetic:mul|MUL]] | Multiplies two values and stores the result in the destination. | 
 +| [[en-us_products:mpino_studio2:box_functions:arithmetic:div|DIV]] | Divides the first value by the second and stores the quotient. | 
 +| [[en-us_products:mpino_studio2:box_functions:arithmetic:mod|MOD]] | Divides the first value by the second and stores the remainder. | 
 +| [[en-us_products:mpino_studio2:box_functions:arithmetic:inc|INC]] | Increments the destination by one and stores it back at the same address. | 
 +| [[en-us_products:mpino_studio2:box_functions:arithmetic:dec|DEC]] | Decrements the destination by one and stores it back at the same address. | 
 +| [[en-us_products:mpino_studio2:box_functions:arithmetic:scale|SCALE]] | Linearly maps an integer from an input range to an integer output range. | 
 +| [[en-us_products:mpino_studio2:box_functions:arithmetic:floor|FLOOR]] | Stores the greatest integer that is not larger than the source. | 
 +| [[en-us_products:mpino_studio2:box_functions:arithmetic:sqrt|SQRT]] | Stores the square root of the source. |
  
 ===== Related Documentation ===== ===== Related Documentation =====
  
   * [[en-us_products:mpino_studio2:box_functions|Phase 4 · Box Functions]]   * [[en-us_products:mpino_studio2:box_functions|Phase 4 · Box Functions]]
-  * [[en-us_products:mpino_studio2:box_functions:bit_latch|Bit and Latch Box Functions]] 
-  * [[en-us_products:mpino_studio2:box_functions:transfer|Transfer Box Functions]] 
   * [[en-us_products:mpino_studio2|MPINO STUDIO 2 User Manual]]   * [[en-us_products:mpino_studio2|MPINO STUDIO 2 User Manual]]
  
en-us_products/mpino_studio2/box_functions/arithmetic.1788944071.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki